I am making a Goat/Butcher game (top-down, 2d grid based). The goat has to avoid the butcher or he will pay the ultimate price. The goat is confined in an area which would look something like this:
How would i go about moving the goat away from the butcher, in the most logical order, so when it is cornered, it will move like so:
Are there any pathfinding algorithms that will retrieve a most optimal destination for the goat?
Notes:
I do not have access to the butcher's properties, like velocity, speed or similar. I can however query for its current (x/y)position, orientation and distance to our goat.
The goat is able to go faster than the butcher.
Diagonal movement is allowed.
Inside the grid are no obstacles.
I will be writing this in java.
Depends on how you want to get away. A greedy algorithm would be good at getting away, if each move the Goat can make has a weight associated with it such that moves that get you further away are worth more (this could be calculated based on the x,y of the Butcher and the x,y of each position). From this you could find the path with the greatest short term benefit. You may want to limit the depth of the search to fit your needs.
If you wanted to find the shortest path to the point furthest away dijkstra's algorithm would be better but you would have to find a way to make sure the goat does not go closer to the Butcher on the way to that point.
Considering the problem a greedy algorithm is likely the better choice since short term avoidance is probably more important in your problem.