Play Now Login Create Account
illyriad
  New Posts New Posts RSS Feed - Pathfinding - how hard is it?
  FAQ FAQ  Forum Search   Register Register  Login Login

Topic ClosedPathfinding - how hard is it?

 Post Reply Post Reply Page  <12345>
Author
 Rating: Topic Rating: 1 Votes, Average 5.00  Topic Search Topic Search  Topic Options Topic Options
Ander View Drop Down
Postmaster General
Postmaster General
Avatar

Joined: 24 Apr 2011
Status: Offline
Points: 1269
Direct Link To This Post Posted: 25 Jan 2012 at 19:10
(2n!)/((n!)(n!))

500 cows to google and 500 to wikipedia Tongue
Back to Top
Createure View Drop Down
Postmaster General
Postmaster General
Avatar

Joined: 07 Apr 2010
Location: uk
Status: Offline
Points: 1191
Direct Link To This Post Posted: 25 Jan 2012 at 18:39
Also I just realised I was correct in the "very large" part of the number example but incorrect in saying it was a factorial thing - it does seem to be an exponential of some for looking at the straight line on a log-linear plot of the first few terms.

If anyone wants to prove they are more switched on/than me today give me a mathematical description for the sequence that starts: 1, 2, 6, 20, 70, 252, 926

And I will give you 1,000 cows if you can do it - math teim. Thumbs Up

p.s. the answer for n=100 is:
267823007376670171763904352500539254130289039388032841724230
Back to Top
GM ThunderCat View Drop Down
Moderator Group
Moderator Group
Avatar
GM

Joined: 11 Dec 2009
Location: Everywhere
Status: Offline
Points: 2157
Direct Link To This Post Posted: 25 Jan 2012 at 18:34
The phrase "capacitated vehicle routing problem with time windows" - brings back such lovely memories...
Back to Top
GM Stormcrow View Drop Down
Moderator Group
Moderator Group
Avatar
GM

Joined: 23 Feb 2010
Location: Illyria
Status: Offline
Points: 3820
Direct Link To This Post Posted: 25 Jan 2012 at 17:43
Nesse - Yes, as Createure has essentially pointed out, "algorithmically easy" does not equal "CPU cycle feasible".

We're reasonably confident we have this in hand, though, as well as pre-experience of much, much more complex real-world implementations (considering square-to-square movement cost in 8 directions is much, much simpler than planning multi-dimensional pathfinding, such as walking door-to-door across a tower-block housing estate).

SC
Back to Top
Createure View Drop Down
Postmaster General
Postmaster General
Avatar

Joined: 07 Apr 2010
Location: uk
Status: Offline
Points: 1191
Direct Link To This Post Posted: 25 Jan 2012 at 16:11
Yes Nesse pathfinding is very simple in the case you describe where you are finding best path from 1 square to an adjacent square.

What you are not considering is that in order to find the best route between two points 500 squares apart you do not just consider each movement 1 square at a time, so it is not just an 'additive' problem in terms of processing time required.

If you take a very simple example with all squares having equal weight - [mountains are same speed as water and plains and forests] - and say that in order to get from point at square [0,0] to square [100,100] you will at minimum need to make 200 steps assuming you can only move directly north or east. If you think about it, there is 100! [aka 100*99*98*97*96*...*3*2*1] different ways of getting from [0,0] to [100,100] in this very simple manner... if you try and work out what number that is you will get MATH ERROR - i.e a very very very big number.

Now consider what path-finding is actually about - it is finding the best (definition of 'best' may change) route between two or more states (locations or whatever). But basically what i'm saying is that in order to find a route you best matches certain criteria, you need to consider ALL the routes. This means that you now have to ask your processor to consider 100! routes in order to find the particular one (or ones) that best match your criteria.

As you can see my simple example is rather simple, real movement in Illy path-finding would certainly be considerably more complex than just moving north/south or east/west on uniform topography - for example it could involve moving away from your destination to begin with in order to get to a road or to circumvent a mountain range or ocean - conditions like this basically mean you have to loosen the restrictions that you place on the range of paths that your system needs to consider in order to pick one... so your 100! number is going to rise dramatically.

What we've all been discussing above is various ways to reduce this 100! number by putting conditions on how many different paths you need to consider. (or the frequency with which you need to consider them) One solution here - as I pointed out in the opening post - is to break the journey down into smaller blocks, like they suggested in that link. For example if you are travelling to 100,100 from 0,0 but you say that you have to pass through 25,25 on the way then you will find the number of possible paths reduces from 100! to 50! + 50! which you will find does fit into the memory of a standard calculator - around 6.1*10^64 different paths. The clever thing here is how you chose to split your journey up.

Obviously breaking the world map up in to equal dimensioned blocks is pretty clumsy but does the job, this is what the 8Realms guys basically did in that article I linked. Various suggestions for breaking journeys in Illy up have already been given by players and devs above and I guess the answer will largely lie in a huge amorphous mutant mess of all of them - but largely starting with the existing topography in Illy - as SC has already pretty much confirmed, when the devs designed the world map they designed it so that various locations would be nicely split up by natural boundries so that complexity of paths for consideration would be reduced.

edit:

100 ! = 9.33262154 × 10157

Thanks Google... it has more memories than my pocket calculator.



Edited by Createure - 25 Jan 2012 at 16:32
Back to Top
Nesse View Drop Down
Forum Warrior
Forum Warrior
Avatar

Joined: 03 Oct 2010
Location: England
Status: Offline
Points: 406
Direct Link To This Post Posted: 25 Jan 2012 at 15:21
Being a scientist by trade, the post by SC about pathfinding makes me a bit worried about the complexity that seems to be considered necessary for intruducing terrain effects into the game, e.g.:

Originally posted by GM Stormcrow GM Stormcrow wrote:

...
Pathfinding algorithms themselves, whether they be A* or variants like Dijkstra, Manhattan or whatever - well, programmatically... these are actually quite simple.  More complex (but implementable) are concepts such as nodal or neural-network pathing via functions such as MapReduce.  There are similarities and parallels between distributed computing algorithms and gameplay pathfinding, strange as it may seem.
...


How about starting with straight line movement along the eight directions S, N, E, W, NE, SW, NW and SE? Add movement costs as speed reductions, e.g. 50% for large mountains and forests, less reduction for the small variants and hills, and an equivalent of adding two squares extra cost to start moving across water. Then pick the closest combination of two of the eight directions and make straight line movement in first one, then the other direction (pick the one of the two choices that is fastest). Since you would be moving through squares straight or diagonally, calculating the speed and travel times would be quite easy.

Just as a teaser for more advanced things to come, and to get payers used to moving at terrain costs. As a research option, adding waypoints to the travel path would be neat, one additional point at the time at increasingly expensive and time consuming research options. Then you could later introduce "Thundercats second pathfinding algorithm" as a research option. Possibly later made obsolete by the introduction of "Thundercats third pathfinding algorithm, necessitating renewed research efforts.



Edited by Nesse - 26 Jan 2012 at 11:17
Back to Top
Bonaparta View Drop Down
Postmaster
Postmaster
Avatar

Joined: 03 Nov 2011
Location: Milky Way
Status: Offline
Points: 541
Direct Link To This Post Posted: 20 Jan 2012 at 02:05
As we are mere ants in this vast Illyria multiverse perhaps ant colony optimization algorithms may be useful.
Back to Top
GM Luna View Drop Down
New Poster
New Poster
Avatar
Community Manager

Joined: 22 Oct 2011
Location: Illyriad
Status: Offline
Points: 2042
Direct Link To This Post Posted: 20 Jan 2012 at 01:16
Originally posted by Kumomoto Kumomoto wrote:

Originally posted by GM Stormcrow GM Stormcrow wrote:

Our shared commercial background is broadly with extracting the dataset marrow from the value-bones of gargantuan problem-dinosaurs, and then extracting the algorithmic DNA to build even more deadly-efficient gaming veloci-raptors.


This sentence has to go down in the annals of Illy history as SC at his SCyest... ;)



Also my new favorite sentence ever. 

Luna
GM Luna | Illyriad Community Manager | community@illyriad.co.uk

Back to Top
Createure View Drop Down
Postmaster General
Postmaster General
Avatar

Joined: 07 Apr 2010
Location: uk
Status: Offline
Points: 1191
Direct Link To This Post Posted: 20 Jan 2012 at 01:08
Originally posted by GM Stormcrow GM Stormcrow wrote:

So here goes!

He takes the bait - hook, line and sinker. ^^

Originally posted by GM Stormcrow GM Stormcrow wrote:

What amuses me the most is that of all the people who have ever worked on the intractible "travelling salesman" problem, TC is probably one of the few who has worked sucessfully on, quite literally, that precise problem Big smile

TC is dot-to-dot pro? Clap


I'm intrigued to learn more about this "Cloud" thing getting mentioned - as far as i'm aware it could be a real cloud that floats above elgea to keep it cool and shady so it can calculate x% more alternative paths per second.

Edited by Createure - 20 Jan 2012 at 01:09
Back to Top
GM Stormcrow View Drop Down
Moderator Group
Moderator Group
Avatar
GM

Joined: 23 Feb 2010
Location: Illyria
Status: Offline
Points: 3820
Direct Link To This Post Posted: 20 Jan 2012 at 00:26
What amuses me the most is that of all the people who have ever worked on the intractible "travelling salesman" problem, TC is probably one of the few who has worked sucessfully on, quite literally, that precise problem Big smile
Back to Top
 Post Reply Post Reply Page  <12345>
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.03
Copyright ©2001-2019 Web Wiz Ltd.