Results 1 to 6 of 6
  1. #1
    zFollette is offline ▼ dafuq did I do?
    Join Date
    Dec 2013
    Posts
    203
    Rep Power
    0

    Default AI Path Finding.

    So I have an idea for path finding, I just don't know where to start to turn it into code. Say you have point A and point B, all of the tiles in the map would have assigned numbers. The numbers represent the distance from point A to point B. Here is a graphical representation of what I want to complete.

    AI Path Finding.-grid.png

    As you can see, starting from point A, 7 is the smallest number out of the surrounding tiles, I would move to a tile with the number 7. I would then re-evaluate the grid, 6 would become the next smallest number, and so on. As you can see in my picture, the highlighted paths are both the smallest possible paths from point A to point B, assuming I can only move in a linear motion. It does not matter which path I choose because they are equal. So, where would I even start with this implementation? (-1 is a barrier and will not be considered in the path finding)

  2. #2
    pj6444 is offline Senior Member
    Join Date
    Jan 2013
    Posts
    164
    Rep Power
    2

    Default Re: AI Path Finding.

    I think you might be better off going to the Java Gaming Forums to do this. They might know some methods to use for path finding.
    Java-Gaming.org - home of the largest java game developer community

  3. #3
    liluma's Avatar
    liluma is offline Member
    Join Date
    May 2011
    Location
    belgium
    Posts
    50
    Rep Power
    0

    Default Re: AI Path Finding.

    depending on what is your priority you could give following algoritms a look:

    breadth first algorithm ==> Breadth-first search - Wikipedia, the free encyclopedia (this will find a solution if there is a solution, but not necessarily the best (shortest, least pathcost) route)
    depth first algorithm ==> Depth-first search - Wikipedia, the free encyclopedia (this will find a solution if there is a solution, but not necessarily the best (shortest, least pathcost) route)
    or the a* algorithm (which i would suggest since this is prob the most efficient) ==> A* search algorithm - Wikipedia, the free encyclopedia

    and bassicly, you are gonna make a tree or graph from you grid, and traverse that tree or graph with the chosen algoritm.

    hope this helps a bit. ;)

    grtz liluma
    Last edited by liluma; 01-15-2014 at 07:37 AM.

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,524
    Blog Entries
    7
    Rep Power
    20

    Default Re: AI Path Finding.

    A simple Dijkstra labeling algorithm can do the job (it'll find an optimal solution).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    zFollette is offline ▼ dafuq did I do?
    Join Date
    Dec 2013
    Posts
    203
    Rep Power
    0

    Default Re: AI Path Finding.

    I have decided I am going to implement the A* path finding algorithm.

  6. #6
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,014
    Rep Power
    6

    Default Re: AI Path Finding.

    Good choice, IMO. Its a nice challenge for the brain too.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Finding program path
    By sathya11491 in forum New To Java
    Replies: 3
    Last Post: 03-21-2012, 12:40 PM
  2. Replies: 1
    Last Post: 11-14-2011, 04:39 PM
  3. Finding path to my command line tools from Java
    By paulanon in forum New To Java
    Replies: 1
    Last Post: 04-07-2011, 02:34 AM
  4. setting class-path & Library Path in ubantu
    By programmer_007 in forum Eclipse
    Replies: 18
    Last Post: 02-22-2010, 12:31 PM

Posting Permissions

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