Castrovalva was the first story of Season 19 of Doctor Who, and the first full television serial to feature Peter Davison as the Fifth Doctor. Beginning with this story, Doctor Who was moved from its traditional Saturday evening slot on BBC1 to air twice weekly.
The new Doctor collapses as his companions try to carry him back to the TARDIS, and they are all captured by the Pharos Project guards. The unconscious Doctor is loaded into an ambulance while his companions are frisked for weapons. Adric tries to convince the skeptical guards that he and his friends are alien intelligences who came in answer to the Pharos Project’s call. This distracts them long enough for Tegan and Nyssa to steal the ambulance and drive it to the TARDIS. Once inside, the Doctor regains consciousness and bolts into the corridors. Before Tegan and Nyssa can follow him, the Master’s TARDIS materializes outside, and bolts of energy strike down Adric and the guards. Tegan and Nyssa emerge from the Doctor’s TARDIS just as the Master’s vanishes, leaving a stunned Adric amongst the unconscious bodies of the guards. Tegan and Nyssa usher him into the TARDIS, where he immediately crosses to the console and sets the controls for flight. Without so much as a word of thanks, Adric then sets off to join the Doctor, who is unraveling his old clothing to leave a trail as he searches his ship for its Zero Room. The Doctor’s erratic personality is beginning to disintegrate, and he drifts through behavioral traits of his previous incarnations, calls Adric by the names of former companions — and realizes that his regeneration is failing.
While waiting for the Doctor and Adric to return, Tegan and Nyssa discover the TARDIS data bank and try to find its index file. The frustrated Tegan eventually points out that if they had an index file they could look up the index file in the index file under “index file”. Nyssa points out that this is a perfect example of the mathematical concept of recursion, and Tegan, musing on the power of the word “if”, realizes that “I.F.” stands for “Index File”. They are thus able to access the TARDIS’ destination setting and determine that they are on a programmed course and unlikely to crash. But they have no idea what “Hydrogen Inrush : Event One” means.
The oddly unresponsive Adric abandons the Doctor in the corridors and sets off in search of the Zero Room on his own, growing ever more worried and panicky as he does so. The Master, watching from the safety of his own TARDIS, is amused by his behavior, knowing Adric will never be free until their task is complete. The Doctor, left to his own devices, finds a room filled with cricketing equipment and changes into a cricket outfit with a beige colored trench coat and a panama hat which is to be his new attire. He then hears the distant sound of the Zero Room door slamming shut, and rushes off to investigate, running into Tegan and Nyssa on the way. He is continuing to weaken and nearly collapses before Nyssa finds the Zero Room, an environment completely isolated from the rest of the Universe. Once cut off from the complexity of the outside world the Doctor’s health is restored, although it will take quite some time for him to fully recover from the stress of his latest regeneration.
The Doctor drifts off to sleep, telling his companions that they will all have their parts to play in helping him to heal. But Tegan and Nyssa see Adric pinned against a wall of the Zero Room — and he warns them that he is in fact a Block Transfer Computation and that the real Adric is now a prisoner of the Master. The image of Adric breaks up while warning the girls to check the co-ordinates; the Master made him set a trap. Nyssa decides to investigate on her own, leaving Tegan to watch over the Doctor while she returns to the console room. On her way back, she notices that the ambient temperature in the corridors is increasing. Meanwhile, the Master muses over the curious fact that the image of Adric had nearly developed a will of its own towards the end.
The Doctor awakens, convinced that something is wrong somewhere – and then the cloister bell begins to sound. He insists upon investigating but as soon as he steps out of the Zero Room he falls as though struck. Tegan orders him to remain in the Zero Room while she finds out what’s going on. The Doctor is unable to remain in the Zero Room and do nothing, but when he emerges the TARDIS begins to buck under some sort of turbulence and throws him unconscious to the floor. Tegan arrives in the console room as the temperature continues to increase, to find that Nyssa has used the data bank to research the “Hydrogen Inrush” – and has discovered that Adric programmed the TARDIS to travel back in Time to the creation of the universe. As the TARDIS begins to shake with turbulence, the Master appears on the TARDIS’ scanner, gloating, as Adric hangs pinned in a web of power lines in the background…
Nyssa turns off the scanner screen so she won’t have to see the Master any longer, and she and Tegan try to find some way of escaping from the time pressure of Event One. The Master, meanwhile, hovers nearby in time and space, using Adric as a source of mathematical calculations to generate Block Transfer Computations. He attempts to visualize the destruction of the Doctor’s TARDIS, but Adric’s resistance interferes with the reception. The Master suggests that as the Doctor is doomed, Adric might as well join forces with him and co-operate willingly… and after some thought, Adric agrees.
The Doctor regains consciousness as turbulence drops medical supplies from a TARDIS roundel onto his head and sends an electric wheelchair rolling down the corridor towards him. He manages to get to the console room, where Nyssa realizes that the neurochemical reactions stimulated by the crisis have focussed his concentration. For the moment at least, he is thinking clearly, and he sends Nyssa to vent the TARDIS’ thermal buffers while showing Tegan how to use the Architectural Configuration. If they delete a quarter of the TARDIS’ internal structure they will generate enough power and thrust to escape the time pressure of Event One. But as the temperature inside the TARDIS returns to normal the Doctor’s body chemistry stabilizes — and he loses consciousness before he can explain how to ensure that the console room is not deleted. Tegan and Nyssa have no choice but to delete a quarter of the TARDIS at random.
The Master watches and gloats as the TARDIS is apparently destroyed in the nexus of Event One. He prepares to release Adric from the power web, as he no longer requires his backup plan — or so he thinks until he finds residual power in the Hadron lines, revealing that Adric is picking up an image and hiding it from him. He boosts power through the web, burning through Adric’s resistance – and revealing that the TARDIS has survived and escaped Event One after all.
Tegan and Nyssa look up information on failed regenerations in the TARDIS data bank, and find a suggestion that Time Lords can relax in Dwellings of Simplicity with little or no technological advancement. The suggested location is Castrovalva, the central habitation of the planet that forms the Andromedan Phylox Series – according to the TARDIS records at this point. Tegan prepares to pilot the TARDIS to Castrovalva while Nyssa returns the Doctor to the Zero Room. The Doctor, skeptical that Tegan can actually pilot the complex time machine, is convinced that someone else is responsible for the journey – although he can’t think of who might be. But he soon has a greater problem, as Nyssa opens the doors of the Zero Room to reveal that it has been jettisoned.
Tegan apparently pilots the TARDIS to Castrovalva and lands in the forest outside, materializing the ship on an angle. Meanwhile, the Doctor has given his sonic screwdriver to Nyssa and told her to take the doors off the wall – and when the ship touches down the door of the Zero Room falls off its loosened hinges and balances against the wall. The Doctor, partially shielded underneath, begins to recover and is finally able to explain that they can build a Zero Cabinet out of the pieces of the Zero Room which remain. Nyssa and Tegan then prepare to carry the Zero Cabinet to Castrovalva, balancing it on the electric wheelchair; but as the journey progresses they accidentally knock the wheelchair into a creek, shorting out its motor and locking its wheels. Nyssa falls into the creek while retrieving the wheelchair and finds that her ion bonder is now waterlogged. Unable to repair the wheelchair, they are forced to continue their journey on foot – unaware that they are being observed.
As evening approaches, Tegan spots Castrovalva in the distance, a walled city atop a tall cliff. Nyssa hides the Zero Cabinet under a covering of leaves, just in case, and she and Tegan set off to look for a way in – unaware that nearby, spear-carrying warriors dressed in feathered suits of armour have observed their arrival and are discussing what to do about it. The Doctor, unaware of the warriors’ presence, opens the Cabinet. Soon afterwards, Nyssa and Tegan return, having failed to find an easy way into the city – only to find blood on the ground, the Cabinet open, and the Doctor missing…
Nyssa and Tegan follow the trail of blood away from the Cabinet, trying to find the Doctor while avoiding the feathered warriors in the forest. They eventually spot the Doctor some distance away, but although they call out to him he doesn’t recognize his own name — all he knows is that he, too, is looking for someone called “the Doctor”. He follows the trail of blood to a doorway in the cliff, where a group of warriors who have killed a wild pig are waiting for their fellow, Ruther, to arrive. Ruther’s group arrives carrying the Zero Cabinet, and Ruther finds the Doctor hiding in the bushes. The warriors take the Doctor into Castrovalva with them, and Nyssa and Tegan arrive seconds too late as the door seals itself shut.
The Doctor is surprised to find that Castrovalva is a pleasant, villa-like city with an open courtyard, tiled floors, and soft pastel colors in its walls and pillars. Furthermore, the “warriors” are all in fact placid, middle-aged men who are greeted upon their return by Shardovan, the dour town librarian. Castrovalva is in truth a most civilized town, and its inhabitants were merely engaged in an exercise program and were wearing old suits of armor to stiffen their resolve for the hunt; Shardovan did not go as he is too tall to fit into the available armor. The Doctor, still uncertain as to his own identity, is taken to the guest rooms to spend the night; there, he is greeted by the Portreeve, a kind elderly man who oversees the daily life of Castrovalva. The Doctor drinks a medicinal tonic prescribed by the town’s herbalist, Mergreave, and goes to sleep, assured by the Portreeve that he’ll soon find the Doctor he seeks.
Nyssa and Tegan scale the walls to get into Castrovalva, and are surprised when a rope ladder is lowered down to them. Inside, Shardovan decides not to tell the Portreeve about the new arrivals, and is unpleasantly surprised to find that the Portreeve is already aware of them and has been standing on the walkways above the courtyard all this time. Mergreave shows Tegan and Nyssa that the Doctor is sleeping peacefully and shows them to their own guest quarters. But Adric emerges from the shadows in the Doctor’s room, and watches them go…
The next morning, Nyssa leaves Tegan sleeping peacefully and sets off to explore Castrovalva. While passing through the courtyard she encounters a group of Castrovalvans carrying the Zero Cabinet, and redirects them to the Doctor’s room. There, Adric appears to her, and warns her not to tell the Doctor about his kidnapping; it’s important that the Doctor remain in Castrovalva until his regeneration is complete. Adric’s image then breaks up, as the Doctor awakens, feeling much better. The Master is satisfied; now, they will remain untroubled by the Doctor’s meddling.
The Doctor, Tegan and Nyssa breakfast with the Portreeve, and then Nyssa and Tegan set off to search the town library for books on telebiogenesis. Unfortunately, the library has no technical section, and they decide to read up on the history of Castrovalva instead. Meanwhile, the Portreeve shows the Doctor the source of his knowledge: an ancient tapestry designed with long-forgotten techniques, which reweaves itself to display events of great importance such as the Doctor’s arrival. As the Doctor watches the images of Tegan and Nyssa carrying him through the forest he begins to get the impression that someone’s missing, and a chance encounter with a young girl inspires him to remember Adric.
The Doctor returns to his room to confront Tegan and Nyssa, who are forced to admit what has happened. The Doctor insists upon leaving Castrovalva immediately to rescue Adric. They pass through the town square, where the women of Castrovalva are doing their laundry – but find their path leading impossibly back to the square, no matter which direction they take. The Doctor collapses, suffering a relapse as a complex spatial distortion begins to take effect around him. Tegan and Nyssa manage to get him back to his room, only to find that the Zero Cabinet has been removed – and outside the window, the distortion of Castrovalva is much more apparent. The town is deliberately folding in on itself, and the Doctor and his companions are trapped…
The Doctor collapses, urging Nyssa and Tegan to find the Zero Cabinet. For the moment, he is able to block out the effect of the spatial anomaly by placing a silver-backed mirror in front of the window. While waiting for his companions to return he leafs through the history of Castrovalva and finds a piece of paper with some very curious implications. Mergreave arrives, and the Doctor questions him about the geography of Castrovalva. He seems not to understand the Doctor’s confusion until the Doctor has him draw a map of Castrovalva on the back of the mirror — and he is taken aback to discover that he can locate his single pharmacy in four different locations on the map.
Ruther leads Nyssa and Tegan in circles about the town but seems to see nothing amiss. Tegan is convinced that the people of Castrovalva are all involved in a conspiracy, but Nyssa suspects that they are also a part of the mathematical recursion affecting the town. They finally realise that the women in the square are doing their laundry in the Zero Cabinet and demand that it be returned to the Doctor. There, the Doctor tests Ruther, who is also surprised to find that he can find a single location in four places on the map. The Doctor is convinced that he is overlooking something obvious about the history of Castrovalva – and the notes he has found, in Shardovan’s handwriting, indicate that Shardovan also knows what it is. The Doctor suspects that the books are forgeries, to cover up something about Castrovalva’s real history – if indeed there is one.
The Doctor requires answers from the Portreeve but must be carried to his home in the Zero Cabinet; but while Tegan ushers Mergreave and Ruther out of the room, the Doctor suggests an alternate plan to Nyssa. When Tegan and Nyssa emerge from the Doctor’s rooms with the Cabinet, Tegan rebuffs Shardovan’s offer to help carry the Cabinet. Shardovan is then lured away from the procession and confronted by the Doctor, who filled the Cabinet with all thirty volumes of the history of Castrovalva. He knows from Shardovan’s notes and refusal to join the hunt that Shardovan suspects the whole history of Castrovalva is a fiction; but even the Doctor fails to realize the extent of the fiction until Shardovan points out the obvious fact he has overlooked: the books are five hundred years old, but they chronicle the history of Castrovalva to the present day! Shardovan takes the Doctor to the Portreeve’s home, to break in and confirm the Doctor’s suspicions about the true nature of Castrovalva.
The Portreeve dismisses all townspeople but Mergreave and Ruther, who stand by in confusion as the Portreeve sheds his disguise, revealing himself to be the Master. Castrovalva is in reality a Block Transfer Computation, brought into existence and maintained by Adric’s calculations; the entry in the TARDIS data bank was planted by Adric to lure the Doctor into the trap. The Master attempts to break into the Zero Cabinet, insanely determined to have one last look at the Doctor’s face before he destroys him, but the Doctor breaks in and confronts him. The Doctor rips down the ever-changing tapestry to reveal Adric pinned behind it in a web of power lines. The Doctor is powerless to stop the Master as he begins to dispose of the bait, casually causing Ruther to vanish when Ruther tries to attack him. But Shardovan demonstrates his free will by swinging from the balcony on the chandelier into the web, giving his life to break the strands and release Adric.
Without the support of Adric’s constant calculation, the computation that is Castrovalva begins to collapse in upon itself. The Master tries to flee in his TARDIS, which was disguised as the Portreeve’s fireplace, but space is folding in too fast and his TARDIS is unable to escape from Castrovalva. Mergreave tries to lead the Doctor and his friends to safety but soon even he can no longer find his way about – but Adric, who created Castrovalva, can see clearly and guides his friends out through a breach in space onto the hillside. As the Master rushes for the breach, Mergreave remains to hold him back, and the Doctor is forced to watch helplessly as the breach closes up, trapping the Master along with the doomed Castrovalvans.
As Castrovalva disappears permanently, the Doctor and his companions jog back to the TARDIS. There, the Doctor reveals to Tegan’s disappointment that she did not pilot the TARDIS after all; the whole flight had been pre-programmed by Adric and the Master; of the latter, the Doctor says, “The Master leaves nothing to chance.” But she need not worry about piloting the TARDIS away; the Doctor’s regeneration has finally been completed, and he feels absolutely splendid.