Search code examples
andenginea-starheuristics

Can A* Pathing in AndEngine allow a sprite to determine "incorrect" paths and make "random" choices?


I am currently developing a Tower Defense game for the Android platform using the AndEngine. My enemies (animated sprite extended class) have hard coded pathing. I'd like to switch to something better where the enemies can determine for themselves where to go. I am using TMX maps. Please refer to the following map:

The 2 hexagonal tiles are spawn locations for the enemies. I have 2 questions abou A* Pathing.

At point A is it possible to make sure the enemy doesn't turn down the path towards the other spawn location?

From what I've been told A* Pathing looks for shortest distance, so is there a way to have the enemy randomly select which way to go at point B?

If A* Pathing is sufficient for these test cases, can you supply me a link to a tutorial/example? I haven't found much help through Google.

If A* Pathing can't do this, what are my other options?


Solution

  • In order to use A*, you need to know where the enemy is trying to get to. If you randomize the target locations of the enemies between the two exit points at the right, they should work correctly.