Thursday, June 28, 2012

Djikstra's algorithm in node / javascript

So tonight I had to implement Djikstra's algorithm to do some very simple pathfinding in an experimental thing I'm working on, so seeing as nothing has happened in June I decided I'll post the code.

Perhaps someone finds it useful some day, perhaps someone wants to discuss it or improve it. The code is very rough as I needed it *now*. Probably some bugs in there as well. I'm gonna start to use it now so I'll update the code as I find them :) I started of all functional but very quickly reverted back to old habits as the impending deadline loomed :)

Anyway, so it was fun writing some proper algorithm code again after how many years of businessy stuff :)

Djikstra in JS:

9 comments:

  1. Djikstra would be proud Nico :)

    ReplyDelete
  2. And to think, he probably didn't even use a komper to create that algorithm (at least that's mos the rumour).

    I'm not even gonna try and tell you how many times I had to rerun and change before my test passed :)

    The guy truly was way WAY above our league.

    ReplyDelete
  3. Algorithm == sequence of steps. Hence no computer needed.

    ReplyDelete
  4. Some funny quotes by the legend:

    "Don't compete with me: firstly, I have more experience, and secondly, I have chosen the weapons."

    "If 10 years from now, when you are doing something quick and dirty, you suddenly visualize that I am looking over your shoulders and say to yourself: 'Dijkstra would not have liked this', well that would be enough immortality for me."

    "It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration."

    "The competent programmer is fully aware of the limited size of his own skull. He therefore approaches his task with full humility, and avoids clever tricks like the plague. "

    and lastly (and quite profound)...

    "Why has elegance found so little following? That is the reality of it. Elegance has the disadvantage, if that's what it is, that hard work is needed to achieve it and a good education to appreciate it."

    ReplyDelete
  5. I won't be able to do it without the help of a komper doing the work for me.

    That's cause I'm spoilt and lazy :)

    ReplyDelete
  6. I think the one where he looks over your shoulder would make an excellent demotivational poster.

    ReplyDelete
  7. We have this on our sprint board: 

    ReplyDelete
  8. Oh guys! Check out this lecture from him! He is EXACTLY like I thought he would be:
    http://www.google.co.za/imgres?um=1&hl=en&client=ubuntu&channel=cs&authuser=0&biw=1600&bih=783&tbm=isch&tbnid=HiFnueGtmYoAvM:&imgrefurl=http://www.youtube.com/user/smpusr&docid=SCzV3rcg7xbExM&imgurl=http://i2.ytimg.com/vi/uW3keAPJqU8/default.jpg&w=120&h=90&ei=v57tT9eiFYyFhQet9J31DA&zoom=1&iact=rc&dur=315&sig=106507085250240615079&page=1&tbnh=72&tbnw=96&start=0&ndsp=38&ved=1t:429,r:27,s:0,i:152&tx=46&ty=3

    ReplyDelete