0

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?

Brandon
  • 779
  • 5
  • 9
  • 28

1 Answers1

2

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.

Russell Zahniser
  • 16,188
  • 39
  • 30
  • I don't know why I didn't think of that. Thanks! Do you know of any good examples of A* for AndEngine? – Brandon Apr 24 '12 at 17:05
  • @Brandon Hi I am currently struggling with the same issue did you find any good example for A*? – Renier May 17 '14 at 15:47
  • This was a while ago that I wrote the game. IIRC, I made my own function that examined all possible paths and randomly chose between the ones that ended at an endpoint. I can dig up the code if you'd like to see it. – Brandon Aug 28 '14 at 17:56