The challenge: make AI that cares about its own survival, like any real-world creature, but provides interesting gameplay and doesn’t simply flee at the slightest sign of trouble.
As the about U.R.R. page notes, a major design goal for my game is the AI. I don’t want AI that just runs blindly into your sword-swings like in most games. Ultima Ratio Regum is instead populated by creatures that – while they have their own objectives, often involving killing the player – also care about their own self-preservation. An Orc will not charge into combat with a Titan by itself; if pressed, it will flee, and if pressed further, it might even lose its mind from terror. Hilarity ensues. Other activities – such as allies fighting over a good item, or rallying their team-mates – hopefully contribute to the realism and self-serving objectives of the AI.
To demonstrate something about the AI, I present to you this flowchart. Before you look, it is worth first noting this diagram is something of a simplification. For example, if a creature sees an item they want, they do not automatically go after it – there is instead an algorithm involving how much they want it, how far away it is, how good the item is, how close they are to an enemy they want to kill, and a few other factors, all of which come into play to decide if they stay where they are or make the detour. However, this diagram still demonstrates the connections between varying conditions – indicated by diamonds – and states, indicated by the shaded rectangles.
Now, this diagram only applies specifically to creatures who are trying to kill you – it makes no note of neutral creatures, monsters attempting to kill foes who aren’t the player, and allies. All of those will come later. Additionally, each ‘state’ – the rectangular boxes – will be examined in more detail in later blog entries. For now, however, let’s talk about a few of the most important points from that diagram.
– Starting states
Monsters – barring a few, rare, exceptions – can only be spawned as the black states. If they begin wandering, they just move themselves around the map. Monsters who begin waiting will remain where they are until they catch sight of an enemy. Guards will remain at their post until they either see a foe they despise so much they simply must come out and fight, or – much more likely – until they are attacked, or in some other way angered. Some monsters can spawn sleeping, in which case their behaviour until they are attacked, or hear something that wakes them, is pretty self-explanatory.
This system merits several posts of its own. Firstly, and foremost – it is not designed anything like morale systems in other games, which I’ve generally found to be aggravating, and often seem rather arbitrary. In Dawn of War, for instance, I recall lone groups of soldiers sometimes fighting to their deaths and sometimes instantly losing all their morale with no apparent reasoning. While I intend to keep the specifics of the morale system hidden, it is designed to emulate as closely as possible a player’s evaluation of the battle. Which is to say – if a monster thinks it has a good chance of winning, or something happens that reinforces this view, it gains morale. If it thinks it might lose, and something that might reinforce this view occurs, it will lose morale. Monsters – especially in larger battles – are getting increasingly skilled at judging the pace of a battle they’re involved in, and deciding whether or not it’s worth fighting you to the end, or fleeing to wait another day. Again, an entry for another day, but variables as diverse as the armour you wear, the damage to a monster’s body, your combat history, the states of your allies, and even stories of past fights you’ve won that your enemies spread amongst themselves play a role.
Monsters, like players, love artifacts. If they see one – and are intelligent enough to recognise what it actually is – they are almost certain to drop anything they’re doing and make a dash for it. However, because many factions have a rigid command structure, stronger enemies will often bully/persuade weaker allies to gift artifacts to them. Disagreements can occur, and therefore battles between allies can even take place over artifacts, potentially deadly if neither party backs down…
As this forms one of the cores of the game, any feedback about logical/illogical paths in that flowchart – or other additions that seem reasonable – would be great. In the mean time:
Coming Friday: Introduction to U.R.R. items – from damage to decay, volume to weight, and material to melting point…
Coming Monday: Detail of the morale system, or: how to terrify an Orc into insanity.