the history of the medieval castle