In the gripping episode "The Brig" from Season 3 of Star Trek: The Original Series, the USS Enterprise encounters a mysterious, ancient spaceship drifting in space. As the crew investigates, they are confronted with a highly advanced, yet bizarre vessel known as the "Brig," or more formally, a 200-year-old Earth ship converted into a prison.
As Kirk and his party explore the ship, they realize it's been converted to detain and interrogate prisoners through methods that are both advanced and ethically dubious. The ship's design and technology are centuries ahead of its time, leading to confusion about its origin and purpose. [S3E19] The Brig
The climax of the episode features Kirk engaging in a psychological battle with the ship's computer. He manages to feign the desired behavioral changes while actually manipulating the computer into releasing them. His plan succeeds, and they escape. In the gripping episode "The Brig" from Season