The castle in the Middle Ages