How to properly use Influence Maps with my AI setup

Started by
14 comments, last by sir7 3 years ago

The light blue composite force vector isn't necessarily “tangential” to anything; you can build a good one as repulsion (orange, pointing almost down)+attraction (dark blue, pointing almost up). It will be possibly short and pointing in a somewhat random direction, but if you normalize it to a “standard” acceleration magnitude it will quickly propel the entity left or right of the obstacle where the path towards the target is clear.

Omae Wa Mou Shindeiru

Advertisement

LorenzoGatti said:

The light blue composite force vector isn't necessarily “tangential” to anything; you can build a good one as repulsion (orange, pointing almost down)+attraction (dark blue, pointing almost up). It will be possibly short and pointing in a somewhat random direction, but if you normalize it to a “standard” acceleration magnitude it will quickly propel the entity left or right of the obstacle where the path towards the target is clear.

I did make two assumptions which may clarify it. 1. based on the prior video's, I assumed all the entities would be on the movement plane. 2. all vectors would be normalized. Given that, the result is the tangent away from the incoming separation force on the “to target” vector. So, they should “scoot” around the friendly, unless there are two (or more) friendlies in the way at which point it will end up trying to barge in between two of them. There should be no “randomness” based on the assumptions. I should have clarified at least the normalization though… :D

Since the quick diagram seems like it wasn't clear, try this one:

Same basic diagram with the light blue moved to the proper location to represent a “tangent" in the traditional sense. The X/Y plane is specified to assume all entities have z=0.0. Blue = “to target” vector, Orange = incoming “separation force”. So now, cross normalized “separation force” (probably negated) with normalized “to target” results in "up" {0,0,1} or “down” {0,0,-1} (skip if either incoming vectors are magnitude < epsilon of course). Cross up/down with normalized “to target”. You will have a direction result which parallel to that light blue tangent, we don't actually care if it is “on” the tangent, just that it is one of the two directions. Scale that by the magnitude of the “separation force” to make it relative and apply a scalar fiddly value to control how much relative strength it will have.

That should be a more complete explanation and why I said tangent?

If your agent can get stuck between two unmoving friendly units because it bounces between left and right of the gap between them, it's probably more productive to ensure that friendly units don't obstruct each other than to make the obstacle avoidance smarter (which would probably require the introduction of long-term planning and pathfinding).

If friendly units A and B stand between unit of interest C and its objective D, it should be quite abnormal for them to remain still and behave like an obstacle.

  • Usually A and B should also have D as a destination (they are closer than C, and presumably similar entities) and therefore they should be moving towards D, with repulsion effects limited to keeping C behind them but still mostly moving forward and following them.
  • If A and B are going elsewhere, they are unlikely to obstruct C for long: the worst case is moving directly away from D, keeping C still but only for the time it takes for A and B to pass C on opposite sides and leave C's path towards D completely clear.

It should be generally easy to detect that an agent feels “stuck,” with simple conservative heuristics like slow velocity for N consecutive timesteps, and decide to replan its movement (e.g. move to the nearest eligible objective rather than their original one; in the example A and B would probably switch to going to D, aligning with C).

Omae Wa Mou Shindeiru

@LorenzoGatti Yep, I am now thoroughly looking at starcraft 2 steering implementation. I am missing some key behaviours like planning and arriving.

This topic is closed to new replies.

Advertisement