Something I've wanted to write about for a while is how the enemy units in Isomer respond to the player. This is an area of Isomer that has taken much more time than I had originally anticipated to build, largely because the way in which characters interact and respond to the world and each other is such an important part of the game....
Posted by Ionising on Apr 26th, 2013
Something I've wanted to write about for a while is how the enemy units in Isomer respond to the player. This is an area of Isomer that has taken much more time than I had originally anticipated to build, largely because the way in which characters interact and respond to the world and each other is such an important part of the game.
I love AI and simulating realistic and challenging behavior in games. Specifically I love watching relatively simple systems come alive after having been fed only a small number of behavioral directives. It's not practical (and probably not possible) to pre-script behavior for every possible event or combinations of events for games with complex worlds and yet, with a few simple instructions it's possible to create dynamic and reactive behavior.
When I started working on Isomer I planned on making the AI separate from all the units, turning it into an objective based system which would come up with tasks in response to player actions, find the closest units it could control and then dispatch them. In a way maybe I subconsciously was planning to recreate a virtual player as the AI, not having written AI code before perhaps this was a logical starting point. However somewhere in the development process I shifted focus to entity based AI, where each unit could sense their surroundings and make their own decisions based on their core directives. These directives currently (I've got more planned) include seeking out player structures and destroying power cores, seeking out player troops, patrolling the world, grouping together into squads and healing friendly units. From this fairly limited set, already interesting and challenging behavior emerges.
Naturally not every unit has the same level of AI control in Isomer, each unit falls into two categories - those that are controlled by the player and those that are fully controlled by the game.
Units that are fully controlled by the game are fully modeled as individual entities with, as I mentioned before, their own abilities to sense the world around them, make decisions and assign their own objectives. With a the relatively small number of core directives, each entity will move around the world organically, seeking out targets and reacting to any unexpected or new situations along the way. The weight an entity places on each directive varies depending on the type of unit they are and the situation they're in, for example: enemy engineers will look at how much health each friendly unit they come across has and walk over to heal them if required whereas heavy combat units focus primarily on looking for enemy units to kill to the exclusion of all else.
Notice before I said 'fully' controlled by the game before when talking about enemy units? The reason for this is even player controlled units have AI constantly running, although rather than be a fully fledged decision making system, the purpose of it is to react automatically when needed as well as to execute player commands. Take for example if an enemy unit walks into view, it would be pretty annoying if the player had to tell each unit they control individually 'hey, there's a guy over there - shoot him damnit!', so consequently the reactive AI automatically targets and starts engaging the enemy entity if the player unit has no existing command in their queue like moving or building (and they are within perception range and line of sight etc etc). Similarly, if the unit is shooting at an entity that runs away or ducks around a corner, the player controlled unit has enough intelligence to turn and keep engaging the enemy unit if they can get a shot. But it doesn't end there, when a player issues a mine or build order, all that's passed to the unit is what the instruction is and where to do it. It's down to the unit to decide how to get there and how to do it.
That's a basic round up of how the AI works currently in Isomer. I still am planning to add the overall AI processing I mentioned earlier, but in a reduced capacity. Having a game that on an individual unit level behaves dynamically to the player is great, but I think it could only enhance things if periodically objectives are set across the whole world map involving more structured commands. This is something I'm going I have to experiment with in the future.