Mercurial > repos > icfp2012
changeset 56:ca86c88c2336
merge
author | William Morgan <bill@mrgn.org> |
---|---|
date | Sun, 15 Jul 2012 22:24:35 -0700 |
parents | b2e9e5ad3ad8 (diff) a37ceb0a4f5c (current diff) |
children | aa822c683e28 |
files | src/sim.tp |
diffstat | 6 files changed, 56 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/maps/evilbug1.map Sun Jul 15 22:24:35 2012 -0700 @@ -0,0 +1,6 @@ +###R# +# # +# # +L # +##### +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/maps/evilbug2.map Sun Jul 15 22:24:35 2012 -0700 @@ -0,0 +1,5 @@ +##### +# R# +# # +*# #* +*#L#*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/maps/evilbug3.map Sun Jul 15 22:24:35 2012 -0700 @@ -0,0 +1,6 @@ +##### +# R# +# # +*# #* +*#L#* +#####
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/maps/evilbug4.map Sun Jul 15 22:24:35 2012 -0700 @@ -0,0 +1,3 @@ +# R# +*# #* +*#L#*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/maps/testSim3.map Sun Jul 15 22:24:35 2012 -0700 @@ -0,0 +1,24 @@ +##### +#L # +# *# +# *# +# *# +# *# +# *# +# *# +# # +# # +# # +# # +# # +# # +# # +# # +# # +# # +# # +# # +# # +# R# +##### +
--- a/src/sim.tp Sun Jul 15 21:56:43 2012 -0700 +++ b/src/sim.tp Sun Jul 15 22:24:35 2012 -0700 @@ -133,6 +133,13 @@ _maxmoves <- in_width * in_height _heuristicValid <- false _heuristic <- 0 + getSafe <- :collection :index { + if: index >= 0 { + if: index < (collection length) { + collection get: index + } else: { (cellTypes wall) } + } else: { (cellTypes wall) } + } _succeeded <- false ret <- #{ grid <- in_grid @@ -142,26 +149,26 @@ calcX <- :index {index % width} calcY <- :index {index / width} getCell <- :x y { - grid get: (calcIndex: x y) + grid getSafe: (calcIndex: x y) } setCell <- :x y val { grid set: (calcIndex: x y) val } getNextCell <- :x y { - _nextGrid get: (calcIndex: x y) + _nextGrid getSafe: (calcIndex: x y) } setNextCell <- :x y val { _nextGrid set: (calcIndex: x y) val } validDest?:from <- :index :fromIndex { - cell <- (grid get: index) + cell <- (grid getSafe: index) if: (cell navigable) {true} else: { if: (cell eq: (cellTypes rock)) { diff <- index - fromIndex //make sure movement was horizontal if: (abs: diff) = 1 { rockdest <- index + diff - if: ((grid get: rockdest) eq: (cellTypes empty)) { + if: ((grid getSafe: rockdest) eq: (cellTypes empty)) { //make sure rock destination doesn't wrap (calcY: rockdest) = (calcY: index) } @@ -332,7 +339,7 @@ cur <- (grid length) - width col <- 0 while: {cur >= 0} do: { - os write: 2 ((grid get: cur) string) + os write: 2 ((grid getSafe: cur) string) cur <- cur + 1 col <- col + 1 if: col = width {