The construction of Castle Tersurus was influenced by the Master and the Ninth Doctor, both of whom seperately and repeatedly travelled back in time to bribe the architect, who they communicated with in his native Tersuran, to make the other fall into traps while anticipating that they would later bribe the architect to do the same.
While the Master bribed the architect to create the Spikes of Doom as a trap in the castle, the Doctor countered this by travelling further back and bribing him to make the Sofa of Reasonable Comfort instead. Anticipating this, the Master travelled even further back, creating in a piece of masonry which he would later use in an attempt to crush the Doctor, however, the Doctor travelled further, resulting in his survival as the masonry was made hollow.
These bribes were made all in anticipation of the Doctor and the Master's confrontation on Tersurus, arriving in their TARDISes a hundred years after the Master first travelled back to meet the architect from his perspective. The Doctor had arranged this meeting with the Master to inform him of his intention to marry his companion Emma. Ultimately, it was the Doctor who prevailed against the Master, having travelled in his TARDIS further back than the Master ever did, he had dinner with the architect and suggested he place a lever-operated trapdoor leading to the vast sewers of Tersurus at a spot where the Master fell before he could go back and make his own suggestion regarding a trapdoor. (NOTVALID: The Curse of Fatal Death)