comparison src/sim.tp @ 54:a37ceb0a4f5c

merge
author Mike Pavone <pavone@retrodev.com>
date Sun, 15 Jul 2012 21:56:43 -0700
parents fbeedb3aa239 186fce0c98ee
children ca86c88c2336 7d4e51b4769a
comparison
equal deleted inserted replaced
53:fbeedb3aa239 54:a37ceb0a4f5c
62 navigable <- { false } 62 navigable <- { false }
63 eq <- :other { id = (other id) } 63 eq <- :other { id = (other id) }
64 collected <- 0 64 collected <- 0
65 heldBreath <- 0 65 heldBreath <- 0
66 razors <- 0 66 razors <- 0
67 busted <- false
68 mine <- null 67 mine <- null
69 doCmd <- :cmd { 68 doCmd <- :cmd {
70 action <- commands get: cmd withDefault: { null } 69 action <- commands get: cmd withDefault: { null }
71 action: 70 action:
72 } 71 }
145 getCell <- :x y { 144 getCell <- :x y {
146 grid get: (calcIndex: x y) 145 grid get: (calcIndex: x y)
147 } 146 }
148 setCell <- :x y val { 147 setCell <- :x y val {
149 grid set: (calcIndex: x y) val 148 grid set: (calcIndex: x y) val
149 }
150 getNextCell <- :x y {
151 _nextGrid get: (calcIndex: x y)
150 } 152 }
151 setNextCell <- :x y val { 153 setNextCell <- :x y val {
152 _nextGrid set: (calcIndex: x y) val 154 _nextGrid set: (calcIndex: x y) val
153 } 155 }
154 validDest?:from <- :index :fromIndex { 156 validDest?:from <- :index :fromIndex {
285 } 287 }
286 } 288 }
287 } 289 }
288 _nextGrid set: index nextValue 290 _nextGrid set: index nextValue
289 } 291 }
290 swapGrids <- { 292 }
291 tmp <- grid 293 checkForDeath <- {
292 grid <- _nextGrid 294 robotsNewFace <- getNextCell: (_robot x) (_robot y) + 1
293 _nextGrid <- tmp 295 robotsFace <- getCell: (_robot x) (_robot y) + 1
294 } 296 if: (robotsNewFace eq: (cellTypes rock)) {
295 swapGrids: 297 if: (not: (robotsFace eq: (cellTypes rock))) {
298 _ended <-true
299 }
300 }
301 }
302 swapGrids <- {
303 tmp <- grid
304 grid <- _nextGrid
305 _nextGrid <- tmp
296 } 306 }
297 abort <- { 307 abort <- {
298 _ended <- true 308 _ended <- true
299 addPoints: (_robot collected) * 25 309 addPoints: (_robot collected) * 25
300 } 310 }
308 if: (not: _ended) { 318 if: (not: _ended) {
309 _robot doCmd: roboCmd 319 _robot doCmd: roboCmd
310 score <- score - 1 320 score <- score - 1
311 moves append: roboCmd 321 moves append: roboCmd
312 doUpdate: 322 doUpdate:
323 checkForDeath:
324 swapGrids:
313 if: (moves length) >= _maxmoves { 325 if: (moves length) >= _maxmoves {
314 abort 326 abort
315 } 327 }
316 } 328 }
317 self 329 self