[Veteran AI and gameplay programmer Mike Diskett (Syndicate Wars, Grand Theft Auto IV) explains why there's "no I in A.I.," and why there shouldn't be, in this #altdevblogaday-reprinted opinion piece.]
I've been coding AI for a long time -- nav systems, state systems, behavior trees, hybrid systems. Generally working in third-person action games, occasionally more strategy-based games.
I can tell you right now there is no I in A.I., nor should there be. You see, the Intelligence is the easy bit; it's avoiding super human intelligence that's the problem. AI programmers should really be working in A.S. -- artificial stupidity.
For me, there's nothing worse than sniping an enemy 400 meters away, and as soon as you fire the gun, every member of the enemy squad turns in unison knowing exactly where I am and returns fire with near perfect aim (even though I'm hiding behind a bush 400 meters away). I'm looking at you, Borderlands
. The enemies achieve this amazing feat in under 30 milliseconds, despite the sound of the gun firing taking at least a second to reach them from my location.
In the original Syndicate
for the Amiga, due to the lack of processing power, the AI processing had to be done across multiple game turns, with enemy agents processed every four to eight game turns. This actually made an improvement over the PC version, which had AI's reacting simultaneously and instantaneously to every player action.
In later games, events would be stored in a queue and delivered with a delay suitable for the type of event.
Another example of annoying omnipotent AI are the cops in Grand Theft Auto
. Once the cops are after you, they are all universally aware of your exact location. There's no obvious communication between them other than the instantaneous and telepathic kind. Hiding is of no use, as cops can see through walls. Your only hope is to leave the cop danger circle. At least in GTA
, they made this a clear part of the gameplay, but I always wanted to hide, to snipe one cop and have the act remain a secret. I guess really I wanted to play Thief
, lurking in shadows.
Here is a final example where enemy AIs know too much: when AIs know exactly the most efficient route to get to you. There might be a complex maze of paths between you and them, but miraculously the moment you fired the bullet from the rooftop, every enemy within 100 meters knew the exact path to get to you. Has anyone ever seen an enemy turn wrongly up a dead end, go "WTF", and run back the other way? No, because we have too much "I " and not enough "S ".
In Syndicate Wars
, we actually experimented with worst path, instead of taking the best path to the target, take the worst. I had AI's do this about half the time. This resulted in most excellent flanking maneuvers on behalf of the AI as some took the long way round to get to you and came in the back way while other agents came in the front.
At Krome for a work-in-progress shooter, I experimented with a system that maintained incomplete knowledge for each AI about possible locations for the player based of last seen location, approximate player speed, areas that can be seen, and connectivity of occluded areas from the AI's perspective. This takes a lot of CPU with a lot of raycasting but shows that if the rendering guys give us a few more CPU cycles we can achieve interesting realistic AI.
Click Image For Video
The red areas show where the AI (the T pose dark character in the distance) can't see, while the spreading green shows where the player might be, creeping away from the last known location of the player.
Notice the green cant spread to adjacent pockets of red (hidden) areas because theres no connectivity. Essentially the AI can see that the player is trapped behind the current bit of cover. Although not obvious in the video, moving AIs work as well because the info in the grid is continuously aged and updated by 50 raycasts per game turn from the current AI's location to each cell of the grid.
So, to wrap up, to help me enjoy your game more, please make your AI enemies dumber!
[This piece was reprinted from #AltDevBlogADay, a shared blog initiative started by @mike_acton devoted to giving game developers of all disciplines a place to motivate each other to write regularly about their personal game development passions.]