A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: [help] artbased pathfinding?

  1. #1
    Senior Member
    Join Date
    Feb 2003
    Posts
    146

    [help] artbased pathfinding?

    I dug up an old project and I've been applying some of my fresh knowledge to it, but I've come to a point where I can't decide what to do.

    The way I set it up was that every time the game is started, the computer creates a new, art-based map. It's really something you'd have to see to believe. The concept of the game is naval combat near small land masses (islands).

    So, I've come to the point where I'm coding the movement of the ships. My problem is that I'm not using tiles, and the map is never the same...

    My first thought was to create a sort of magnet effect on the land masses, so that when a ship was ordered to move through one, the effect would actually rotate it and push it away so that it would be forced to go around.

    Then I got around to searching the forum and found tons of tile-based info. So, I figured maybe what I could do would be to set up a grid and search each "tile" to see if it is occupied by the land MC. Then, use A* to pathfind for the ship.

    So, what do you guys think? Do I have other options that I haven't come across, yet? Should I just dive in and try coding something?!

  2. #2
    Member
    Join Date
    Jun 2005
    Location
    dallas, tx
    Posts
    54
    i actually thought about doing something like this as well.

    the only difference being that my game boards weren't going to be dynamically created. using xml, i was going to have it load in the "background" which was really the map, then a bunch of blank "tiles" with a walkable property. a 1 for a "walkable" tile and 0 for a wall

    i'm not expert, but it seems like this would be the most efficient way to accomplish the algorithm

  3. #3
    Patron Saint of Beatings WilloughbyJackson's Avatar
    Join Date
    Nov 2000
    Location
    Ro-cha-cha-cha, New York
    Posts
    1,988
    I think Webgeek was going to play around with an artbased pathfinding thing. I'm not sure if he created anything for that...

  4. #4
    Senior Member fil_razorback's Avatar
    Join Date
    Jul 2005
    Location
    Paris, France
    Posts
    607
    Well can't you try something like that ?
    code:

    //Instructions
    If I'm not stuck into an island{
    Move to ennemy
    islanding = false
    } else {
    if (islanding == false) {
    Take a random direction to go around the island
    islanding = true
    } else {
    Continue sailing round the island
    }
    }



    Just hope the map isn't too big

  5. #5
    Senior Member webgeek's Avatar
    Join Date
    Sep 2000
    Posts
    1,352
    I think Webgeek was going to play around with an artbased pathfinding thing. I'm not sure if he created anything for that...
    Yeah, I have it working nicely but not in an "API" form that can be used for games yet. Commercial work killed my opportunity to finish it. I'm still trying to get it done though.
    Well can't you try something like that ?
    No, the algorithm you listed isn't "smart" enough for a good looking AI. If the map is primarily open, I suggest you use a simple algorithm like breadth-first or one of the tracing ones. If the map is dense, then I'd use something more sophisticated.

  6. #6
    Senior Member
    Join Date
    Feb 2003
    Posts
    146
    Alright, just so you guys can see what I'm talking about, here's the "rough-in" of the project. http://img294.imageshack.us/my.php?i...tleship3rx.swf

    You can just click "Play" through all of the setup area. Then, if you want to see the random terrain generator at work, you can just right-click, rewind, and then click through all of the setup options again and a new island will be created. You can play with the setup, too... It does some cool stuff.

    Thanks for the replies, I'm gonna go mess around and see what I can come up with.

  7. #7
    Senior Member webgeek's Avatar
    Join Date
    Sep 2000
    Posts
    1,352
    Looking at that, I would just chop the screen into a grid and then mark a grid segment as either traversible or not. Then you can easily use something like A* or Breadth-First to solve it. There are implementations of both readily available in Flash.

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