Tactical AI Kit: Stealth Pwnag3
by Bryce · 04/26/2009 (2:10 pm) · 14 comments
I've been getting a lot of emails lately asking for a Tactical AI Kit Update. As you wish, community.
The last multiplayer demo I released was very successful. I was glad to be able to interact with everyone, answer their questions, and show them how horrible I am at deathmatches. It seemed like everyone had some good suggestions about how to improve my AI system and make it more fun.
The most frequent things I heard from other players were:
"AI is too stationary, he should move more"
"AI has terrible aim"
"Maps are too linear"
"AI is jumping off buildings"
And so, I set out to fix these flaws one at a time.
AI isn't as mobile as he should be
I've completely re-written the reaction code. They now use whatever they can to track their enemies, and will move on those clues. They will use enemy sightings by their teammates, last known enemy locations, and gunfire to figure out where they should be to intercept their target.
Word-of-mouth has become more dynamic. An NPC who comes under fire will be able to alert nearby teammates of where they think the sniper is (in implementation, teammate NPCs will accquire this information when they get close enough to the reacting NPC).
While doing this, they also have a sense of self-preservation. They will move slowly and cautiously as necessary, taking cover every so often, and always watching their surroundings.
Example: A guard is standing around in the street, and a bullet impacts the ground behind him. He did not hear the shot. Since the round landed behind him, he assumes that the bullet came from somewhere down the street ahead, and takes cover behind a car. He shouts to his friends that a sniper is somewhere down the street, they take cover and word of the sniper quickly travels from guard to guard. Guards who are close to the area where the sniper is begin to carefully advance towards it, keeping their distance and sticking to enclosed, less visible spaces. The sniper is found and abruptly killed.
AI has terrible aim
The aim accuracy of any NPC can be controlled through global variables which define the minimum and maximum aim inaccuracy. This marksmanship of an NPC depends on their stress (under fire) and movement (it's hard to aim when you're running).
One thing that was desperately needed was corrected aim. NPCs aim and fire at their target every 500ms by default. This becomes a problem for moving targets. Depending on the direction, speed, and distance of the target, NPCs can't seem to hit moving targets unless they are running straight at them.
The lead aiming code from the Killer Kork AI resource by Devans has now been implemented. It's a very clever function; it will decide how far ahead of a moving target to aim for a bullet at a given speed to intercept it. No more strafing circles around stationary NPCs anymore.
Maps are too linear
I got this complaint a LOT, and I quickly began to notice it myself. The quick, hacky AI Manager I coded for the multiplayer demo would spawn AI players at a certain distance away from the human players to keep from unfairly spawning behind one. In the linear maps, especially the Palace mission, the AI Manager would end up spawning NPCs on the other side of the map. Me and another player would clear out the vehicle entrance walkways, run through the server room, up to the roof, and then declare "okay, let's go back the way we came." Then we backtrack, clear out NPCs all the way to the lobby, turn around, and repeat. This got very boring.
Tuomas Kaukoranta very gratiously let me use some building he made, and I made some of my own, and I populated a large, open town with dozens of interiors and spawn points. I'll be including this in the next multiplayer demo if I decide to release another. This map demonstrates the reaction system incredibly well, and has made the AI more fun than ever. You now get to flank, hide, snipe, and use every building to your advantage to remove the presence of AI (the embedded video below shows me clearing out six AI Players from this map as stealthily as possible, only coming under fire for less than a second).
www.youtube.com/watch?v=QCXByYGUCtc
Suicidal AI
Many people were experiencing NPCs that just couldn't handle the pressure in the Middle East map in the multiplayer demo. This is a flaw in their wander function, which didn't check for a walking surface underneath the spot they plan to move to. If they spawn up on a rooftop and notice the body of a previous combatant, the react state kicks in. More likely than not, they will run off the top of the building. The wander function has now been fixed so that they look for other navigation nodes, rather than random positions, so they will only move if there is a good path to the position.
Leave a comment, tell me what you think!
The last multiplayer demo I released was very successful. I was glad to be able to interact with everyone, answer their questions, and show them how horrible I am at deathmatches. It seemed like everyone had some good suggestions about how to improve my AI system and make it more fun.
The most frequent things I heard from other players were:
"AI is too stationary, he should move more"
"AI has terrible aim"
"Maps are too linear"
"AI is jumping off buildings"
And so, I set out to fix these flaws one at a time.
AI isn't as mobile as he should be
I've completely re-written the reaction code. They now use whatever they can to track their enemies, and will move on those clues. They will use enemy sightings by their teammates, last known enemy locations, and gunfire to figure out where they should be to intercept their target.
Word-of-mouth has become more dynamic. An NPC who comes under fire will be able to alert nearby teammates of where they think the sniper is (in implementation, teammate NPCs will accquire this information when they get close enough to the reacting NPC).
While doing this, they also have a sense of self-preservation. They will move slowly and cautiously as necessary, taking cover every so often, and always watching their surroundings.
Example: A guard is standing around in the street, and a bullet impacts the ground behind him. He did not hear the shot. Since the round landed behind him, he assumes that the bullet came from somewhere down the street ahead, and takes cover behind a car. He shouts to his friends that a sniper is somewhere down the street, they take cover and word of the sniper quickly travels from guard to guard. Guards who are close to the area where the sniper is begin to carefully advance towards it, keeping their distance and sticking to enclosed, less visible spaces. The sniper is found and abruptly killed.
AI has terrible aim
The aim accuracy of any NPC can be controlled through global variables which define the minimum and maximum aim inaccuracy. This marksmanship of an NPC depends on their stress (under fire) and movement (it's hard to aim when you're running).
One thing that was desperately needed was corrected aim. NPCs aim and fire at their target every 500ms by default. This becomes a problem for moving targets. Depending on the direction, speed, and distance of the target, NPCs can't seem to hit moving targets unless they are running straight at them.
The lead aiming code from the Killer Kork AI resource by Devans has now been implemented. It's a very clever function; it will decide how far ahead of a moving target to aim for a bullet at a given speed to intercept it. No more strafing circles around stationary NPCs anymore.
Maps are too linear
I got this complaint a LOT, and I quickly began to notice it myself. The quick, hacky AI Manager I coded for the multiplayer demo would spawn AI players at a certain distance away from the human players to keep from unfairly spawning behind one. In the linear maps, especially the Palace mission, the AI Manager would end up spawning NPCs on the other side of the map. Me and another player would clear out the vehicle entrance walkways, run through the server room, up to the roof, and then declare "okay, let's go back the way we came." Then we backtrack, clear out NPCs all the way to the lobby, turn around, and repeat. This got very boring.
Tuomas Kaukoranta very gratiously let me use some building he made, and I made some of my own, and I populated a large, open town with dozens of interiors and spawn points. I'll be including this in the next multiplayer demo if I decide to release another. This map demonstrates the reaction system incredibly well, and has made the AI more fun than ever. You now get to flank, hide, snipe, and use every building to your advantage to remove the presence of AI (the embedded video below shows me clearing out six AI Players from this map as stealthily as possible, only coming under fire for less than a second).
www.youtube.com/watch?v=QCXByYGUCtc
Suicidal AI
Many people were experiencing NPCs that just couldn't handle the pressure in the Middle East map in the multiplayer demo. This is a flaw in their wander function, which didn't check for a walking surface underneath the spot they plan to move to. If they spawn up on a rooftop and notice the body of a previous combatant, the react state kicks in. More likely than not, they will run off the top of the building. The wander function has now been fixed so that they look for other navigation nodes, rather than random positions, so they will only move if there is a good path to the position.
Leave a comment, tell me what you think!
#2
04/26/2009 (2:31 pm)
Steve, if you're any good at porting Torque Script from 1.4 to TGEA, would you be willing to beta test? From what I understand, you have an awesome system, and you'd be great for a stress test. Plus, the map you've been working on would be a cool place for some firefights :DQuote:Are you sure that they're not just too scared to fight you? ;)Dunno...one of them fired at me on his way down
#3
Come to think of it, what are your PC's specs?
04/26/2009 (3:31 pm)
I'd expect that Torque Script should work the same for all the 3D engines. Problem is TGE code (C++) files don't just slot into TGEA ... or really the problem is that I don't know C++ so I can't port them. I haven't fully ported all of my older TGE demo stuff over because of that (though I've come up with a few workarounds).Quote:From what I understand, you have an awesome systemLol no! I've a GeForce9700, pre-DX10. Not exactly state of the art.
Come to think of it, what are your PC's specs?
#4
4 Gig Memory
Vista Basic
1.8Ghz Intel Core 2 Duo
It isn't that bad (around 20-30fps usually), but when I notice the metrics bar in the corner of some of your screenshots, reading 250+, I kind of want to scream.
04/26/2009 (3:52 pm)
Dell Vostro 15104 Gig Memory
Vista Basic
1.8Ghz Intel Core 2 Duo
It isn't that bad (around 20-30fps usually), but when I notice the metrics bar in the corner of some of your screenshots, reading 250+, I kind of want to scream.
#5
Ah, you're working on a laptop, yeah my laptop takes a real hit when using TGE.
How much of your code is C++? Your pathfinding is, isn't it? I know that Mr.Notman posted recently that he was going to make a TGEA port for his resource.
04/26/2009 (4:12 pm)
My 250+ FPS is without Dynamic Range Lighting, but yeah, TGEA does give better performance than TGE (which is one of the main reasons I upgraded). In TGE I got around 90fps.Ah, you're working on a laptop, yeah my laptop takes a real hit when using TGE.
How much of your code is C++? Your pathfinding is, isn't it? I know that Mr.Notman posted recently that he was going to make a TGEA port for his resource.
#6
04/26/2009 (4:34 pm)
I am using Gabriel Notman's, which if I recall, only needs the line drawing changed for TGEA. I think he already did, it's one of the comments at the end.
#7
Also I noticed that you made a post on one of my old blogs, regarding AI teams and the Array resource. Did you end up using it for that? I currently am, but then thought if you used a seperate array for team, it would cut down on searches even less.
EDIT:
Just seen you made a post on the older pathfinding resource about random crashes whilst placing nodes using the X keybind. I found it best to put them in with the World Creator Tool like normal objects. Try saving whilst you're doing it because 1800 nodes is a lot of stuff for your laptop to be rendering!
04/26/2009 (4:51 pm)
I thought he said he "was going to" as in hasn't had chance yet. There's actually a few other changes in the TGEA directory structure, I did try and port it myself a while back minus the "line drawing" but wasn't successful and gave up.Also I noticed that you made a post on one of my old blogs, regarding AI teams and the Array resource. Did you end up using it for that? I currently am, but then thought if you used a seperate array for team, it would cut down on searches even less.
EDIT:
Just seen you made a post on the older pathfinding resource about random crashes whilst placing nodes using the X keybind. I found it best to put them in with the World Creator Tool like normal objects. Try saving whilst you're doing it because 1800 nodes is a lot of stuff for your laptop to be rendering!
#8
I implemented a PlayerArray, which tracks all players existing in the game world, living or dead (in fact, at the end of the video, I type PlayerArray.echo() to see if I killed the last NPC). That gave me a huge performance boost, thank you for the idea. The array needs to track for all teams, because NPCs are required to analyze their own teammates (to find their bodies, for example).
As for the crashes, I just deleted the path group and started over. The graph was getting insane anyway, I had nodes going into every building and loading the mission took forever.
04/26/2009 (5:04 pm)
Konrad Kiss posted a comment at the end that makes the lines work for TGEA 1.7.1. Was that all that was needed?I implemented a PlayerArray, which tracks all players existing in the game world, living or dead (in fact, at the end of the video, I type PlayerArray.echo() to see if I killed the last NPC). That gave me a huge performance boost, thank you for the idea. The array needs to track for all teams, because NPCs are required to analyze their own teammates (to find their bodies, for example).
As for the crashes, I just deleted the path group and started over. The graph was getting insane anyway, I had nodes going into every building and loading the mission took forever.
#9
04/26/2009 (5:15 pm)
There's a bit more jiggery-pokery required than just the lines code.
#10
I probably won't be home tonight to test, but I'll give it a try tomorrow when I do get home.
You are doing an awesome job with this resource. Keep it up. :-)
04/27/2009 (2:17 am)
Just a quick parusing of the code Steve linked too, it appears all you'll need to do is fix the paths to the files. (aside from the code fix for drawing lines) Things like "#include game/somefile; will need to be changed to #include T3D/somefile and the one dgl/dgl.h just needs commenting out. There isn't a replacement for it, and you dont need it.I probably won't be home tonight to test, but I'll give it a try tomorrow when I do get home.
You are doing an awesome job with this resource. Keep it up. :-)
#11
04/28/2009 (6:41 am)
Bryce, just to check about performance and your compiled exectueable. When you are compiling with Vis2005/2008/whatever_you_use, configurations are as "Release" and not "Debug"?
#12
04/28/2009 (8:10 am)
Awesome, I really can see my interiors there, they really look better after your retexturing.
#13
@Tuomas: I didn't do a lot, I just did what I could to avoid the "concrete10" texture. It's too generic for my tastes ;)
04/28/2009 (1:34 pm)
@Steve: I always use a release build. I've never really found Debug builds that useful, except for learning how portals work with the wireframe view.@Tuomas: I didn't do a lot, I just did what I could to avoid the "concrete10" texture. It's too generic for my tastes ;)
#14
05/01/2009 (11:27 am)
Looks awesome Good work! give yourself a pat on the back!
Associate Steve Acaster
[YorkshireRifles]
Are you sure that they're not just too scared to fight you? ;)
Don't worry, you've never seen me at MP. XD
There's a reason I prefer SP gaming and it's not just that I'm a camper