diff --git a/app/Model.hs b/app/Model.hs index 8d7a922..78eaa76 100644 --- a/app/Model.hs +++ b/app/Model.hs @@ -85,20 +85,21 @@ isWall world (Location n y x) = type Movement = (Int, Int) moveBlock :: - World -> - Map Location (Char, Box) -> - Map Location (Int, Char, Maybe Location) -> - Location -> - Movement -> + World {- ^ world -} -> + Map Location (Char, Box) {- ^ location cache -} -> + Map Location (Int, Char, Maybe Location) {- ^ accumulated changes -} -> + Location {- ^ source location -} -> + Movement {- ^ movement direction -} -> Rational {- ^ offset -} -> Maybe (Map Char (Maybe Location)) --- moving into a wall, not possible +-- moving a wall, not possible moveBlock world _ _ loc _ _ | isWall world loc = Nothing -- move introduced a loop, trim off the tail and report success moveBlock _ _ visited loc _ _ + -- XXX: ensure update is consistent to support flipped levels | Just (n,_,_) <- Map.lookup loc visited = Just (Map.fromList [(c,l) | (a,c,l) <- Map.elems visited, a >= n]) @@ -126,7 +127,7 @@ moveBlock' :: Movement -> Char -> Box -> - Set Location -> + Set Char -> Rational {- ^ offset -} -> Maybe (Map Char (Maybe Location)) moveBlock' world locMap visited loc loc' dir name box enters offset = @@ -138,16 +139,16 @@ moveBlock' world locMap visited loc loc' dir name box enters offset = moveInto = do (n,b) <- Map.lookup loc' locMap (locI, offset') <- enterLoc world n b dir offset - if Set.member locI enters then - do epsilon <- findEpsilon world (locName locI) + if Set.member (locName loc') enters then + do epsilon <- findEpsilon world (locName loc') moveEpsilon epsilon else - moveBlock' world locMap visited loc locI dir name box (Set.insert locI enters) offset' + moveBlock' world locMap visited loc locI dir name box (Set.insert (locName loc') enters) offset' moveEpsilon epsilon = do let eBox = boxIx world epsilon (locI, offset') <- enterLoc world epsilon eBox dir offset - moveBlock' world locMap visited loc locI dir name box (Set.insert locI enters) offset' + moveBlock' world locMap visited loc locI dir name box enters offset' moveToEat = do let dir' = invert dir diff --git a/levels/challenge04.txt b/levels/challenge04.txt new file mode 100644 index 0000000..9baf21c --- /dev/null +++ b/levels/challenge04.txt @@ -0,0 +1,65 @@ +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 +▓▓▓▓▓ +▓ ▓ ▓ +▓▓▓▓▓ +▓▓▓▓▓ +▓▓▓▓▓ diff --git a/levels/challenge05.txt b/levels/challenge05.txt new file mode 100644 index 0000000..bda7262 --- /dev/null +++ b/levels/challenge05.txt @@ -0,0 +1,57 @@ +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 +▓▓▓▓▓ +▓ ▓ ▓ +▓▓▓▓▓ +▓▓▓▓▓ +▓▓▓▓▓ diff --git a/levels/challenge06.txt b/levels/challenge06.txt new file mode 100644 index 0000000..e4226a5 --- /dev/null +++ b/levels/challenge06.txt @@ -0,0 +1,39 @@ +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 + + - + diff --git a/levels/challenge11.txt b/levels/challenge11.txt new file mode 100644 index 0000000..dbdcf71 --- /dev/null +++ b/levels/challenge11.txt @@ -0,0 +1,89 @@ +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 +▓▓▓▓▓ +▓ ▓ ▓ +▓▓▓▓▓ +▓▓▓▓▓ +▓▓▓▓▓ diff --git a/levels/challenge16.txt b/levels/challenge16.txt new file mode 100644 index 0000000..5ef9376 --- /dev/null +++ b/levels/challenge16.txt @@ -0,0 +1,46 @@ +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 +▓▓▓▓▓ +▓ ▓ ▓ +▓▓▓▓▓ +▓▓▓▓▓ +▓▓▓▓▓ diff --git a/levels/challenge17.txt b/levels/challenge17.txt index f66c89e..64393d1 100644 --- a/levels/challenge17.txt +++ b/levels/challenge17.txt @@ -45,10 +45,12 @@ block y blue boring ▓ block z blue boring ▓ -block p magenta boring +block p magenta boring height 7 ▓▓▓▓▓ ▓ ▓ ▓ +▓▓▓▓▓ +▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓ block 1 green interesting diff --git a/levels/challenge32.txt b/levels/challenge32.txt new file mode 100644 index 0000000..29123a4 --- /dev/null +++ b/levels/challenge32.txt @@ -0,0 +1,70 @@ +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 +▓▓▓▓▓ +▓ ▓ ▓ +▓▓▓▓▓ +▓▓▓▓▓ +▓▓▓▓▓ diff --git a/levels/challenge33.txt b/levels/challenge33.txt new file mode 100644 index 0000000..7883dad --- /dev/null +++ b/levels/challenge33.txt @@ -0,0 +1,68 @@ +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 +▓▓▓▓▓ +▓ ▓ ▓ +▓▓▓▓▓ +▓▓▓▓▓ +▓▓▓▓▓ diff --git a/levels/challenge34.txt b/levels/challenge34.txt new file mode 100644 index 0000000..78b0c41 --- /dev/null +++ b/levels/challenge34.txt @@ -0,0 +1,36 @@ +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 +▓▓▓▓▓ +▓ ▓ ▓ +▓▓▓▓▓ +▓▓▓▓▓ +▓▓▓▓▓ diff --git a/levels/gallery01.txt b/levels/gallery01.txt new file mode 100644 index 0000000..9bb3c29 --- /dev/null +++ b/levels/gallery01.txt @@ -0,0 +1,33 @@ +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 +▓▓▓▓▓ +▓ ▓ ▓ +▓▓▓▓▓ +▓▓▓▓▓ +▓▓▓▓▓ diff --git a/levels/gallery02.txt b/levels/gallery02.txt new file mode 100644 index 0000000..b2e4f48 --- /dev/null +++ b/levels/gallery02.txt @@ -0,0 +1,23 @@ +player p height 98 +block b blue interesting +▓▓▓▓▓▓▓ +▓ ▓ +▓ g ▓ +▓p - +▓ b ▓ +▓ ▓ +▓▓▓▓▓▓▓ +block g green interesting +▓▓▓▓▓▓▓ +▓ ▓ +▓ ▓ + - = ▓ +▓ ▓ +▓ ▓ +▓▓▓▓▓▓▓ +block p magenta boring +▓▓▓▓▓ +▓ ▓ ▓ +▓▓▓▓▓ +▓▓▓▓▓ +▓▓▓▓▓ diff --git a/levels/gallery03.txt b/levels/gallery03.txt new file mode 100644 index 0000000..e00f3cb --- /dev/null +++ b/levels/gallery03.txt @@ -0,0 +1,23 @@ +player p height 98 +block b blue interesting +▓▓▓▓▓▓▓ + =▓ + - -p ▓ + g ▓ +▓ b▓▓ +▓▓▓▓ ▓▓ + ▓▓▓▓▓▓ +block g green interesting +▓ +▓ +▓ +▓ +▓ +▓ +▓ +block p magenta boring +▓▓▓▓▓ +▓ ▓ ▓ +▓▓▓▓▓ +▓▓▓▓▓ +▓▓▓▓▓ diff --git a/levels/infiniteEnter01.txt b/levels/infiniteEnter01.txt new file mode 100644 index 0000000..900806e --- /dev/null +++ b/levels/infiniteEnter01.txt @@ -0,0 +1,26 @@ +player p +block p magenta boring +▓▓▓▓▓ +▓ ▓ ▓ +▓▓▓▓▓ +▓▓▓▓▓ +▓▓▓▓▓ +block w white interesting +▓▓▓▓▓▓▓ +▓▓▓▓ ▓▓ +▓ g ▓ +▓ ▓ +▓ p ▓ +▓ G ▓ +▓▓▓▓▓▓▓ +block g green interesting +▓ ▓ +▓▓▓ +▓▓▓ +link G g green +epsilon ε g green + + + = + + diff --git a/levels/infiniteEnter02.txt b/levels/infiniteEnter02.txt new file mode 100644 index 0000000..e19c8ef --- /dev/null +++ b/levels/infiniteEnter02.txt @@ -0,0 +1,28 @@ +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 + + + = + + diff --git a/levels/infiniteEnter03.txt b/levels/infiniteEnter03.txt new file mode 100644 index 0000000..233f57a --- /dev/null +++ b/levels/infiniteEnter03.txt @@ -0,0 +1,31 @@ +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 + + = + ▓▓ + ▓ ▓▓ + -▓ diff --git a/levels/infiniteEnter04.txt b/levels/infiniteEnter04.txt new file mode 100644 index 0000000..adcc848 --- /dev/null +++ b/levels/infiniteEnter04.txt @@ -0,0 +1,32 @@ +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 + + + = + + diff --git a/levels/infiniteEnter05.txt b/levels/infiniteEnter05.txt new file mode 100644 index 0000000..b7305e1 --- /dev/null +++ b/levels/infiniteEnter05.txt @@ -0,0 +1,32 @@ +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 + + + = + + diff --git a/levels/infiniteEnter6.txt b/levels/infiniteEnter06.txt similarity index 95% rename from levels/infiniteEnter6.txt rename to levels/infiniteEnter06.txt index 259fc5b..f6ac223 100644 --- a/levels/infiniteEnter6.txt +++ b/levels/infiniteEnter06.txt @@ -1,4 +1,4 @@ -player p +player p height 98 block w white interesting ▓▓▓▓▓▓▓ ▓ p ▓ diff --git a/levels/infiniteEnter08.txt b/levels/infiniteEnter08.txt new file mode 100644 index 0000000..2d876a1 --- /dev/null +++ b/levels/infiniteEnter08.txt @@ -0,0 +1,26 @@ +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 +▓▓▓▓▓ +▓ ▓ ▓ +▓▓▓▓▓ +▓▓▓▓▓ +▓▓▓▓▓ diff --git a/levels/infiniteEnter09.txt b/levels/infiniteEnter09.txt new file mode 100644 index 0000000..f4e0701 --- /dev/null +++ b/levels/infiniteEnter09.txt @@ -0,0 +1,26 @@ +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 +▓▓▓▓▓ +▓ ▓ ▓ +▓▓▓▓▓ +▓▓▓▓▓ +▓▓▓▓▓ diff --git a/levels/infiniteEnter15.txt b/levels/infiniteEnter15.txt new file mode 100644 index 0000000..a59f9e1 --- /dev/null +++ b/levels/infiniteEnter15.txt @@ -0,0 +1,29 @@ +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 + ▓ + ▓▓▓▓▓▓ + ▓ + ▓ + ▓ + ▓ + ▓▓ + ▓ diff --git a/levels/infiniteEnter20.txt b/levels/infiniteEnter20.txt index fe28db9..9368157 100644 --- a/levels/infiniteEnter20.txt +++ b/levels/infiniteEnter20.txt @@ -11,7 +11,7 @@ block t white boring ▓▓▓▓▓▓▓▓▓ block w white interesting ▓▓▓▓▓▓▓▓▓ -▓1 2▓▓=▓ +▓1 2 ▓▓=▓ ▓ ▓▓ε▓ ▓4 3▓▓▓▓ ▓ ▓ ▓ @@ -32,15 +32,9 @@ block r red interesting link a r red link b r red epsilon ε r red - - - - - - - - - + + + block 1 blue boring ▓ block 2 blue boring