Page 2 of 9 FirstFirst 1234 ... LastLast
Results 11 to 20 of 90

Thread: A* pathfinding example !

  1. #11
    Legendary Member cairnswm's Avatar
    Join Date
    Nov 2002
    Location
    Randburg, South Africa
    Posts
    1,537

    A* pathfinding example !

    My standard license: Free for any use
    William Cairns
    My Games: http://www.cairnsgames.co.za (Currently very inactive)
    MyOnline Games: http://TheGameDeveloper.co.za (Currently very inactive)

  2. #12

    A* pathfinding example !

    nice, thanks, ill probably make some modifications and post them here

    EDIT: as promised:



    https://github.com/JernejL/astar

    added:
    colored cubes, actual path finding that finds the shortest path between the nodes, and some fun stuff

    EDIT:

    I modified some of the algorythm internals now, for start - i replaced the sorted Tlistbox with a dynamic array instead, and instead of sorting the array i just find the lowest item in the array - which is MUCH faster than sorting the whole list for every added item no matter which sorting algorythm you use, the deletion of item from array is also optimized with using memory MOVE routine.

    and i added a cleanup menu button to clear the path searching results.

    i also commented most of the new code i added so it should be easy to understand.
    Last edited by JernejL; 21-05-2018 at 07:04 AM.
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  3. #13

    A* pathfinding example !

    Nice one Delpfi

    Thanks for posting
    The views expressed on this programme are bloody good ones. - Fred Dagg

  4. #14
    Legendary Member cairnswm's Avatar
    Join Date
    Nov 2002
    Location
    Randburg, South Africa
    Posts
    1,537

    A* pathfinding example !

    Some more things that can be added

    1. Find a way to make it a class that can easily be included in any game using squares. I have sort of done this in my Run-A-War game but every time I want to reuse the Pathfinding I am finding I need to make modifications.

    2. Make weighted cells - so be able to add a river that costs three movement points to cross, or mountains, forests etc.

    3. Optimise optimise optimise

    Glad to see someone found the tutorial useful anyway
    William Cairns
    My Games: http://www.cairnsgames.co.za (Currently very inactive)
    MyOnline Games: http://TheGameDeveloper.co.za (Currently very inactive)

  5. #15

    A* pathfinding example !

    I thought of making it a library with some simple callbacks, so you would call it and it would call your callback parameter of your routine that would just call you back for every cube that it wants to search and you would tell it if it is passable and A* weight... this would be very simple to use.
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  6. #16

    A* pathfinding example !

    Make sure that it is flexiable in its walking and passing schema. For example don't limit it to X, Y int coords. X, Y, Z Singles would be much better, with a step size passed back for each direction. That way if you have a "Warp" from one loc to another you can let the engine know about it.

  7. #17

    A* pathfinding example !

    Added: fallback case: finds closest point to the goal if there is no direct path!



    Ok, i separated the path finding from the form unit, it works like i described - using callbacks, here is the new download:

    http://www.gtatools.com/temp/astar1.rar

    If you need older one for any reasons it is here:
    http://www.gtatools.com/temp/astar1_old.rar

    EDIT:

    jdarling:

    this is now all possible what you described, the map area field is dynamic, and you can also specify it to wrap worlds (it cannot go to negative coords, you need to enlarge the field you give to pathfinder and compensate for it in the callback routines)

    im not sure if you could make warp areas, it could be done, just give the cube at the warp entrance much bigger priority if the warp exit is closer..
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  8. #18

    A* pathfinding example !

    How hard will it be to add ‘ground priorities’, meaning:
    road penalty = 0.
    dirt path penalty = 1.
    Up hill penalty = 5
    And so on.
    [size=9px]BEGIN GEEK CODE BLOCK
    <br />d s-- : a24 GB GCS GTW GE C++ P L+ W++ N+ K- w++++ M- PS+ PE+ Y- t+ 5+++ X+ R*
    <br />tv b+ DI++ D+ e++ h+ G-
    <br />END GEEK CODE BLOCK[/size]
    <br />Create your own GeekCode block at: <a href="">...</a>

  9. #19

    A* pathfinding example !

    Quote Originally Posted by tanffn
    How hard will it be to add ‘ground priorities’, meaning:
    road penalty = 0.
    dirt path penalty = 1.
    Up hill penalty = 5
    And so on.
    very easy.. just tell the pathfinder block cost in the callback.
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  10. #20

    A* pathfinding example !

    Now this is embarrasing, i forgot to include actual astar.pas into the rar file, i added it now ops:
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

Page 2 of 9 FirstFirst 1234 ... LastLast

Bookmarks

Posting Permissions

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