Deer pathfinding

One thing that makes pushing deer so annoying to me is the way pathfinding works for them. You push them close to a wood or building and suddenly they make a long run right to the other side of the obstacle.

I have recorded a video from a match where I encountered this issue that makes the deer behave completely illogical, and gives me as a player a clear disadvantage:

https://www.youtube.com/watch?v=PmrF_QpDMOk

From my understanding, the deer pathfinding logic probably works as follows: If a unit gets close to the deer, the algorithm looks for a free spot near the deer with a preferably high distance to the unit. Then it uses the normal pathfinding logic to find a path to this spot.

That way, the deer can also go around the unit when it is pushed into a dead end. However, this also creates these situations where the chosen spot is on the other side of the woods and the deer suddenly covers a long distance, ignoring all other units on its way that it technically should avoid, too.

I get that the pathfinding algorithm for deer must be lightweight and cannot consume too much processing power. My suggestion would be something like this: If a unit gets close to a deer, it should run a path of 3 tiles that gives it the biggest distance to the unit without getting just as close to another unit.
To achieve that, we start with the tile on the opposite side of the unit. If it is free, look for the next free tile with the same process (start with the adjacent tile with the maximum distance to the unit). If it is blocked, randomly choose the tile to the left or right of the deer instead (where the unit is behind it).

Proceed with that algorithm until we found a path of free tiles (not necessarily 3) that increases the distance to the unit at least by one tile. The pathfinding algorithm can then help making the deer move in a straight line.

Here is a little image illustrating the order in which the algorithm looks for free tiles (let’s just assume that the scout is to the upper left of the deer):

What do you think?

1 Like