render deep infinities correctly

This commit is contained in:
2022-12-04 17:16:43 -08:00
parent 884ea15e6c
commit 14c8d62646
3 changed files with 208 additions and 308 deletions

View File

@@ -125,55 +125,58 @@ smallWorld =
(Location 'b' 0 0) (Location 'b' 0 0)
center8 :: World center8 :: World
center8 = center8 = parse
World "player p\n\
(Map.fromList \block t white boring\n\
[('a', \▓▓▓▓▓▓▓▓▓\n\
Box (Location 'a' 3 (-3)) \▓▓▓▓▓▓▓▓▓\n\
(Original (makeWalls [ \▓▓▓▓▓▓▓▓▓\n\
"▓▓▓▓▓▓▓▓▓", \▓▓▓▓▓▓▓▓▓\n\
"▓▓▓▓▓▓▓▓▓", \▓▓▓▓t▓a▓▓\n\
"▓▓ ▓▓", \▓▓▓▓▓▓▓▓▓\n\
"▓▓ ▓▓", \▓▓▓▓▓▓▓▓▓\n\
"▓ ▓▓", \▓▓▓▓▓▓▓▓▓\n\
"▓ ▓▓", \▓▓▓▓▓▓▓▓▓\n\
"▓▓▓▓ ▓▓▓▓", \block a white interesting\n\
"▓ ▓▓ ▓▓", \▓▓▓▓▓▓▓▓▓\n\
"▓▓▓▓▓▓▓▓▓" \▓▓▓▓▓▓▓▓▓\n\
])) \▓▓ ▓▓\n\
(withForeColor defAttr black) \▓▓ p ▓▓\n\
False), \ g ▓▓\n\
('1', \▓ ▓▓\n\
Box \▓▓▓▓ ▓▓▓▓\n\
(Location 'a' 0 0) \▓▓▓▓- =▓▓\n\
(Original (makeWalls [ \▓▓▓▓▓▓▓▓▓\n\
" ▓▓", \block g green interesting\n\
" ▓▓▓▓▓", \ x ▓▓\n\
" ", \ ▓▓▓▓▓\n\
" ", \ \n\
" ", \ \n\
" ", \ \n\
" ", \ \n\
" ", \ \n\
" " \ \n\
])) \ \n\
(withForeColor defAttr green) \block x yellow boring\n\
False), \▓▓▓▓▓▓▓▓▓\n\
('2', \▓▓▓▓▓▓▓▓▓\n\
Box \▓▓▓▓▓▓▓▓▓\n\
(Location '1' (-4) 0) \▓▓▓▓▓▓▓▓▓\n\
(Original (solid 9)) \▓▓▓▓▓▓▓▓▓\n\
(withForeColor defAttr yellow) \▓▓▓▓▓▓▓▓▓\n\
True), \▓▓▓▓▓▓▓▓▓\n\
('b', \▓▓▓▓▓▓▓▓▓\n\
Box \▓▓▓▓▓▓▓▓▓\n\
(Location 'a' (-1) 0) \block p magenta boring\n\
(Original (solid 9)) \▓▓▓▓▓▓▓▓▓\n\
(withForeColor defAttr red) \▓▓▓▓▓▓▓▓▓\n\
True) \▓ ▓▓▓ ▓▓▓\n\
]) 'b' \▓▓▓▓▓▓▓▓▓\n\
Set.empty \▓▓▓▓▓▓▓▓▓\n\
(Location 'a' 3 2) \▓▓▓▓▓▓▓▓▓\n\
\▓▓▓▓▓▓▓▓▓\n\
\▓▓▓▓▓▓▓▓▓\n\
\▓▓▓▓▓▓▓▓▓\n"
center13 :: World center13 :: World
center13 = parse center13 = parse
@@ -230,40 +233,29 @@ center13 = parse
\▓▓▓▓▓▓▓▓▓\n" \▓▓▓▓▓▓▓▓▓\n"
clone11 :: World clone11 :: World
clone11 = clone11 = parse
World "player p\n\
(Map.fromList \block a green boring\n\
[('a', \▓▓▓▓▓▓▓▓▓\n\
Box (Location 'a' (-2) 2) \▓= \n\
(Original (makeWalls [ \▓- ▓ a ▓\n\
"▓▓▓▓▓▓▓▓▓", \▓- \n\
"", \ pA \n\
"▓ ▓ ▓", \▓ ▓ ▓\n\
"▓ ▓ ▓", \▓ ▓ ▓\n\
"", \▓▓▓ ▓▓▓\n\
"▓ ▓ ▓", \▓▓▓▓▓▓▓▓▓\n\
"▓ ▓ ▓", \link A a green\n\
"▓▓▓ ▓▓▓", \block p magenta boring\n\
"▓▓▓▓▓▓▓▓▓" \▓▓▓▓▓▓▓▓▓\n\
])) \▓▓▓▓▓▓▓▓▓\n\
(withForeColor defAttr green) \▓ ▓▓▓ ▓▓▓\n\
False), \▓▓▓▓▓▓▓▓▓\n\
('A', \▓▓▓▓▓▓▓▓▓\n\
Box \▓▓▓▓▓▓▓▓▓\n\
(Location 'a' 0 2) \▓▓▓▓▓▓▓▓▓\n\
(Link 'a') \▓▓▓▓▓▓▓▓▓\n\
(withForeColor defAttr green) \▓▓▓▓▓▓▓▓▓\n"
True),
('b',
Box
(Location 'a' 0 (-2))
(Original (solid 9))
(withForeColor defAttr red)
True)
])
'b'
(Set.fromList [Location 'a' (-1) (-3), Location 'a' (-2) (-3)])
(Location 'a' (-3) (-3))
transfer14 :: World transfer14 :: World
transfer14 = transfer14 =
@@ -860,117 +852,62 @@ infiniteExit5 =
infiniteExit15 :: World infiniteExit15 :: World
infiniteExit15 = infiniteExit15 = parse
World "player m\n\
(Map.fromList \block t cyan boring\n\
[('A', -- extra frame to accomodate the larger level \▓▓▓▓▓▓▓▓▓\n\
Box (Location 'F' 3 3) \▓▓▓▓▓▓▓▓▓\n\
(Original (makeWalls [ \▓▓▓▓▓▓▓▓▓\n\
"▓▓▓▓▓▓▓▓▓", \▓▓▓▓▓▓▓▓▓\n\
"▓▓▓▓▓▓▓▓▓", \▓▓▓▓t▓a▓▓\n\
"▓▓▓▓▓▓▓▓▓", \▓▓▓▓▓▓▓▓▓\n\
"▓▓▓▓▓▓▓▓▓", \▓▓▓▓▓▓▓▓▓\n\
"▓▓▓▓ ▓▓▓▓", \▓▓▓▓▓▓▓▓\n\
"▓▓▓▓▓▓▓▓▓", \▓▓▓▓▓▓▓▓▓\n\
"▓▓▓▓▓▓▓▓▓", \block a cyan interesting\n\
"▓▓▓▓▓▓▓ ", \▓▓▓G▓▓▓▓▓\n\
"▓▓▓▓▓▓▓▓▓" \ ▓▓▓▓\n\
])) \ P ▓▓-=\n\
(withForeColor defAttr cyan) \ ▓--▓\n\
True), \ p g -▓▓\n\
('a', \ m ▓▓▓▓\n\
Box \ Π Γ ▓▓▓▓\n\
(Location 'A' 0 0) \ ▓▓▓▓\n\
(Original (makeWalls [ \▓▓▓▓▓▓▓▓▓\n\
"▓▓▓ ▓▓▓▓▓", \block m magenta boring\n\
" ▓▓▓▓", \▓▓▓▓▓▓▓▓▓\n\
" ▓▓ ", \▓▓▓▓▓▓▓▓▓\n\
" ▓ ▓", \▓▓ ▓▓▓ ▓▓\n\
" ▓▓", \▓▓▓▓▓▓▓▓▓\n\
" ▓▓▓▓", \▓▓▓▓▓▓▓▓▓\n\
" ▓▓▓▓", \▓▓▓▓▓▓▓▓▓\n\
" ▓▓▓▓", \▓▓▓▓▓▓▓▓▓\n\
"▓▓▓▓▓▓▓▓▓" \▓▓▓▓▓▓▓▓▓\n\
])) \▓▓▓▓▓▓▓▓▓\n\
(withForeColor defAttr cyan) \block g green interesting\n\
False), \ \n\
('b', \ \n\
Box \ \n\
(Location 'a' 1 (-2)) \ \n\
(Original (makeWalls [ \ \n\
"▓▓▓▓▓▓▓▓▓", \ \n\
"▓▓▓▓▓▓▓▓▓", \ \n\
"▓▓ ▓▓▓ ▓▓", \ \n\
"▓▓▓▓▓▓▓▓▓", \ \n\
"▓▓▓▓▓▓▓▓▓", \block p red interesting\n\
"▓▓▓▓▓▓▓▓▓", \ \n\
"▓▓▓▓▓▓▓▓▓", \ \n\
"▓▓▓▓▓▓▓▓▓", \ \n\
"▓▓▓▓▓▓▓▓▓" \ \n\
])) \ \n\
(withForeColor defAttr magenta) \ \n\
True), \ \n\
('g', \ \n\
Box \ \n\
(Location 'a' 0 (-1)) \link G g green\n\
(Original (makeWalls [ \link P p red\n\
" ", \infinity Γ g green\n\
" ", \infinity Π p red\n"
" ",
" ",
" ",
" ",
" ",
" ",
" "
]))
(withForeColor defAttr green)
False),
('G',
Box
(Location 'a' (-4) (-1))
(Link 'g')
(withForeColor defAttr green)
True),
('Γ',
Box
(Location 'a' 2 (-1))
(Infinity 'g')
(withForeColor defAttr green)
False),
('p',
Box
(Location 'a' 0 (-3))
(Original (makeWalls [
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
]))
(withForeColor defAttr red)
False),
('P',
Box
(Location 'a' (-2) (-3))
(Link 'p')
(withForeColor defAttr red)
True),
('Π',
Box
(Location 'a' 2 (-3))
(Infinity 'p')
(withForeColor defAttr red)
False)
])
'b'
(Set.fromList [Location 'a' 0 2, Location 'a' (-1) 2, Location 'a' (-1) 3, Location 'a' (-2) 3])
(Location 'a' (-2) 4)
infiniteEnter17 :: World infiniteEnter17 :: World
infiniteEnter17 = infiniteEnter17 =
@@ -1262,112 +1199,72 @@ multiInfinite5 = parse
\▓▓▓▓▓▓▓▓▓\n\ \▓▓▓▓▓▓▓▓▓\n\
\▓▓▓▓▓▓▓▓▓\n\ \▓▓▓▓▓▓▓▓▓\n\
\infinity 1 b blue\n\ \infinity 1 b blue\n\
\infinity 2 b blue\n\ \infinity 2 1 blue\n\
\infinity 3 b blue\n" \infinity 3 2 blue\n"
multiInfinite8 :: World multiInfinite8 :: World
multiInfinite8 = multiInfinite8 = parse
World "player p\n\
(Map.fromList \block b blue interesting\n\
[('b', Box \▓ ▓\n\
(Location 'b' 3 1) \ \n\
(Original (makeWalls [ \▓▓ ▓\n\
"", \1 p A ▓\n\
"", \\n\
"", \2\n\
" ", \\n\
" ", \3 b▓▓▓\n\
"▓ ▓", \▓▓▓▓▓▓▓▓▓\n\
"▓▓ ▓", \link A b blue\n\
"▓ ▓▓▓", \link B b blue\n\
"▓▓▓▓▓▓▓▓▓"])) \link C b blue\n\
(withForeColor defAttr blue) \block p magenta boring\n\
False), \▓▓▓▓▓▓▓▓▓\n\
('p', \▓▓▓▓▓▓▓▓▓\n\
Box \▓▓ ▓▓▓ ▓▓\n\
(Location 'b' (-1) 0) \▓▓▓▓▓▓▓▓▓\n\
(Original (makeWalls [ \▓▓▓▓▓▓▓▓▓\n\
"▓▓▓▓▓▓▓▓▓", \▓▓▓▓▓▓▓▓▓\n\
"▓▓▓▓▓▓▓▓▓", \▓▓▓▓▓▓▓▓▓\n\
"▓▓ ▓▓▓ ▓▓", \▓▓▓▓▓▓▓\n\
"▓▓▓▓▓▓▓▓▓", \▓▓▓▓▓▓▓▓▓\n\
"▓▓▓▓▓▓▓▓▓", \epsilon 1 b blue\n\
"▓▓▓▓▓▓▓▓▓", \ \n\
"▓▓▓▓▓▓▓▓▓", \ \n\
"▓▓▓▓▓▓▓▓▓", \ \n\
"▓▓▓▓▓▓▓▓▓" \ ▓▓\n\
])) \ B \n\
(withForeColor defAttr magenta) \ ▓▓\n\
True), \ \n\
('A', \ \n\
Box (Location 'b' (-1) 2) \ \n\
(Link 'b') \epsilon 2 1 blue\n\
(withForeColor defAttr blue) \ \n\
True), \ \n\
('1', \\n\
Box \ ▓▓\n\
(Location 'b' (-1) (-3)) \\n\
(Epsilon 'b' (makeWalls [ \ ▓▓\n\
" ", \ \n\
"", \ \n\
" ", \ C x \n\
" ▓▓", \epsilon 3 2 blue\n\
"", \ \n\
" ▓▓", \ \n\
" ", \ \n\
" ", \ ▓▓\n\
" "])) \ = \n\
(withForeColor defAttr blue) \ ▓▓\n\
False), \ \n\
('2', \ \n\
Box \ \n\
(Location 'b' 1 (-3)) \block x yellow boring\n\
(Epsilon '1' (makeWalls [ \▓▓▓▓▓▓▓▓▓\n\
" ", \▓▓▓▓▓▓▓▓▓\n\
" ", \▓▓▓▓▓▓▓▓▓\n\
"", \▓▓▓▓▓▓▓▓▓\n\
" ▓▓", \▓▓▓▓▓▓▓▓▓\n\
"", \▓▓▓▓▓▓▓▓▓\n\
" ▓▓", \▓▓▓▓▓▓▓▓▓\n\
" ", \▓▓▓▓▓▓▓▓▓\n\
" ", \▓▓▓▓▓▓▓▓▓\n"
" "]))
(withForeColor defAttr blue)
False),
('3',
Box
(Location 'b' 3 (-3))
(Epsilon '2' (makeWalls [
" ",
" ",
" ",
" ▓▓",
"",
" ▓▓",
" ",
" ",
" "]))
(withForeColor defAttr blue)
False),
('x',
Box
(Location '2' 4 1)
(Original (solid 9))
(withForeColor defAttr yellow)
True),
('B',
Box
(Location '1' 0 0)
(Link 'b')
(withForeColor defAttr blue)
True),
('C',
Box
(Location '2' 4 (-1))
(Link 'b')
(withForeColor defAttr blue)
True)
])
'p'
Set.empty
(Location '3' 0 0)

View File

@@ -46,7 +46,7 @@ parseBlocks (x:xs) =
["infinity", [name], [target], color] -> ["infinity", [name], [target], color] ->
do color_ <- parseColor color do color_ <- parseColor color
bs <- parseBlocks xs bs <- parseBlocks xs
pure ((name, Box undefined (Infinity target) color_ False,[]):bs) pure ((name, Box undefined (Infinity target) color_ True,[]):bs)
["epsilon", [name], [target], color] -> ["epsilon", [name], [target], color] ->
do color_ <- parseColor color do color_ <- parseColor color
let (xs1,xs2) = splitAt 9 xs let (xs1,xs2) = splitAt 9 xs

View File

@@ -52,12 +52,7 @@ renderCell world locMap name box y x scale =
| otherwise -> unit (boxColor box) scale floorChar | otherwise -> unit (boxColor box) scale floorChar
where where
loc = Location name' y x loc = Location name' y x
name' = name' = contentName world name box
case boxType box of
Original{} -> name
Link c -> c
Infinity c -> c
Epsilon{} -> name
wallChar = wallChar =
case boxType box of case boxType box of
Original{} -> '▓' Original{} -> '▓'
@@ -71,6 +66,14 @@ renderCell world locMap name box y x scale =
Infinity {} -> '∞' Infinity {} -> '∞'
Epsilon {} -> 'ε' Epsilon {} -> 'ε'
contentName :: World -> Char -> Box -> Char
contentName world name box =
case boxType box of
Original{} -> name
Link c -> c
Infinity c -> contentName world c (worldBoxes world Map.! c)
Epsilon{} -> name
renderBox :: World -> Map Location Char -> Box -> Char -> Int -> Image renderBox :: World -> Map Location Char -> Box -> Char -> Int -> Image
renderBox world locMap box name scale = renderBox world locMap box name scale =
vertCat [ vertCat [