A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: A* in a real time strategy game

  1. #1
    self-portrait Kianis's Avatar
    Join Date
    Feb 2004
    Location
    Stockholm, Sweden
    Posts
    425

    A* in a real time strategy game

    I got inspired by the topic about remaking Dune so I started this project. It's just for fun though, I doubt flash can handle the pathfinding, scrolling, AI, etc..

    There's no scrolling so far, just the pathfinder. Works pretty okay for now, with a tiny map and fog of war but no other units.

    asd

    I'm not sure the A* works properly though. It doesn't seem as it always selects the shortest path. :/

    Edit: new version. Fixed heuristic. No more bugs. Terrain costs works but isn't balanced so the unit often walks over them anyway.
    Last edited by Kianis; 12-11-2004 at 04:37 PM.

  2. #2
    Member
    Join Date
    Nov 2004
    Posts
    51
    Nice work, it looks pretty fast. Did you write your own A*?
    BTW, you should use something else like robust tracing (no idea how it works but looks fast) or even precalculated paths. A* is just too slow, no matter how efficient and optimized.. Then if you limit the size of the map and the number of units you could probably pull it off.

  3. #3
    SaphuA SaphuA's Avatar
    Join Date
    Oct 2002
    Location
    The Netherlands
    Posts
    2,180
    Hey,
    Is that your own A*-engine? Very nice It seems fast enough..
    Although it's pretty buggy, like you say, it doesn't always take the shortest path. It seems like it's also not seeing the different type of terrains (the swamp tiles). Also sometimes it's not reacting or just giving a 'no path' when I click somewhere.

    Still nice though

    SaphuA

  4. #4
    self-portrait Kianis's Avatar
    Join Date
    Feb 2004
    Location
    Stockholm, Sweden
    Posts
    425
    Thanks,
    yes I wrote it after this excellent link.

    Seems as if there are quite a few bugs left. :/

    I was thinking of limiting the length of the paths to about one screensize and of course there would only be one unit searching for a path at the same time (I've already got a que), but I'll have a look at robust tracing

    Edit: After reading a bit about robust tracing I think it might be the better alternative. Terrain costs isn't that important - at least not as important as speed. There's a lot of talking about Klas Kroon's robust tracing. I found a .swf at his site but no .fla?
    Last edited by Kianis; 12-11-2004 at 12:03 PM.

  5. #5
    Tetris Downstacker Hasufel's Avatar
    Join Date
    Feb 2004
    Location
    Near by
    Posts
    247
    Funny thing, sometimes the character goes, then goes backwards, as if the a* was recalculated.
    You didnt include costs it seems ?
    The char goes on "slow" tiles as if it liked them

    Also, you should accept a click while the char is moving,
    its a shame one has to wait until the char is done moving to tell it a new destination.

    I tried one A* version some time ago, you can find it here:
    http://www.ventoline.com/basis2.html

    Keep it up.
    Bubble Islands - Your arcade puzzle game !
    Dot-invasion Team
    Tales from the code front: stimunation developers blog
    Puzzle Bobble - The arcade port!
    2iceMP framework - Flash Multiuser Server: multiplayer tetris, chess, othello, connect4 ...
    Frozen Bubble - shoot da bubbles!
    The Pi Game - game for geeks

  6. #6
    self-portrait Kianis's Avatar
    Join Date
    Feb 2004
    Location
    Stockholm, Sweden
    Posts
    425
    Yep, sorry for not being clear; when I said it didn't take the shortest path I meant on explored terrain. Unexplored terrain is treated as walkable until proven otherwise and it will have to recalculate.

    Edit:
    > The char goes on "slow" tiles as if it liked them

    Haha You're right. Must have done something wrong.. :S
    Last edited by Kianis; 12-11-2004 at 12:24 PM.

  7. #7
    self-portrait Kianis's Avatar
    Join Date
    Feb 2004
    Location
    Stockholm, Sweden
    Posts
    425
    Updated :P
    link

    The pathfinder seems to work well even with several units. I think I'll stick with A* since terrain cost is quite imortant after all.

    I'll add the tilescrollingengine in a few days.. : )

  8. #8
    Senior Member UnknownGuy's Avatar
    Join Date
    Jul 2003
    Location
    Canada
    Posts
    1,361
    If it matters, in games like Warcraft I believe the units already "know" the map, predicting there path without surprise rivers etc....
    Hope that helps!

  9. #9
    self-portrait Kianis's Avatar
    Join Date
    Feb 2004
    Location
    Stockholm, Sweden
    Posts
    425
    Originally posted by tonypa
    It doesnt work correctly when several units try to walk into same spot same time. They will block each others paths and I lost 2 units because they walked off the map.
    Fixed : )

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center