More challenge levels

This commit is contained in:
Eric Mertens 2024-12-07 19:17:50 -08:00
parent 05161a3c42
commit 6012831267
6 changed files with 231 additions and 9 deletions

View File

@ -139,13 +139,13 @@ moveBlock' world locMap visited loc loc' dir name box enters offset =
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 locI enters then if Set.member locI enters then
moveEpsilon do epsilon <- findEpsilon world (locName locI)
moveEpsilon epsilon
else 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 locI enters) offset'
moveEpsilon = moveEpsilon epsilon =
do epsilon <- findEpsilon world (locName loc') do let eBox = boxIx world epsilon
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 (Set.insert locI enters) offset' moveBlock' world locMap visited loc locI dir name box (Set.insert locI enters) offset'

View File

@ -62,6 +62,12 @@ 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
@ -70,9 +76,10 @@ 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 xs1 <- parseWalls height
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)
@ -92,18 +99,20 @@ 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 xs1 <- parseWalls height
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 :: ReadP [String] parseWalls :: Maybe Int -> ReadP [String]
parseWalls = parseWalls height =
do row0 <- munch1 ('\n' /=) <* char '\n' do row0 <- munch1 ('\n' /=) <* char '\n'
rows <- replicateM (length row0 - 1) (munch1 ('\n' /=) <* char '\n') let h = maybe (length row0 - 1) (subtract 1) height
rows <- replicateM h (munch1 ('\n' /=) <* char '\n')
pure (row0:rows) pure (row0:rows)
token :: ReadP String token :: ReadP String

27
levels/challenge08.txt Normal file
View File

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

87
levels/challenge18.txt Normal file
View File

@ -0,0 +1,87 @@
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
▓▓ ▓▓
▓▓
▓▓▓▓▓
▓▓▓▓▓
▓▓▓▓▓

43
levels/challenge30.txt Normal file
View File

@ -0,0 +1,43 @@
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

56
levels/challenge31.txt Normal file
View File

@ -0,0 +1,56 @@
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