The Daily Click ::. Forums ::. Klik Coding Help ::. Tower defence AI problem
 

Post Reply  Post Oekaki 
 

Posted By Message

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
4th May, 2007 at 21:14:28 -

my rshift has shit under it and i don't feel like using lshift so bear with the lack of capitalisation.

you want the towers to target the frontmost enemy. forget about the 'threat level' stuff. if a lesser threat enemy is in front of a greater one, it'll die first anyway and the turret will move onto the next dude in sequence.

give each enemy an incremental ID when they are created, and have the turret target the one with the lowest ID of those in range.

the reasoning is that unless there's a standard, logical way of allocating targets, your damage will be applied inefficiently. it makes the most sense to target the frontmost first since it'll always be the first one to come within range. this way when the frontmost enemy move out of range the next frontmost is targeted and so on, so the damage is distributed towards the front of the pack, meaning as soon as the front target dies the next target will be in a weakened state, and the turrets further down the line will move on to progressively weakened targets.

 
http://www.klikscene.com

Paul_James



Registered
  02/07/2002
Points
  1320
5th May, 2007 at 11:30:19 -

actually sketchy the manhattan is the same as the chebevey in MMF because each pixel counts as one grid square

there are no decimals and to be honest
probably the best and simplest form to find distance than pythagorean theorum


 
Its not enough,I need more
Not enough to satisify
I said I dont want it, I just need it.
To believe, to feel, to know I'm alive.

Knuckle deep beneath the borderlines.
This may hurt a little but its something you'll get used to.
Relax. Slip Away...

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1960

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
5th May, 2007 at 13:18:46 -

Not exactly sure what you mean, or where decimals come in, but Chebyshev & Manhattan are NOT the same.
Recommend you download the example;

http://www.angelfire.com/mech/banshee/Distance.cca (copy & paste to address bar)
it shows the distance between the active object and mouse cursor, as calculated by euclidean, estimated euclidean, chebyshev, and manhattan methods (in that order).

you'll see that the Chebyshev and Manhattan formulae produce very different results, with the former being consistently more accurate, and not significantly more complex.


Getting back to the original question, and having actually looked up precisely what a tower defense game is (http://www.jeannettevejarano.com/tower-defence.swf), I'd have to say that Radix is totally right (at least assuming you don't make it any more complex - different attackers having different vulnerability to different turrets etc), and for something this simple there's probably nothing wrong with using a hidden circle object to determine what's in range, as someone else suggested. Feel free to ignore everyhting I posted...

Image Edited by the Author.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click