Page 1 of 1

warrior doesn't find correct path

Posted: Fri Apr 18, 2014 6:55 pm
by Luke100000
Simple example of my problem:
X | O
Warrior (X) wants to run to his target (O), but there is a wall in his way (|)
How I can make that the guy finds automatical his way to O, not only with 1 wall.

X|||||||||||||
......|||O ...||
|...||||.....||
|.............||
|||||||||||||

... == floor, " " doesn't work

My idea was something like WarCraft, the warriors run to the target and took the shortest way.

It have to work fast, because of 100 or more warriors.

Thanks! :awesome:

Re: warrior doesn't find correct path

Posted: Sat Apr 19, 2014 7:09 am
by MGinshe
you might want to look into jumper, which is a lua implementation of the A* Search Algorithm

Re: warrior doesn't find correct path

Posted: Sun Apr 20, 2014 10:47 pm
by Roland_Yonaba
Technically, what you need is a pathfinding algorithm. And pathfinding is a very interesting and wide topic, and there are loads of algorithms.
Typically, Astar is a good compromise. It is widely used in games and has a dozen of variants.
Depending on your world representation (which seems to be a flat grid, in your case), its size, its dynamicity and the type of path requests
you are willing to perform (single source, all pairs shortests paths, etc) some algorithms are better than others.
MGinshe wrote:you might want to look into jumper, which is a lua implementation of the A* Search Algorithm
Jumper is not just a Astar pathfinding library, it is a bit more than that. It offers a high level API to run different pathfinding algorithms. You just pick the one you want (between Astar, Dijkstra, Jump Point Search, Breadth-First Search, Deoth First Search) and use it. You can compare them easily and decide what one suits the best your needs.

Otherwise, you can also take a look at some other implementations, or try to implement Astar for yourself. It is really learningful, and as a game developer it will help to know it. The best tutorial, AFAIK, is the Great Patrick Lester's, and the best set of resources can be found on the Great Amit Patel's website.

Re: warrior doesn't find correct path

Posted: Tue Apr 22, 2014 8:16 am
by Luke100000
Thanks, an A* Search Algorithm I've searched.