The Enterprise is summoned to a space station without explanation. Commodore Wesley, commanding a group of starships from the USS Lexington, explains that the Enterprise will be a test vessel for a revolutionary tactical and control computer called the "M-5 Multitronic System", designed by the brilliant Dr. Richard Daystrom.[N 1]
The M-5 will handle all ship functions without human assistance. While Captain Kirk and Chief Medical Officer Dr. McCoy are unhappy about the test, Science Officer Spock is impressed with M-5. However, Kirk learns that four earlier prototypes were unsuccessful, giving him further doubts.
At first M-5 works well, performing ship functions more quickly and efficiently than a living crew. Later, M-5 exhibits quirks such as turning off power and life support to unoccupied parts of the ship. It draws increased power for unknown reasons. But Daystrom maintains M-5 is working properly.
In a drill, M-5 defends the Enterprise against mock attacks from starships Excalibur and Lexington. The Enterprise is declared the victor, prompting Commodore Wesley to call Kirk "Captain Dunsail" (pronounced "dunsel"). Spock explains the term is used by midshipmen at Starfleet Academy to describe a part serving no useful purpose. Kirk is visibly shaken by this.
Soon after, M-5 detects the Woden, an unmanned freighter that is not part of the test, and attacks with real weapons, destroying it. Kirk orders M-5 taken offline, but Daystrom continues to believe it is working correctly, and refuses.
Kirk tries to disconnect M-5, but discovers it is protecting itself with a force field. Chief Engineer Scott assigns Ensign Harper, a technician, to unplug the main connection, but the crewman is killed in the process. Spock and Scott desperately attempt a manual override, but they discover M-5 has bypassed its power source and now draws energy directly from the ship's warp engines. Daystrom persistently defends M-5 and refuses to disconnect it.
Spock questions Daystrom on his computer design. Daystrom reveals he has programmed human engrams into M-5. Pressed further, Daystrom admits the engrams he used were his own, meaning M-5 thinks similarly to Daystrom himself. With increased stress and anger, Daystrom appears unstable. M-5 now shows similar instability. An attempt by the Enterprise crew to isolate M-5 from the ship fails, as they are duped by a decoy.
Meanwhile the other ships in the test continue unaware of the problems with the Enterprise. Next follows a war game against Federation starships Lexington, Potemkin, Excalibur, and Hood. M-5 detects the ships, but does not treat them as part of the trial, instead firing on them with full-strength weapons. Daystrom states the M-5 is programmed to preserve itself by any means. Although surprised by M-5's actions, Daystrom simply views them as mistakes made by a learning "child." An angry Kirk asserts these "mistakes" are costing lives, and the computer must be shut down.
The crew watches as M-5 pounds the other ships relentlessly. The Enterprise fires on the Lexington, killing 53, then completely cripples the Excalibur - killing all aboard her and leaving her to drift in space. From the Lexington, Commodore Wesley contacts Starfleet Command for permission to destroy the Enterprise. Since M-5 has disabled communications, Kirk is unable to contact Commodore Wesley and explain what is happening.
Kirk demands that Daystrom act, and make the computer stop the attack. Daystrom at first tries to reason with the M-5, but then becomes more unstable, rambling about proving his worth and cursing colleagues taking credit for his work. McCoy sees a psychotic episode coming, and warns Kirk the scientist is becoming delusional.
Kirk has Daystrom taken to sickbay after Spock fells him with a Vulcan nerve pinch. Kirk then talks to M-5 to see whether he can persuade it to stop the attacks. The M-5 acknowledges Kirk, who asks M-5 what its purpose is. M-5 responds "To save men from the dangerous activities of space exploration". Kirk rejoins that it just acted contrary to its purpose by killing people. M-5 recognizes the penalty for murder is death, so it shuts itself down. In so doing, it cripples the Enterprise, setting the ship adrift.
Having permission from Starfleet, the other Federation ships now close on the Enterprise to destroy it. While Scotty frantically attempts to regain control of the ship, Kirk decides to let the ship drift with shields down, hoping that Commodore Wesley will realize what the situation is aboard the Enterprise. The gamble pays off as the Commodore orders his ships to stand down at the last moment.
McCoy says that Daystrom will be committed to a rehabilitation center. Kirk explains that he knew that Bob Wesley would not fire, because he gambled on his humanity. McCoy pointedly comments that compassion is something computers lack. Spock responds that machines are more efficient than human beings: not better. He then dryly remarks that if McCoy's engrams were impressed in a computer, the resulting torrential flood of illogic would be most entertaining. 
Errors and Explanations
The Nitpicker's Guide for Classic Trekkers
- In Star Trek: The Next Generation, the creators make frequent mention of the Daystrom Institute of Technology. Was that institute named for the Richard Daystrom who appears in this episode? True, he is acknowledged as a genius but he also is responsible tor the slaughter of more than four hundred Starfleet personnel. Wouldn't that be enough to get you kicked off Starfleet's list of the top ten most beloved scientists? The slaughter was actually due to the actions of the M-5 unit, not Daystrom. Besides, the use of his name for the UFP's premier institute of technology could be part of a plan to rehabilitate his reputation.
- Why is Starfleet letting M5 operate a Constitution class starship? Wouldn't it be more reasonable to give it something like a freighter for its first “real world" test? Freighters are generally unarmed, and therefore not equipped to fight battles such as the one that forms the finale of the test.
- The Woden - the old-style freighter that the M5 destroys - looks a lot like the SS Botany Bay, but they can't be the same type of ship. The Botany Bay was a DY-100 class ship meant for interplanetary travel and built in the 1990s.[N 2] Does the merchant marine actually have ships this old? It is more likely to be a newly built ship based on the old design, in the same way that new examples of WW2 fighter aircraft are built specifically for the warbird market.
- The doors in sick bay show a marvelous sensitivity in this episode. After Kirk and Spock visit a heavily sedated Daystrom, McCoy joins them on the way to the bridge. For some reason the camera stays behind in sick bay, and the trio walks away from it and onto a turbolift. Thankfully, the doors in sick bay understand our need to watch our heroes depart and graciously stay open until Kirk, Spock, and McCoy walk across the hall and board the turbolift. Even more amazing, the doors know that Daystrom needs his rest and therefore open with absolute quiet. This could be an experimental setting.
- Johnny Veitch on Tuesday, March 02, 1999 - 3:23 pm - If M5 acknowledged both messages from Commodore Wesley saying that it's an M5 drill, how come M5 thinks of them as "enemy vessels"? Mike Konczewski on Wednesday, March 03, 1999 - 7:56 am - The reason M5 responds to the messages with "it's just a drill" is that M5 is lying to fool Commodore Wesley. By lulling his suspicions, he's easier prey. Kahn did the same thing in STII.
- Mf on Wednesday, March 03, 1999 - 10:32 am - Hundreds (thousands?) of Starfleet officers die at the hands of the Enterprise, right? Kirk's career (responsible or not) has to take a hit for this one. Spockania on Wednesday, March 03, 1999 - 8:07 pm - Why? He was "Captain Dunsel." Commodore Wesley seems to be in charge, AND he is the superior officer. He ought to take the blame. Seniram (20:54, October 1, 2014 - UTC) Technically, Daystrom and the M-5 unit were responsible. The Federation may consider Daystrom's breakdown, triggered by the loss of M-5, to be sufficient punishment.
- MattS on Thursday, May 13, 1999 - 2:01 pm - At the end of the show, while McCoy and Spock are poking fun at each other in the turbolift, Spock should know that "illogic" is not a word. But hey, I guess English isn't his first language. Unless illogic became a word by the 23rd century - perhaps as a contraction of illogical, just as can't is a contraction of cannot.
- Sophie Hawksworth on Saturday, April 06, 2002 - 5:32 am - At the end, why can't Kirk contact Welsey by communicator? Ships's communications are down, not blocked. The direct (non-relayed) comm range of the communicators may be too short to allow communication between starships.
Internet Movie Database
- As Kirk, Spock and McCoy ride the turbolift to engineering, Spock observes that it is unfortunate no computer can replace a starship surgeon. As they exit the turbolift, McCoy replies "Very funny" but his mouth is not moving. As stated in other entries, there are a few members of the crew who appear to have mastered the ventriloquial arts.
- As M-5 is evaluating a planet for exploration, Scott remarks that M-5 is cutting off power on decks 4 and 5. In the following scene, Dr. Daystrom explains why power was cut off on decks 4 and 5. Captain Kirk's quarters are on deck 5, which should still be available as he remains on the ship. Kirk is probably the only crew-member still on board with quarters on Deck 5, and would presumably be expected to move to another deck for the duration of the tests.
- When Lieutenant Uhura informs Captain Kirk that the M-5 had already acknowledged a transmission from Commodore Wesley, her left hand is holding the earpiece in her left ear. As the camera cuts to Kirk for his reaction, her hand is at her side.She probably adjusted the position of her hand while the camera cut to Kirk.
- Kirk gets the M-5 to commit suicide by asking what is the penalty for murder. However, in The Menagerie Part 1, it's established that the death penalty has been abolished for all crimes with the exception of visiting Talos IV. This could be due to M-5 displaying acknowledgement of it's guilt, in relation to the deaths it has caused, and automatically deactivating itself to prevent further unnecessary deaths.
- ↑ Daystrom had also invented the TOS era computer systems, after developing duotronics when he was 24 years old.
“ Could someone send me a post-card when these are ready to sail? I'd love to take a trip to Mars, and these are the '90s, after all. ”
–Phil Farrand, author of the Nitpicker Guides.