# HG changeset patch # User Mike Pavone # Date 1342414603 25200 # Node ID a37ceb0a4f5c8a14ddd57e6b9b66ad94741236cd # Parent fbeedb3aa2395ae2635ee9626fefbb602c0abf90# Parent 186fce0c98ee8d8ed3a6ba605cd93cdda1538ea6 merge diff -r fbeedb3aa239 -r a37ceb0a4f5c src/sim.tp --- a/src/sim.tp Sun Jul 15 21:42:46 2012 -0700 +++ b/src/sim.tp Sun Jul 15 21:56:43 2012 -0700 @@ -64,7 +64,6 @@ collected <- 0 heldBreath <- 0 razors <- 0 - busted <- false mine <- null doCmd <- :cmd { action <- commands get: cmd withDefault: { null } @@ -148,6 +147,9 @@ setCell <- :x y val { grid set: (calcIndex: x y) val } + getNextCell <- :x y { + _nextGrid get: (calcIndex: x y) + } setNextCell <- :x y val { _nextGrid set: (calcIndex: x y) val } @@ -287,12 +289,20 @@ } _nextGrid set: index nextValue } - swapGrids <- { - tmp <- grid - grid <- _nextGrid - _nextGrid <- tmp + } + checkForDeath <- { + robotsNewFace <- getNextCell: (_robot x) (_robot y) + 1 + robotsFace <- getCell: (_robot x) (_robot y) + 1 + if: (robotsNewFace eq: (cellTypes rock)) { + if: (not: (robotsFace eq: (cellTypes rock))) { + _ended <-true + } } - swapGrids: + } + swapGrids <- { + tmp <- grid + grid <- _nextGrid + _nextGrid <- tmp } abort <- { _ended <- true @@ -310,6 +320,8 @@ score <- score - 1 moves append: roboCmd doUpdate: + checkForDeath: + swapGrids: if: (moves length) >= _maxmoves { abort }