After Tegan believes she successfully landed the TARDIS,she and Nyssa drag the doctor in his make shift miniature zero chamber to the city of Castrovalva,which Tegan sees at walking distance. After a long walk to this particular local,she and Nyssa are set upon by what appear to be a group of masked hunters. One of them is a is a librarian named Shardovan,who along with the local leader the Portweeve insist the doctor get some rest. Things continue to be amiss however when,while consulting books from the library on the history of Castrovalva,even Tegan is puzzled by the inconsistencies she witnesses. Following a visit from Adric to Nyssa warning her not to reveal his presence,the doctor awakens to the fact Adric is the key presence missing. While trying to leave Castrovalva to find him with his two companions,he realizes the entire city is part of (and it's population defined by) a time/space loop with no resolution. Helping Shardovan to realize this the doctor engineers an escape for his companions when Portweeve is revealed to be the master. And Castrvalva,it's history and very existence a complete contrivance to destroy the doctor. Having escaped Adric returns with Tegan,Nyssa and the now fully regenerated doctor to continue their voyages in the TARDIS.
This concludes a loose trilogy of stories with The Master as the connective thread,and which led to the regeneration of Tom Baker's fourth doctor to Peter Davison's fifth in this story. And this is probably one of the most involved regeneration stories from the classic Doctor Who series as the doctor pays quite a price for this particular incarnation of himself. Throughout most of the story the Doctor is rather absent,leaving Tegan and Nyssa as new arrivals to have to put aside their doubts about the doctor they've just met and put their minds together to pilot the TARDIS even the doctor,at the best of times,has trouble dealing with. Also present is the issue of control. The doctor,abley portrayed by Davison as having a complete crisis of identity (his use of the vocal and physical inflections of William Hartnell and Patrick Troughton is a highlight of his acting in this story) which The Master uses to create a whole society to distract the doctor. There's also an interesting presidents in the contrivance of Castrovalva itself. As they continue to repeat the same events,the natives of the city become extremely shocked when they realize how psychically numb they've become to their own unreality. It's almost the concept of 'The Matrix' seventeen years before the fact. But as with Doctor Who,the outcome is inevitably a positive one.