Hi.
I'm creating some roguelike but I have a little problem with monster pathfinding.
Actually, the algorithm I'm using works perfect and everything is ok.
The only problem I got is when the player is in a situation like this:
Here we have a thin corridor where the player and a Kobold are approaching, and in the other side, an Orc.
The Kobold can go straight and reach the player, but the straight path to the player is blocked for the Orc, so the pathfinding algo searches an alternative route.
This doesn't sound bad for this example since the 0rc can reach in little amount of turns the other side of the corridor, but I see here two problems:
- when the map is large and complicated the pathfinding algorithm searches a route that may require a lot of turns, which is quite dumb, and nobody will go for a long route if he can wait a couple of turns for the Kobold to die,
- If there is no alternate route, the Orc just stuck in place until the Kobold dies and the route is free.
So I want the Orc to move towards the player and just await behind the Kobold until this one dies rather than searching an alternate route if this alternate route if this route is too long, but also, use the alternate route if the distance to run is relatively short.
Any idea on how to do this?
Actually I'm using a Jump-Point pathfinding algorithm, so I'm not sure if there is some interesting tweak that it is recommended to do specifically for Roguelikes.
Also, I'm using a blockmap for the player and another for the enemies. (blockmap = array that contains the walkable tiles)
The enemies' blockmap has all walls and floors in the normal map, but also monsters here are represented by "#" too, so they are basically like walking walls, so the pathfinding is recalculated like if monsters were walls.
Thanks a lot.