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!
warrior doesn't find correct path
- Luke100000
- Party member
- Posts: 232
- Joined: Mon Jul 22, 2013 9:17 am
- Location: Austria
- Contact:
Re: warrior doesn't find correct path
you might want to look into jumper, which is a lua implementation of the A* Search Algorithm
- Roland_Yonaba
- Inner party member
- Posts: 1563
- Joined: Tue Jun 21, 2011 6:08 pm
- Location: Ouagadougou (Burkina Faso)
- Contact:
Re: warrior doesn't find correct path
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.
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.
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.
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.MGinshe wrote:you might want to look into jumper, which is a lua implementation of the A* Search Algorithm
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.
- Luke100000
- Party member
- Posts: 232
- Joined: Mon Jul 22, 2013 9:17 am
- Location: Austria
- Contact:
Re: warrior doesn't find correct path
Thanks, an A* Search Algorithm I've searched.
Who is online
Users browsing this forum: No registered users and 0 guests