One of the heuristics I implemented in my A, was to link information from the AI back to the routing grid. For example A will always pick the shortest route, however this isn't the best route. Imagine you have the AI pinned down in a building and the route finder picks a route out of the building, well it's likely to pick the shortest route (out the front door). So all the player has to do is put the cross hair over the door and keep shooting.
Now sure you could write some code to 'fix' this issue. Or you could let the problem fix itself. If when an AI pawn is killed at a certain point, I added a penalty to the surrounding nodes. This made the route more and more expensive over time, after a short while the AI decided to use the back door and walk around the building.
The important part of this is the player perception. To the player it looks like the AI is flanking the player, and they're like 'woooo cooool', which is the effect you're after.
That sounds like a weighted graph, with different factors contributing to the weighting. Kills, terrain type, etc. can all play into that to account for each unit type's strenths and weaknesses plus historical factors such as number of kills. If you want to get clever, you could implement kill weighting while taking into account whether or not information about those kills has been communicated through direct observation, message relaying, sound, and so on. If you get really clever, you could end up with enemies who remove evidence of their kills to maintain the element of surprise, who hunt down last survivors to prevent the information from being communicated, and other emergent behavior.
- increase the cost of traversing nodes that are within known enemy firing zones
- in some circumstances if the destination is unreachable it might be desirable to still compute a "best effort" path to the node that is the minimal heuristic distance from the unreachable destination
- in some circumstances if the destination is unreachable it might be desirable to still compute a "best effort" path to the node that is the minimal heuristic distance from the unreachable destination
This is actually very important, especially in RTS games! If you have a unit selected, and he's standing near the edge of a cliff, and you right-click off the edge (intersecting lower-elevation terrian), then the naive Astar algo would make the unit run away from your mouse cursor, because it would search the whole map for a valid way to get there --- however the player very likely wanted to get as close as possible to the edge, e.g. to attack an enemy he spotted.
(In other words, when pathing to different elevations, the the player almost always wants the unit to "run up as close as possible" to the edge, not try to find a valid path all the way around the map.)
It's actually a very tough/interesting problem, because it's probably impossible to "always do what the user intends in every situation" by merely looking at his mouseclicks.
Now sure you could write some code to 'fix' this issue. Or you could let the problem fix itself. If when an AI pawn is killed at a certain point, I added a penalty to the surrounding nodes. This made the route more and more expensive over time, after a short while the AI decided to use the back door and walk around the building.
The important part of this is the player perception. To the player it looks like the AI is flanking the player, and they're like 'woooo cooool', which is the effect you're after.