Mercurial > repos > icfp2012
comparison src/sim.tp @ 67:ff8d7b4499f5 default tip
Submission prep
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 16 Jul 2012 04:48:50 -0700 |
parents | aa822c683e28 |
children |
comparison
equal
deleted
inserted
replaced
66:cffcf36f1610 | 67:ff8d7b4499f5 |
---|---|
399 foreach: moves :idx m { | 399 foreach: moves :idx m { |
400 os write: 2 m | 400 os write: 2 m |
401 } | 401 } |
402 os write: 2 "\n" | 402 os write: 2 "\n" |
403 } | 403 } |
404 printMoves <- { | |
405 foreach: moves :idx m { | |
406 os write: 1 m | |
407 } | |
408 os write: 1 "\n" | |
409 } | |
404 clone <- { | 410 clone <- { |
405 cgrid <- #[] | 411 cgrid <- #[] |
406 foreach: grid :idx el { | 412 foreach: grid :idx el { |
407 if: (el isrobot) { | 413 if: (el isrobot) { |
408 cgrid append: (el clone) | 414 cgrid append: (el clone) |
515 if: (args length) < 2 { | 521 if: (args length) < 2 { |
516 print: "usage: sim filename\n" | 522 print: "usage: sim filename\n" |
517 } else: { | 523 } else: { |
518 verbose <- true | 524 verbose <- true |
519 text <- readFile: (args get: 1) | 525 text <- readFile: (args get: 1) |
520 print: text | 526 os write: 1 text |
521 //os close: 1 | 527 os close: 1 |
522 simState <- state fromStr: text | 528 simState <- state fromStr: text |
523 while: { not: (simState ended: ) } do: { | 529 while: { not: (simState ended: ) } do: { |
524 simState advance: (getMove: ) | 530 simState advance: (getMove: ) |
525 if: verbose { | 531 if: verbose { |
526 simState printGrid | 532 simState printGrid |