Mercurial > repos > icfp2012
view src/lifter.tp @ 42:21b14768ea00
removed comments.
author | William Morgan <bill@mrgn.org> |
---|---|
date | Sun, 15 Jul 2012 14:48:05 -0700 |
parents | 9bccdb3ac979 |
children | 0c09730c173e |
line wrap: on
line source
#{ pqueue <- { normalnode <- :pri val { #{ priority <- pri value <- val next <- false higherPriority? <- :other { priority > (other priority) } if:else <- :self trueblock :elseblock { trueblock: } } } head <- #{ higherPriority? <- :other {false} next <- { self } value <- { false } } #{ take <- { cur <- head head <- cur next cur value } insert:atPriority <- :val pri { node <- normalnode: pri val cur <- head last <- false while: {cur higherPriority?: node} do: { last <- cur cur <- cur next } if: last { node next!: (last next) last next!: node } else: { node next!: head head <- node } self } } } abs <- :val { if: val < 0 { 0 - val } else: { val } } distanceFrom:to <- :sx sy :dx dy { (abs: sx - dx) + (abs: sy - dy) } main <- { text <- sim readFd: 0 playfield <- (sim state) fromStr: text os write: 2 text os write: 2 "width: " . (string: (playfield width)) . "\n" os write: 2 "height: " . (string: (playfield height)) . "\n" me <-playfield getRobot os write: 2 "robot x: " . (me x) . " y: " . (me y) . "\n" neighbors <- playfield validMoves: (me x) (me y) foreach: neighbors :idx move { os write: 2 "move: " . move . "\n" curfield <- playfield clone curfield advance: (move cmd) curfield printGrid } } }