A computer called M5 built by the scientist Daystrom is being tested out on the Enterprise. The implication of its success being that a starship no longer requires a crew, let alone a captain. We see the computer manoeuvre the starship through an unscheduled test encounter successfully.
The scientist responsible for M5 is gleeful, while Kirk is upset harrassed by the idea of a starship being controlled by a computer. To resolve this McCoy prescribes alcohol which makes Kirk quote Masefield. Spock is generally fascinated, though doesn’t want to take instructions from a computer.
Following this, there is an encounter with another unmanned ore freighter. The M5 refuses to disengage and instead blows it apart with the photon torpedoes. An infuriated Kirk proceeds to physically disconnect M5, which electrocutes him in order to protect itself. M5 also proceeds to tap into the ship’s warp engine matter-antimatter reserve to get “unlimited” power, while also vaporizing an ensign who happened to get in the way.
Spock and Scotty attempt to disengage the rogue computer from a differnt place in the ship, while McCoy tries to get the scientist to shut down the computer. This time instead of giving excuses, the scientist changes his tone and seems sympathetic towards the computer. Soon Scotty realizes that it does not work and that they had been fooled. On further questioning, the scientist Daystrom finally reveals that he’s managed to emulate human behaviour in this new computer of his.
All this while, the ship is rapidly accelerating to the four starships that are waiting for a planned war game intended to test the M5 system. What they do not know is that M5 is completely in control and on course to obliterate them.
The crew is helpless as the starship proceeds to have its way with the four ships. It manages to kill all the humans on the first ship. Daystrom then reveals, that the computer is engineered to emulate his brain. Kirk decides to put the computer in an inconsistent state by first questioning its ethics and then its behaviour. Noting the inconsistency, the computer decides to shut down and relinquishes control so that it may be destroyed by the three remaining starships. The day is saved after Spock and Scotty manually disconnect the computer from the Enterprise.
The idea of a computer gaining sentience and then proceeding to assume complete control is not new to Star Trek. Nor is the idea of pointing out inherent logical inconistencies to render them unusable. The idea was first explored in “The Return of the Archons” (S1E21), where using a similar technique, Kirk causes a computer to self-destruct. Now why a computer would self destruct just because it was pointed to a logical inconsistency is not explained in either of the episodes. The process also involves a tedious walkthrough of the conflicting facts used to bring about the inconsistency.
Also stupid is the idea of testing out an AI by giving it complete control of a military class spaceship without any kind of safeguard in place. It is often mentioned that the Enterprise requires a crew of 800 to run properly. But all of that crew is removed when the testing is happening. What is the contingency in the case where the AI fails to do so?
Lack of the most basic logic in constructing the plot makes this a pretty lame episode.