Game Development Community

Cooking AI on Gas

by Steve Acaster · 04/02/2008 (6:46 pm) · 1 comments

After much hammering away at my AI, things have been coming along nicely.

Initially I implementing the coded Djikstra pathfinding by Robert Brower, which was a great way of learning to understand what pathfinding required.

After that I moved on to something more complex, enabling Gabriel Notman's C++ pathfinding resource (new zip available I see) for Mark Holcomb's CTF resrouce. Gabriel was nice enough to send me his scripts so I could have a good look through a working example - very useful as I'm not a programmer, but I can script a bit.

Initially I tried to mod my now built CTF resource to fit my AI routines, but in the end found it easier to start from the ground up with Gabriel's pathfinding C++ files and Mark's array C++ file, and eventually I got my custom goal-by-trigger based AI working with these resources. So that really sorted my pathfinding problems out.

Video, my AI using Gabriel's pathfinding, running around Mark's CTF map. And me changing the AI's goals dynamically with the console.

After that was sorted out, I worked on fixing my AI's combat-think, team, targeting system. I'd been using a heavily modded version of the famous Killer Kork by Devans. This had been a great script for reading through and learning how AI work. Using my hugely cutdown version I found that it could get a bit laggy with 32 AI on the go - and had a noticeable jolt ever thinktick() if I spawned all 32 in one go. I reckoned this was because each Killer Kork AI had it's own Vislist, which it updated every thinktick(), so that's 32 extra lists duplicating 31 other AI, getting updated every tick.

Going back to Mark's CTFbot resource I made a MasterArrayList which each AI joins when they spawn (and so does the player 'cos I'm only interested in SinglePlayer gaming). Every think(), working side-by-side with the pathfinding, they check for non-team members within their dynamically set %range. Finding the nearest with a decent LOS they attempt to shoot them.

Even with a LOS check for friendlies, there is the occaisonal blunder of friendly-fire, so I knocked up a bit of hacky code for projectiles to ignore damage on teammates.

After much fiddling and testing and tweaking, I'm pretty pleased with it. 32 AI running around, shooting the hell out of each other with shotguns, smgs and rifles - and no lag.

Last versions AI causing an almighty conflagration of dodgy LODed models and animations.
uk.geocities.com/eastyorksrifles/hillbillies.jpg
I tweaked my triggerable spawn system to get rid of the remain $globals in my AI script, so everything important can be changed on the fly with scripts and triggers.
dospawn(%name, %aitype, %team, %spawnPoint, %startup, %sight_range, %weapon, %goal)

That's pretty much done for my basic AI, I need to come up with an OnStuck() or dynamic avoidance of teammates function for when they occaissonally bump into each other and get jammed. And I need to come up with a OnDeath() "spawn ammunition of the type of weapon it was carrying" for the player to pickup.

After that I want to knock up a dedicated hunter AI to run down enemies for melee type attacks, and then start getting some functionality for the player sorted out.

So, I've been busy, and I've been productive. And I still managed to get time to go to an Ale Festival last week!

Steve Acaster - yorkshirerifles.blogspot.com/

#1
03/22/2009 (10:41 am)
Hmmmmm...I like your idea with the MasterArrayList for the AI