comparison src/sim.tp @ 46:5d2e59cbbc7c

Merge
author Mike Pavone <pavone@retrodev.com>
date Sun, 15 Jul 2012 17:27:23 -0700
parents 9f1ca5ba2684 1f583d85c8ed
children 365c83ea7658
comparison
equal deleted inserted replaced
45:9f1ca5ba2684 46:5d2e59cbbc7c
209 foreach: grid :index value { 209 foreach: grid :index value {
210 if: (value eq: (cellTypes rock)) { 210 if: (value eq: (cellTypes rock)) {
211 x <- calcX: index 211 x <- calcX: index
212 y <- calcY: index 212 y <- calcY: index
213 below <- getCell: x (y - 1) 213 below <- getCell: x (y - 1)
214 fallToSide <- :delta {
215 side <- getCell: (x + delta) y
216 belowSide <- getCell: (x + delta) (y - 1)
217 if: (side eq: (cellTypes empty)) {
218 if: (belowSide eq: (cellTypes empty)) {
219 setCell: (x + delta) (y - 1) value
220 setCell: x y (cellTypes empty)
221 true
222 } else: { false }
223 } else: { false }
224 }
214 if: (below eq: (cellTypes empty)) { 225 if: (below eq: (cellTypes empty)) {
215 setCell: x y (cellTypes empty) 226 setCell: x y (cellTypes empty)
216 setCell: x (y - 1) value 227 setCell: x (y - 1) value
217 } 228 } else: { if: (below eq: (cellTypes rock)) {
229 if: (not: (fallToSide: 1)) {fallToSide: -1}
230 } else: { if: (below eq: (cellTypes lambda)) {
231 fallToSide: 1
232 }}} // end if
218 } else: { 233 } else: {
219 if: (value eq: (cellTypes closedLift)) { 234 if: (value eq: (cellTypes closedLift)) {
220 if: (_robot collected) = lambdaCount { 235 if: (_robot collected) = lambdaCount {
221 grid set: index (cellTypes openLift) 236 grid set: index (cellTypes openLift)
222 } 237 }
292 } else: { 307 } else: {
293 if: (el eq: (cellTypes lambda)) { 308 if: (el eq: (cellTypes lambda)) {
294 ret lambdaCount!: (ret lambdaCount) + 1 309 ret lambdaCount!: (ret lambdaCount) + 1
295 } 310 }
296 } 311 }
297
298
299 // adding a 'new' method to robot and doing this instead
300 // wolud allow me to treat robots and other cellTypes equaly
301 // particularly for adding methods or state to other cellTypess.
302 //
303 // if: (el = (cellTypes robot)) {
304 // robot <- el new:
305 // (ret grid) set: index robot
306 // robot mine!: ret
307 // ret updatePos: robot index
308 // nextGrid append: el
309 // } else: {
310 // nextGrid append: el
311 // }
312
313 } 312 }
314 ret 313 ret
315 } 314 }
316 315
317 fromStr <- :str { 316 fromStr <- :str {