Compare commits

..

No commits in common. "e28a3f5b07525dfa76729bc9808eac9261fd3b12" and "05161a3c4294ca798955f886755f442e9900cc38" have entirely different histories.

28 changed files with 31 additions and 1029 deletions

View File

@ -85,21 +85,20 @@ isWall world (Location n y x) =
type Movement = (Int, Int) type Movement = (Int, Int)
moveBlock :: moveBlock ::
World {- ^ world -} -> World ->
Map Location (Char, Box) {- ^ location cache -} -> Map Location (Char, Box) ->
Map Location (Int, Char, Maybe Location) {- ^ accumulated changes -} -> Map Location (Int, Char, Maybe Location) ->
Location {- ^ source location -} -> Location ->
Movement {- ^ movement direction -} -> Movement ->
Rational {- ^ offset -} -> Rational {- ^ offset -} ->
Maybe (Map Char (Maybe Location)) Maybe (Map Char (Maybe Location))
-- moving a wall, not possible -- moving into a wall, not possible
moveBlock world _ _ loc _ _ moveBlock world _ _ loc _ _
| isWall world loc = Nothing | isWall world loc = Nothing
-- move introduced a loop, trim off the tail and report success -- move introduced a loop, trim off the tail and report success
moveBlock _ _ visited loc _ _ moveBlock _ _ visited loc _ _
-- XXX: ensure update is consistent to support flipped levels
| Just (n,_,_) <- Map.lookup loc visited | Just (n,_,_) <- Map.lookup loc visited
= Just (Map.fromList [(c,l) | (a,c,l) <- Map.elems visited, a >= n]) = Just (Map.fromList [(c,l) | (a,c,l) <- Map.elems visited, a >= n])
@ -127,7 +126,7 @@ moveBlock' ::
Movement -> Movement ->
Char -> Char ->
Box -> Box ->
Set Char -> Set Location ->
Rational {- ^ offset -} -> Rational {- ^ offset -} ->
Maybe (Map Char (Maybe Location)) Maybe (Map Char (Maybe Location))
moveBlock' world locMap visited loc loc' dir name box enters offset = moveBlock' world locMap visited loc loc' dir name box enters offset =
@ -139,16 +138,16 @@ moveBlock' world locMap visited loc loc' dir name box enters offset =
moveInto = moveInto =
do (n,b) <- Map.lookup loc' locMap do (n,b) <- Map.lookup loc' locMap
(locI, offset') <- enterLoc world n b dir offset (locI, offset') <- enterLoc world n b dir offset
if Set.member (locName loc') enters then if Set.member locI enters then
do epsilon <- findEpsilon world (locName loc') moveEpsilon
moveEpsilon epsilon
else else
moveBlock' world locMap visited loc locI dir name box (Set.insert (locName loc') enters) offset' moveBlock' world locMap visited loc locI dir name box (Set.insert locI enters) offset'
moveEpsilon epsilon = moveEpsilon =
do let eBox = boxIx world epsilon do epsilon <- findEpsilon world (locName loc')
let eBox = boxIx world epsilon
(locI, offset') <- enterLoc world epsilon eBox dir offset (locI, offset') <- enterLoc world epsilon eBox dir offset
moveBlock' world locMap visited loc locI dir name box enters offset' moveBlock' world locMap visited loc locI dir name box (Set.insert locI enters) offset'
moveToEat = moveToEat =
do let dir' = invert dir do let dir' = invert dir

View File

@ -62,12 +62,6 @@ parseBoring =
"interesting" -> pure False "interesting" -> pure False
_ -> empty _ -> empty
parseHeight :: ReadP (Maybe Int)
parseHeight = option Nothing $
do "height" <- token
Just <$> integer
parseBlock :: ReadP (Char, Box, [(Char, Location)]) parseBlock :: ReadP (Char, Box, [(Char, Location)])
parseBlock = parseBlock =
do cmd <- token do cmd <- token
@ -76,10 +70,9 @@ parseBlock =
do [name] <- token do [name] <- token
color <- parseColor color <- parseColor
boring <- parseBoring boring <- parseBoring
height <- parseHeight
skipMany (satisfy (' '==)) skipMany (satisfy (' '==))
_ <- char '\n' _ <- char '\n'
xs1 <- parseWalls height xs1 <- parseWalls
let locs = findLocs name xs1 let locs = findLocs name xs1
let b = Box Nothing (Original (walls xs1)) color boring let b = Box Nothing (Original (walls xs1)) color boring
pure (name, b, locs) pure (name, b, locs)
@ -99,20 +92,18 @@ parseBlock =
do [name] <- token do [name] <- token
[target] <- token [target] <- token
color <- parseColor color <- parseColor
height <- parseHeight
skipMany (satisfy (' '==)) skipMany (satisfy (' '==))
_ <- char '\n' _ <- char '\n'
xs1 <- parseWalls height xs1 <- parseWalls
let locs = findLocs name xs1 let locs = findLocs name xs1
let b = Box Nothing (Epsilon target (walls xs1)) color False let b = Box Nothing (Epsilon target (walls xs1)) color False
pure (name, b, locs) pure (name, b, locs)
_ -> empty _ -> empty
parseWalls :: Maybe Int -> ReadP [String] parseWalls :: ReadP [String]
parseWalls height = parseWalls =
do row0 <- munch1 ('\n' /=) <* char '\n' do row0 <- munch1 ('\n' /=) <* char '\n'
let h = maybe (length row0 - 1) (subtract 1) height rows <- replicateM (length row0 - 1) (munch1 ('\n' /=) <* char '\n')
rows <- replicateM h (munch1 ('\n' /=) <* char '\n')
pure (row0:rows) pure (row0:rows)
token :: ReadP String token :: ReadP String

View File

@ -1,65 +0,0 @@
player p height 98
block W white boring
▓▓▓
▓w▓
▓▓▓
block w white interesting
▓U▓
7▓
p 1 ▓▓
▓▓
2 3 ▓▓
L▓
▓=▓
block U green interesting
▓▓▓
▓-▓
▓y▓
block y yellow boring
block 7 blue interesting
▓▓▓▓▓▓▓
block L blue interesting
▓▓▓▓▓▓▓
block 1 green interesting
▓▓
▓▓
▓▓
▓▓
block 2 green interesting
▓▓
▓▓
▓▓
▓▓
block 3 green interesting
▓▓
▓▓
▓▓
▓▓
▓▓
▓▓
block p red interesting
▓▓▓▓▓
▓ ▓ ▓
▓▓▓▓▓
▓▓▓▓▓
▓▓▓▓▓

View File

@ -1,57 +0,0 @@
player p height 90
block W white boring
▓▓▓
▓w▓
▓▓▓
block w white interesting
p
g b
G B
▓▓▓
block g green interesting
▓▓▓▓▓▓▓▓▓
▓▓
▓▓
▓▓
▓▓
▓▓ ▓
▓▓
▓▓▓▓▓▓▓▓▓
block G green interesting
▓▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓=
▓▓▓▓▓▓▓▓▓
▓▓
▓ ▓
▓▓
▓▓
▓▓
▓▓▓▓▓▓▓▓▓
block b blue interesting
▓▓▓▓▓▓▓▓▓
▓▓
▓▓
▓▓
▓ ▓
▓▓
▓ ▓▓
▓ ▓▓
▓▓▓▓▓▓▓▓▓
block B blue interesting
▓▓▓▓▓▓▓▓▓
▓ ▓▓
▓▓
▓▓
▓ ▓
▓▓
▓▓
▓ ▓▓
▓▓▓▓▓▓▓▓▓
block p red interesting
▓▓▓▓▓
▓ ▓ ▓
▓▓▓▓▓
▓▓▓▓▓
▓▓▓▓▓

View File

@ -1,39 +0,0 @@
player p height 105
block W white boring
▓▓▓
▓w▓
▓▓▓
block w white interesting
p 1
=
2 3
block 1 blue interesting
block 2 green interesting
block 3 yellow interesting
block p red interesting
-

View File

@ -1,27 +0,0 @@
player p height 81
block b blue interesting
▓▓▓▓▓▓▓▓▓
▓ ▓
▓ - - ▓
▓ y g ▓
▓ ▓
▓ p b ▓
▓ ▓
▓ ▓
▓▓▓▓▓▓▓▓▓
block y yellow boring
block g green interesting
▓▓▓▓▓▓▓
▓ ▓
▓ ▓
▓▓▓ ▓
▓= - ▓
▓▓▓▓▓▓▓
block p red boring
▓▓▓▓▓
▓ ▓ ▓
▓▓▓▓▓
▓▓▓▓▓
▓▓▓▓▓

View File

@ -1,89 +0,0 @@
player p height 98
block w white boring
▓▓▓▓▓▓▓
▓▓▓ab▓▓
▓▓▓gc▓▓
▓▓▓▓▓▓▓
▓▓▓▓▓▓▓
▓p d▓
▓▓▓▓▓▓▓
link a g green
link b g green
link c g green
link d g green
block g green interesting
1ABCD
EFGHI
KLM2
OP3QR
STUVW
block 1 yellow interesting
▓▓ ▓▓
▓▓
▓▓▓▓▓
▓▓▓=
▓▓▓▓▓
block 2 yellow interesting
▓ ▓ ▓
▓ ▓
▓ ▓ ▓
▓ ▓
▓▓▓ ▓
block 3 yellow interesting
▓▓▓ ▓
▓▓▓ ▓
▓▓▓ ▓
▓ ▓▓▓
block A blue boring
block B blue boring
block C blue boring
block D blue boring
block E blue boring
block F blue boring
block G blue boring
block H blue boring
block I blue boring
block J blue boring
block K blue boring
block L blue boring
block M blue boring
block N blue boring
block O blue boring
block P blue boring
block Q blue boring
block R blue boring
block S blue boring
block T blue boring
block U blue boring
block V blue boring
block W blue boring
block p magenta boring
▓▓▓▓▓
▓ ▓ ▓
▓▓▓▓▓
▓▓▓▓▓
▓▓▓▓▓

View File

@ -1,46 +0,0 @@
player p height 98
block g green interesting
▓▓▓▓▓▓▓▓▓
▓▓g123456
▓▓▓▓ ▓▓▓▓
▓ ▓
▓ 7 8 9 ▓
▓ ▓
▓ p y ▓
▓ Y▓
▓▓▓▓▓▓▓▓▓
block y yellow interesting
link Y y yellow
block 1 red boring
block 2 red boring
block 3 red boring
block 4 red boring
▓▓▓
▓=▓
▓ ▓
block 5 red boring
block 6 red boring
block 7 red boring
block 8 red boring
block 9 red boring
block p magenta boring
▓▓▓▓▓
▓ ▓ ▓
▓▓▓▓▓
▓▓▓▓▓
▓▓▓▓▓

View File

@ -45,12 +45,10 @@ block y blue boring
block z blue boring block z blue boring
block p magenta boring height 7 block p magenta boring
▓▓▓▓▓ ▓▓▓▓▓
▓ ▓ ▓ ▓ ▓ ▓
▓▓▓▓▓
▓▓▓▓▓
▓▓▓▓▓ ▓▓▓▓▓
▓▓▓▓▓ ▓▓▓▓▓
block 1 green interesting block 1 green interesting

View File

@ -1,87 +0,0 @@
player p height 154
block w white boring
▓▓▓▓▓▓▓▓▓▓▓
▓abc▓ q▓▓▓▓
▓ p ▓▓
▓123▓▓▓▓y ▓
▓▓▓▓▓▓▓▓▓ ▓
▓▓▓▓▓▓▓I H▓
▓▓▓4▓▓▓ ▓▓▓
▓ ▓K J▓▓▓
▓ ▓▓▓▓▓
▓LMN▓ r▓▓▓▓
▓▓▓▓▓▓▓▓▓▓▓
block 1 green boring
▓▓▓▓▓
▓▓▓▓▓
▓▓▓▓▓
▓▓
▓▓ ▓▓
block 2 green boring
▓▓▓▓▓
▓▓
▓▓ ▓▓
▓▓
▓▓▓▓▓
block 3 green boring
▓ ▓▓▓
▓▓▓
▓▓▓▓▓
▓▓▓▓▓
▓▓▓▓▓
block 4 green boring
▓▓▓▓▓
▓▓▓▓▓
▓▓▓▓▓
▓=▓▓▓
▓ ▓▓▓
block A cyan boring
block B cyan boring
block C cyan boring
block D cyan boring
block E cyan boring
block F cyan boring
block G cyan boring
block H cyan boring
block I cyan boring
block J cyan boring
block K cyan boring
block L cyan boring
block M cyan boring
block N cyan boring
block p red boring height 1
ABCDEFG
link q p red
link r p red
block a blue boring
▓▓▓
▓▓▓
▓ ▓
block b blue boring
▓▓▓
▓▓▓
▓ ▓
block c blue boring
▓▓▓
▓▓▓
▓ ▓
block y yellow boring
▓▓ ▓▓
▓▓
▓▓▓▓▓
▓▓▓▓▓
▓▓▓▓▓

View File

@ -1,43 +0,0 @@
player p height 81
block w white boring
▓▓▓▓▓▓▓▓▓
▓▓▓ y▓▓▓▓
▓ ▓▓
▓ G ▓▓
▓=p g▓
▓ Y ▓▓
▓ ▓▓
▓▓E▓F▓▓▓▓
▓▓▓▓▓▓▓▓▓
link G g green
link Y y yellow
block p red boring
▓▓▓▓▓
▓ ▓ ▓
▓▓▓▓▓
▓▓▓▓▓
▓▓▓▓▓
block y yellow boring
▓▓▓
▓▓
▓▓▓
block g green boring
▓▓▓
▓▓
▓▓▓
epsilon E y yellow
▓▓▓ ▓
1-
epsilon F g green
▓▓▓ ▓
2-
block 1 cyan boring
block 2 cyan boring

View File

@ -1,56 +0,0 @@
player p height 81
block w white boring
▓▓▓▓▓▓▓▓▓
▓ ▓
▓ g y ▓
▓B G Y b▓
▓ ▓
▓ p ▓▓▓▓
▓= ▓
▓▓▓▓▓QRS▓
▓▓▓▓▓▓▓▓▓
link G g green
link Y y yellow
link B b blue
block p red boring
▓▓▓▓▓
▓ ▓ ▓
▓▓▓▓▓
▓▓▓▓▓
▓▓▓▓▓
block y yellow interesting
▓▓▓
▓▓▓
▓ ▓
block g green interesting
▓▓▓
▓▓▓
▓ ▓
block b blue interesting
▓▓▓
▓▓▓
▓ ▓
epsilon Q g green
▓▓▓ ▓
▓-▓ ▓
▓1 ▓
▓ ▓▓▓
▓ ▓▓
epsilon R y yellow
▓▓▓ ▓
▓-▓ ▓
▓2 ▓
▓ ▓▓▓
▓ ▓▓
epsilon S b blue
▓▓▓ ▓
▓-▓ ▓
▓3 ▓
▓ ▓▓▓
▓ ▓▓
block 1 cyan boring
block 2 cyan boring
block 3 cyan boring

View File

@ -1,70 +0,0 @@
player p
block W white boring
▓▓▓
▓w▓
▓▓▓
block w white interesting
▓▓Y▓
1 ▓ y
2
3 p
ABC
▓ 4567
block Y yellow interesting
▓▓▓▓▓
▓▓▓▓▓
▓ =▓▓
▓ ▓▓▓
▓ ▓▓▓
block g green interesting
▓D▓
E▓F
▓G▓
link A g green
link B g green
link C g green
link D g green
link E g green
link F g green
link G g green
epsilon ε g green
block Q red interesting
▓▓▓▓▓▓▓▓▓
▓ ▓
▓ ▓
▓ ▓
▓ ε ▓
▓ ▓
▓ ▓
▓ ▓
▓▓▓▓▓▓▓▓▓
block 1 blue boring
block 2 blue boring
block 3 blue boring
block 4 blue boring
block 5 blue boring
block 6 blue boring
block 7 blue boring
block y yellow boring
▓ ▓▓▓
▓ ▓▓▓
▓▓▓
▓▓▓▓▓
▓▓▓▓▓
block p magenta boring
▓▓▓▓▓
▓ ▓ ▓
▓▓▓▓▓
▓▓▓▓▓
▓▓▓▓▓

View File

@ -1,68 +0,0 @@
player p height 121
block b blue interesting
▓▓
▓ ▓▓
▓A
▓▓
p ▓B
▓ ▓▓
f b▓▓▓C
▓▓▓▓▓
▓▓▓▓D
▓▓▓▓y▓▓▓▓▓▓
▓▓▓▓▓▓▓▓▓▓▓
block y yellow interesting
link f b blue
epsilon A b blue
X
▓ c
link c b blue
link X y yellow
epsilon B A blue
Y
d
▓ ▓
2
link d b blue
link Y y yellow
epsilon C B blue
Z
e 3
link e b blue
link Z y yellow
epsilon D C blue
=
block 1 yellow boring
block 2 yellow boring
block 3 yellow boring
block p magenta boring
▓▓▓▓▓
▓ ▓ ▓
▓▓▓▓▓
▓▓▓▓▓
▓▓▓▓▓

View File

@ -1,36 +0,0 @@
player p height 98
block w white interesting
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▓ ▓▓▓ ▓
▓ ▓ ▓
▓ 1 ▓ E ▓
▓ ▓▓ ▓
▓ 2 3 ▓ ▓
▓ ▓▓▓▓▓▓▓
▓ ▓ p ▓▓-▓▓
▓ ▓- F ▓
▓ A b ▓▓▓▓-▓▓
▓ ▓▓▓▓▓▓▓
▓ B ▓▓= ▓▓▓
▓ ▓▓ I ▓▓
▓ ▓▓▓ ▓▓▓
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
block b blue interesting
epsilon E b blue
epsilon F E blue
link A b blue
link B b blue
infinity I b blue
block 1 yellow boring
block 2 yellow boring
block p magenta boring
▓▓▓▓▓
▓ ▓ ▓
▓▓▓▓▓
▓▓▓▓▓
▓▓▓▓▓

View File

@ -1,33 +0,0 @@
player p height 98
block w white interesting
▓▓▓▓▓▓▓
▓ ▓
▓ b ▓
▓ p ▓
▓ g ▓
▓ ▓
▓▓▓▓▓▓▓
block b blue interesting
block g green interesting
▓▓▓ ▓▓▓
▓▓ ▓▓▓
▓▓ ▓▓▓▓
=▓ ▓▓
▓▓-12 ▓
▓▓-▓▓▓▓
▓▓▓▓▓▓▓
block 1 yellow boring
block 2 yellow boring
block p magenta boring
▓▓▓▓▓
▓ ▓ ▓
▓▓▓▓▓
▓▓▓▓▓
▓▓▓▓▓

View File

@ -1,23 +0,0 @@
player p height 98
block b blue interesting
▓▓▓▓▓▓▓
▓ ▓
▓ g ▓
▓p -
▓ b ▓
▓ ▓
▓▓▓▓▓▓▓
block g green interesting
▓▓▓▓▓▓▓
▓ ▓
▓ ▓
- = ▓
▓ ▓
▓ ▓
▓▓▓▓▓▓▓
block p magenta boring
▓▓▓▓▓
▓ ▓ ▓
▓▓▓▓▓
▓▓▓▓▓
▓▓▓▓▓

View File

@ -1,23 +0,0 @@
player p height 98
block b blue interesting
▓▓▓▓▓▓▓
=▓
- -p ▓
g ▓
▓ b▓▓
▓▓▓▓ ▓▓
▓▓▓▓▓▓
block g green interesting
block p magenta boring
▓▓▓▓▓
▓ ▓ ▓
▓▓▓▓▓
▓▓▓▓▓
▓▓▓▓▓

View File

@ -1,26 +0,0 @@
player p
block p magenta boring
▓▓▓▓▓
▓ ▓ ▓
▓▓▓▓▓
▓▓▓▓▓
▓▓▓▓▓
block w white interesting
▓▓▓▓▓▓▓
▓▓▓▓ ▓▓
▓ g ▓
▓ ▓
▓ p ▓
▓ G ▓
▓▓▓▓▓▓▓
block g green interesting
▓ ▓
▓▓▓
▓▓▓
link G g green
epsilon ε g green
=

View File

@ -1,28 +0,0 @@
player p height 98
block p magenta boring
▓▓▓▓▓
▓ ▓ ▓
▓▓▓▓▓
▓▓▓▓▓
▓▓▓▓▓
block w white interesting
▓▓▓▓▓▓▓
▓ ▓
▓ p ▓
▓G ▓
▓ ▓
▓g 1 ▓
▓▓▓▓▓▓▓
block g green interesting
▓ ▓
▓▓▓
link G g green
block 1 blue boring
epsilon ε g green
=

View File

@ -1,31 +0,0 @@
player p height 98
block p magenta boring
▓▓▓▓▓
▓ ▓ ▓
▓▓▓▓▓
▓▓▓▓▓
▓▓▓▓▓
block w white interesting
▓▓▓▓▓▓▓
▓▓▓ Gg▓
▓ F▓
▓ 1 ▓
▓ ▓▓
▓p ▓▓
▓▓▓▓▓▓▓
block g green interesting
▓▓▓▓▓
▓▓▓▓▓
▓▓▓▓
▓▓▓▓▓
▓▓ ▓▓
link G g green
link F g green
block 1 blue boring
epsilon ε g green
=
▓▓
▓ ▓▓
-▓

View File

@ -1,32 +0,0 @@
player p
block p magenta boring
▓▓▓▓▓
▓ ▓ ▓
▓▓▓▓▓
▓▓▓▓▓
▓▓▓▓▓
block w white interesting
▓▓▓▓▓▓▓
▓ ▓
▓ 1 2 ▓
▓ p ▓
▓ G ▓
▓ g ▓
▓▓▓▓▓▓▓
block g green interesting
▓▓ ▓▓
▓▓ ▓▓
▓▓ ▓▓
▓▓▓▓▓
▓▓▓▓▓
link G g green
block 1 blue boring
block 2 blue boring
epsilon ε g green
=

View File

@ -1,32 +0,0 @@
player p height 98
block p magenta boring
▓▓▓▓▓
▓ ▓ ▓
▓▓▓▓▓
▓▓▓▓▓
▓▓▓▓▓
block w white interesting
▓▓▓▓▓▓▓
▓ ▓
▓ 1 2 ▓
▓ p ▓
▓ g ▓
▓ G ▓
▓▓▓▓▓▓▓
block g green interesting
▓▓ ▓▓
▓▓ ▓▓
▓▓ ▓▓
▓▓▓▓▓
▓▓▓▓▓
link G g green
block 1 blue boring
block 2 blue boring
epsilon ε g green
=

View File

@ -1,26 +0,0 @@
player p height 98
block w white interesting
▓▓▓▓▓▓▓
▓- ▓ ▓▓
▓=p ▓▓
▓ ▓
▓ ▓ε▓▓
▓g ▓ ▓▓
▓▓▓▓▓▓▓
link G g green
block g green interesting
▓▓▓
▓▓G
▓▓▓
epsilon ε g green
block p magenta boring
▓▓▓▓▓
▓ ▓ ▓
▓▓▓▓▓
▓▓▓▓▓
▓▓▓▓▓

View File

@ -1,26 +0,0 @@
player p height 81
block w white interesting
▓▓▓▓▓▓▓▓▓
▓g ▓▓▓
▓ = ▓▓
▓G p ▓▓
▓ - ▓
▓ ▓▓
▓▓ ε ▓▓
▓▓▓▓▓▓ ▓▓
▓▓▓▓▓▓▓▓▓
link G g green
block g green interesting
epsilon ε g green
▓ ▓
▓ ▓
block p magenta boring
▓▓▓▓▓
▓ ▓ ▓
▓▓▓▓▓
▓▓▓▓▓
▓▓▓▓▓

View File

@ -1,29 +0,0 @@
player p
block p magenta boring
▓▓▓▓▓
▓ ▓ ▓
▓▓▓▓▓
▓▓▓▓▓
▓▓▓▓▓
block g green interesting
▓▓▓
▓ ε▓▓
▓▓▓
p
▓ --- ▓
g=G
link G g green
link F g green
epsilon ε g green
▓ F
▓▓▓▓▓▓
▓▓

View File

@ -35,6 +35,12 @@ epsilon ε r red
block 1 blue boring block 1 blue boring
block 2 blue boring block 2 blue boring

View File

@ -1,4 +1,4 @@
player p height 98 player p
block w white interesting block w white interesting
▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓
▓ p ▓ ▓ p ▓