Fortifications, both temporary and permanent, are almost as old as warfare itself.
Examples are walled towns, hill forts,
fortified camps and border fortresses.
Castles, which acted both as military structures and as residences and/or administrative centers, were far less common for most of history.
The first castles appeared in the late 10th century CE, a result of attacks by the vikings.
They acted as refuges for the civilian population, but later also as bases for raiding and conquest.
These early castles were of the motte-and-bailey type.
A motte is a hill, sometimes natural and sometimes built by hand, topped with a wooden, brick or stone tower: the keep.
Mottes seldom reached higher than 10 meters.
A bailey is a courtyard, enclosed by a circular wall, again either wood, brick or stone, that is anchored on the keep.
Often the wall would be enhanced by a ditch on the outside.
The design was not fixed; there were mottes without baileys and vice versa, or with multiple ones.
Motte-and-bailey castles were simple; the largest took less than a year to build, the smallest only a week.
From their origin in and around Normandy motte-and-baileys spread all over Europe.
In the 12th century they were taken over by other types.
The first successor type was the shell keep, which appeared in the 11th century CE.
In this design a stone wall encircled the motte.
It was built at the bottom, not at the motte itself, because that hill is often not strong enough to support a stone wall.
On the inside of the wall wooden buildings could be placed, like stables, granaries and living quarters.
From the shell keep it was a small step towards a fully stone castle.
This had no need of a motte, though retained the structure of an outer 'curtain' wall and an inner keep a.k.a. 'donjon'.
Curtain walls were high enough to seriously hamper siege ladders and towers and had battlements on top to protect defenders from missile fire.
At intervals the walls were studded with towers to strengthen their structure and to allow the defenders to shoot at the attackers from the sides.
Soon gates became the weakest part of the walls and they were in turn protected by gatehouses.
Stone castles were very expensive and could take up to 10 years to build.
But they could withstand long sieges with only small garrisons.
During the High Middle Age Europe, especially the west, was so densely packed with castles that sieges were far more common than field battles.
Outside Europe, true castles were less common, though fortresses were just as abundant in many places.
During the crusades, both christians and and muslims built castles and fortresses in the Middle East.
India has many castles.
In Japan they flourished in the 16th century CE, the Warring States Period.
Some Japanese castles match the best castles of Europe.
Around 1270 CE, castle designers took the next step and started to build concentric castles.
In these, multiple curtain walls surround each other, each inner one at a higher level than an outer one.
Any attacker had to overcome each obstacle one by one.
Often concentric castles had no central donjon, but offered a maze of walls and passages were defenders can counterattack from many sides.
Concentric castles were much stronger in defense than straightforward stone castles.
Another advantage was that they offered better living quarters to their inhabitants.
They were also more expensive, leading to a decline in the number of castles being built.
Heavy siege artillery like trebuchets could slowly break down castle walls.
When gunpowder bombards came of age in the 15th century CE, they did the same but much faster.
The importance of castles declined and for about 80 years there were more field battles being fought.
In the 15th century CE many castles were once more upgraded and became star forts, which could withstand a lot of artillery fire.
Others lost their military value but remained in use as residences for the nobility, not as fortresses but as opulent houses.
War Matrix - Castle
Viking Age 800 CE - 1066 CE, Weapons and technology