After hours of work and many many mistakes, I've finally conquered the Dijkstra algorithm.
About six hours ago I decided to tackle the route distances. I began by porting some of the Eve map databases over to my production database, and then worked on creating a Graph. That probably took up to two hours. The real bitch was working with the Dijkstra code lying on the internets.
Most references want me to use PriorityDictionaries so I spent an hour or so trying to figure them out. I had a ton of python editors full of gibberish. In the end I resorted to the wikipedia Dijkstra site (http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm). They have a pseudo-code logical outline for a solution.
My version would run through once, find the starting location (as it should) and then die (as it shouldn't). I thought maybe I can't alter a variable that is running a while statement I'm in, so far too much time was wasted tyring to solve that. The real problem was a variable that wasn't being redefined. Pretty much after it found the starting point (distance = 0) it would then look for something closer, and since there isn't it would die.
A quick "cut and paste" later and the shell started spewing out distances. I only checked one (Jita to Sizamod) against the Battle Clinic site (http://www.battleclinic.com/eve_online/route_finder.php) but it came up accurate (15 jumps in Hi-Sec). So I count that as a win!!
With Dijkstra written I need to define a distance table. This will have a column for each solar system and a row for each solar system. Should be about 12.5M entries. I'm jazzed and want to do it now, but I should get some sleep. And who knows how long the DB part will take to code??
Night all..
Friday, February 27, 2009
Subscribe to:
Post Comments (Atom)
Excellent work Dystopian Primate Coder!
ReplyDelete-Primate Prime