I love how the anxiety is a red herring and that the actual cause for Snape not being able to leave is because he will die if he goes too far and that it is 'punishment' for his transgressions.
This just goes to show the failings of artificial intelligence. I don't think the Castle has the intelligence of a five year old, it is more an animal. A five year old can at least understand complexities of things not being as they appear, that people are 'pretending' to be something else. An animal can only understand a threat and punishing that threat.
The Castle's personality actually made me think of HAL.