How do the leaders' AI personalities work?

They have a pre-made AI personality script, that gives them their unique behaviour. To give an example, Catherine is the only leader that might declare war on you even if you have the best (Friendly) relationship, other leaders will never do this. She is the backstabber.

Of course this behaviour will also match their traits more or less, so Montezuma, Shaka or Napoleon are more likely to go into war (actually you will see them fighting most of the time), while Hatshepshut, Gandhi or even Mansa Musa will attack you quite rarely.