Mindfields – AI for crowds

Gameplay and Story Segregation really gets on my nerves. Especially with RPGs. Story takes place in a city with thousands of souls, yet all you get are three levels with 30 characters at most. Those are due to technical limitations – usual AI just can’t handle too many agents, so in RPG battles will have handful of combatants on each side, at most.

I don’t want that in “In Dead Company”. You can raise a small army, and I want you to see this army. So I need to innovate.

Good AI is expensive. Each character needs to judge options it has, pick best one, think a few steps into future. You can cheat a bit with heuristics (predefined behaviors), but this becomes obvious, as your AI is not adapting. So I pulled out my master thesis and applied ant colony optimization to my AI.

And it works quite well. Current iteration can handle about 500 characters on map. I usually run smaller batches to better observe what is happening. Mind you, those are just arrows on mocked map right now, but I can see they take correct paths, they judge risks and rewards. All great for RPG elements.

There are downsides – I don’t program behaviour, I program needs and desires, and behaviour emerges on it’s own. So it’s not really obvious what given change will do. And without fine-tuning, characters don’t behave as people. And it is OK for undead, but I need this AI to handle living.

So I tune and tune. It’s fun to watch and fun to tune, and in the end should provide AI robust enough to adapt to any action that player will make, and hopefully your own company won’t get in your way. And this AI will handle both combat and out-of-combat behaviour. There is really little difference, code wise, between need to defend yourself from attacker and need to buy food on the market. And this should make transition to and out of combat seamless, just like RPG should have.

 

Leave a Reply