AI Programming strategies

Blitz3D Forums/Blitz3D Programming/AI Programming strategies

Craig H. Nisbet(Posted 2007) [#1]
Hey guys,

I've been coming up with some AI coding strategies for solving some common problems in my game design. I've been trying to think about how deal with agent attempting to malee attack another player or agent without passing through each other.

A good example would be something like World of Warcraft. If 3 bad guys spot you and start running toward you and attempt to attack you, how do you keep their meshes from passing threw each other in a logical fachion. I say logical, because I know the cheezy easy route would be to us collision spheres on them and have the collision system just push them off of each other. The only problem I see with this is that it could look sloppy . I can see a scenario where an agent is pressed up again another agent and it's legs are running in place.

I'd prefer that if it detects that it is in the space on another agent, it would find a way around the offending agent. I think if it was coded well, I think the end look would be much more natural, but I not sure what the best approach would be.

So you guys have any thoughts?


BlackJumper(Posted 2007) [#2]
How about having the collision spheres trigger a change of state where the characters switch to a priority system based on seniority...

Each character gets a priority value and faster/dumber characters move first, followed by slower characters or those with more intelligent routeing routines. You would probably need to set a threshold above which they would then resort to normal movement (to stop 'popping/oscillating' around about the edges of collision spheres)

Does this need further expansion, or is it a dead end ?


bradford6(Posted 2007) [#3]
you could use a [separation] function.

you could a include a separation radius that checks periodically to see how far away an agent is from another and adjusting if it is too close. this could be done every 3rd frame or so.

entitydistance() is one way to do it.


jfk EO-11110(Posted 2007) [#4]
AI is a big word. I guess we're talking about some kind of enemy attack player in fps game AI, do we? Players may move freely, using some kind of A-Star or so pathfinding method. If they are doing realtime calcualtion then you may simply add them to the level walls one by one, from the closest to those far away: the enemy with the lowest distance to the player will do his moves first, then he will be added to the level walls that are used to find paths. The second nearest enemy will then have to walk around the first one. The third nearest will pass by the nearest and second nearest. And so on.

Although, I'm afraid true pathfinding complicates things a lot. Personally I'd rather use a number of waypoint tracks with lots of crossing points, where the enemies may "jump" on antother track, depending on the situation.


Matty(Posted 2007) [#5]
A fairly simple way is to have a set of vectors:

Vector from AI to player (Vector 1)
Vector from AI to nearest AI friend (Vector 2)

If the vector from AI to player is shorter than AI to friend then head towards the player.
If the vector from AI to player is longer than AI to friend then check the following as well:

If the dot product of normalised Vector 1 (AI to player) and normalised Vector 2 (AI to nearest AI friend) is >'Tolerance Value' (Tolerance Value would be between say 0.7 (about 45 degrees) and 1 (0 degrees) ) then cause the AI player to head at an angle perpendicular to the angle between AI and player for a brief amount of time.

That is one way, and it can be tweaked okay. This is not about pathfinding but more about collision avoidance.