hide boring blocks

This commit is contained in:
Eric Mertens 2022-12-03 13:33:02 -08:00
parent 877d7dc251
commit b77716c6bc
3 changed files with 344 additions and 44 deletions

View File

@ -63,6 +63,10 @@ worldList = Map.fromList
, ("clone11", clone11) , ("clone11", clone11)
, ("transfer14", transfer14) , ("transfer14", transfer14)
, ("open4", open4) , ("open4", open4)
, ("cycle10", cycle10)
, ("player10", player10)
, ("player11", player11)
, ("player18", player18)
] ]
smallWorld :: World smallWorld :: World
@ -82,32 +86,32 @@ smallWorld =
"▓ ▓", "▓ ▓",
"▓▓▓▓▓▓▓▓▓" "▓▓▓▓▓▓▓▓▓"
])) ]))
(withForeColor defAttr black)), (withForeColor defAttr black) False),
('1', ('1',
Box Box
(Location 'a' (-3) (-3)) (Location 'a' (-3) (-3))
(Original (makeWalls (replicate 9 (replicate 9 ' ')))) (Original (makeWalls (replicate 9 (replicate 9 ' '))))
(withForeColor defAttr yellow)), (withForeColor defAttr yellow) False),
('2', ('2',
Box Box
(Location 'a' (-3) (-2)) (Location 'a' (-3) (-2))
(Original (makeWalls (replicate 9 (replicate 9 ' ')))) (Original (makeWalls (replicate 9 (replicate 9 ' '))))
(withForeColor defAttr magenta)), (withForeColor defAttr magenta) False),
('3', ('3',
Box Box
(Location 'a' (-2) (-3)) (Location 'a' (-2) (-3))
(Original (makeWalls (replicate 9 (replicate 9 ' ')))) (Original (makeWalls (replicate 9 (replicate 9 ' '))))
(withForeColor defAttr blue)), (withForeColor defAttr blue) False),
('4', ('4',
Box Box
(Location 'a' (-2) (-2)) (Location 'a' (-2) (-2))
(Original (makeWalls (replicate 9 (replicate 9 ' ')))) (Original (makeWalls (replicate 9 (replicate 9 ' '))))
(withForeColor defAttr green)), (withForeColor defAttr green) False),
('b', ('b',
Box Box
(Location '1' 0 0) (Location '1' 0 0)
(Original (solid 9)) (Original (solid 9))
(withForeColor defAttr red)) (withForeColor defAttr red) True)
]) 'b' ]) 'b'
Set.empty Set.empty
(Location 'b' 0 0) (Location 'b' 0 0)
@ -129,7 +133,8 @@ center8 =
"▓ ▓▓ ▓▓", "▓ ▓▓ ▓▓",
"▓▓▓▓▓▓▓▓▓" "▓▓▓▓▓▓▓▓▓"
])) ]))
(withForeColor defAttr black)), (withForeColor defAttr black)
False),
('1', ('1',
Box Box
(Location 'a' 0 0) (Location 'a' 0 0)
@ -144,17 +149,20 @@ center8 =
" ", " ",
" " " "
])) ]))
(withForeColor defAttr green)), (withForeColor defAttr green)
False),
('2', ('2',
Box Box
(Location '1' (-4) 0) (Location '1' (-4) 0)
(Original (solid 9)) (Original (solid 9))
(withForeColor defAttr yellow)), (withForeColor defAttr yellow)
True),
('b', ('b',
Box Box
(Location 'a' (-1) 0) (Location 'a' (-1) 0)
(Original (solid 9)) (Original (solid 9))
(withForeColor defAttr red)) (withForeColor defAttr red)
True)
]) 'b' ]) 'b'
Set.empty Set.empty
(Location 'a' 3 2) (Location 'a' 3 2)
@ -176,7 +184,8 @@ center13 =
"▓ ▓▓ ▓", "▓ ▓▓ ▓",
"▓▓▓▓▓▓▓▓▓" "▓▓▓▓▓▓▓▓▓"
])) ]))
(withForeColor defAttr cyan)), (withForeColor defAttr cyan)
False),
('1', ('1',
Box Box
(Location 'a' (-1) 1) (Location 'a' (-1) 1)
@ -191,17 +200,20 @@ center13 =
" ▓▓▓▓▓▓▓ ", " ▓▓▓▓▓▓▓ ",
" " " "
])) ]))
(withForeColor defAttr green)), (withForeColor defAttr green)
False),
('2', ('2',
Box Box
(Location 'a' (-1) (-1)) (Location 'a' (-1) (-1))
(Original (solid 9)) (Original (solid 9))
(withForeColor defAttr yellow)), (withForeColor defAttr yellow)
True),
('b', ('b',
Box Box
(Location 'a' (-3) 0) (Location 'a' (-3) 0)
(Original (solid 9)) (Original (solid 9))
(withForeColor defAttr red)) (withForeColor defAttr red)
True)
]) 'b' ]) 'b'
Set.empty Set.empty
(Location 'a' 2 0) (Location 'a' 2 0)
@ -224,17 +236,20 @@ clone11 =
"▓▓▓ ▓▓▓", "▓▓▓ ▓▓▓",
"▓▓▓▓▓▓▓▓▓" "▓▓▓▓▓▓▓▓▓"
])) ]))
(withForeColor defAttr green)), (withForeColor defAttr green)
False),
('A', ('A',
Box Box
(Location 'a' 0 2) (Location 'a' 0 2)
(Link 'a') (Link 'a')
(withForeColor defAttr green)), (withForeColor defAttr green)
True),
('b', ('b',
Box Box
(Location 'a' 0 (-2)) (Location 'a' 0 (-2))
(Original (solid 9)) (Original (solid 9))
(withForeColor defAttr red)) (withForeColor defAttr red)
True)
]) ])
'b' 'b'
(Set.fromList [Location 'a' (-1) (-3), Location 'a' (-2) (-3)]) (Set.fromList [Location 'a' (-1) (-3), Location 'a' (-2) (-3)])
@ -257,7 +272,8 @@ transfer14 =
" ", " ",
" " " "
])) ]))
(withForeColor defAttr cyan)), (withForeColor defAttr cyan)
False),
('g', ('g',
Box Box
(Location 'a' (-1) (-1)) (Location 'a' (-1) (-1))
@ -272,7 +288,8 @@ transfer14 =
" ", " ",
"" ""
])) ]))
(withForeColor defAttr green)), (withForeColor defAttr green)
False),
('x', ('x',
Box Box
(Location 'g' 3 (-3)) (Location 'g' 3 (-3))
@ -287,12 +304,14 @@ transfer14 =
" ", " ",
" " " "
])) ]))
(withForeColor defAttr magenta)), (withForeColor defAttr magenta)
False),
('b', ('b',
Box Box
(Location 'a' 1 (-1)) (Location 'a' 1 (-1))
(Original (solid 9)) (Original (solid 9))
(withForeColor defAttr red)) (withForeColor defAttr red)
True)
]) ])
'b' 'b'
(Set.fromList [Location 'g' (-2) 0]) (Set.fromList [Location 'g' (-2) 0])
@ -315,7 +334,8 @@ open4 =
"▓▓ ▓", "▓▓ ▓",
"▓▓ ▓" "▓▓ ▓"
])) ]))
(withForeColor defAttr cyan)), (withForeColor defAttr cyan)
False),
('g', ('g',
Box Box
(Location 'a' 2 (-1)) (Location 'a' 2 (-1))
@ -330,7 +350,8 @@ open4 =
"▓▓▓▓ ▓▓▓▓", "▓▓▓▓ ▓▓▓▓",
"▓▓▓▓ ▓▓▓▓" "▓▓▓▓ ▓▓▓▓"
])) ]))
(withForeColor defAttr green)), (withForeColor defAttr green)
False),
('y', ('y',
Box Box
(Location 'a' 2 1) (Location 'a' 2 1)
@ -345,12 +366,14 @@ open4 =
"▓▓▓▓▓▓▓▓▓", "▓▓▓▓▓▓▓▓▓",
"▓▓▓▓▓▓▓▓▓" "▓▓▓▓▓▓▓▓▓"
])) ]))
(withForeColor defAttr yellow)), (withForeColor defAttr yellow)
False),
('b', ('b',
Box Box
(Location 'a' 0 1) (Location 'a' 0 1)
(Original (solid 9)) (Original (solid 9))
(withForeColor defAttr red)) (withForeColor defAttr red)
True)
]) ])
'b' 'b'
Set.empty Set.empty
@ -376,7 +399,8 @@ world0 = World {
"▓ ▓", "▓ ▓",
"▓ ▓", "▓ ▓",
"▓ ▓▓▓▓▓ ▓" "▓ ▓▓▓▓▓ ▓"
] ],
boxBoring = False
}), }),
('2', Box { ('2', Box {
boxColor = withForeColor defAttr cyan, boxColor = withForeColor defAttr cyan,
@ -391,12 +415,14 @@ world0 = World {
"▓ ▓", "▓ ▓",
" ", " ",
"▓ ▓▓ ▓▓ ▓" "▓ ▓▓ ▓▓ ▓"
] ],
boxBoring = False
}), }),
('₂', Box { ('₂', Box {
boxColor = withForeColor defAttr cyan, boxColor = withForeColor defAttr cyan,
boxLocation = Location '1' 2 (-1), boxLocation = Location '1' 2 (-1),
boxType = Link '2' boxType = Link '2',
boxBoring = True
}), }),
('3', Box { ('3', Box {
boxColor = withForeColor defAttr blue, boxColor = withForeColor defAttr blue,
@ -411,7 +437,8 @@ world0 = World {
"▓▓ ▓▓▓▓", "▓▓ ▓▓▓▓",
"▓▓ ▓▓▓▓", "▓▓ ▓▓▓▓",
"▓▓▓▓ ▓▓▓▓" "▓▓▓▓ ▓▓▓▓"
] ],
boxBoring = False
}), }),
('4', Box { ('4', Box {
boxColor = withForeColor defAttr black, boxColor = withForeColor defAttr black,
@ -426,7 +453,8 @@ world0 = World {
"▓ ▓", "▓ ▓",
"▓ ▓", "▓ ▓",
"▓▓▓▓ ▓▓▓▓" "▓▓▓▓ ▓▓▓▓"
] ],
boxBoring = False
}), }),
('b', Box { ('b', Box {
boxColor = withForeColor defAttr red, boxColor = withForeColor defAttr red,
@ -441,7 +469,8 @@ world0 = World {
"▓ ▓", "▓ ▓",
"▓ ▓", "▓ ▓",
"▓▓▓▓▓▓▓▓▓" "▓▓▓▓▓▓▓▓▓"
] ],
boxBoring = True
}), }),
('x', Box { ('x', Box {
boxColor = withForeColor defAttr yellow, boxColor = withForeColor defAttr yellow,
@ -456,8 +485,8 @@ world0 = World {
" ▓▓▓ ", " ▓▓▓ ",
" ▓ ▓▓▓ ", " ▓ ▓▓▓ ",
" ", " ",
"▓ ▓ ▓" "▓ ▓ ▓"],
] boxBoring = False
}), }),
('y', Box { ('y', Box {
boxColor = withForeColor defAttr magenta, boxColor = withForeColor defAttr magenta,
@ -471,33 +500,303 @@ world0 = World {
"▓▓▓▓ ", "▓▓▓▓ ",
"▓▓ ▓▓▓ ", "▓▓ ▓▓▓ ",
" ", " ",
"▓ ▓ ▓" "▓ ▓ ▓"],
] boxBoring = False
}), }),
('i', Box { ('i', Box {
boxColor = withForeColor defAttr black, boxColor = withForeColor defAttr black,
boxLocation = Location 'b' 0 (-2), boxLocation = Location 'b' 0 (-2),
boxType = Original $ solid 9 boxType = Original $ solid 9,
boxBoring = True
}), }),
('j', Box { ('j', Box {
boxColor = withForeColor defAttr black, boxColor = withForeColor defAttr black,
boxLocation = Location 'b' 0 (-1), boxLocation = Location 'b' 0 (-1),
boxType = Original $ solid 9 boxType = Original $ solid 9,
boxBoring = True
}), }),
('k', Box { ('k', Box {
boxColor = withForeColor defAttr black, boxColor = withForeColor defAttr black,
boxLocation = Location 'b' 0 0, boxLocation = Location 'b' 0 0,
boxType = Original $ solid 9 boxType = Original $ solid 9,
boxBoring = True
}), }),
('l', Box { ('l', Box {
boxColor = withForeColor defAttr black, boxColor = withForeColor defAttr black,
boxLocation = Location 'b' 0 1, boxLocation = Location 'b' 0 1,
boxType = Original $ solid 9 boxType = Original $ solid 9,
boxBoring = True
}), }),
('₁', Box { ('₁', Box {
boxColor = withForeColor defAttr green, boxColor = withForeColor defAttr green,
boxLocation = Location '1' 2 1, boxLocation = Location '1' 2 1,
boxType = Link '1' boxType = Link '1',
boxBoring = True
}) })
] ]
} }
cycle10 :: World
cycle10 =
World
(Map.fromList
[('g',
Box (Location 'g' 3 3)
(Original (makeWalls [
"▓▓▓▓ ▓▓▓▓",
"▓▓▓▓ ▓▓▓▓",
"▓▓▓▓ ▓▓▓▓",
"▓ ▓▓▓",
"▓ ▓▓▓",
"▓ ▓▓▓",
"▓ ▓▓▓",
"▓ ▓ ▓",
"▓ ▓ ▓"
]))
(withForeColor defAttr green)
False),
('G',
Box
(Location 'g' 0 (-2))
(Link 'g')
(withForeColor defAttr green)
True),
('p',
Box
(Location 'g' 0 0)
(Original (makeWalls [
"▓▓▓▓▓▓▓▓▓",
"▓▓▓▓▓▓▓▓▓",
"▓▓ ▓▓▓ ▓▓",
"▓▓▓▓▓▓▓▓▓",
"▓▓▓▓▓▓▓▓▓",
"▓▓▓▓▓▓▓▓▓",
"▓▓▓▓▓▓▓▓▓",
"▓▓▓▓▓▓▓▓▓",
"▓▓▓▓▓▓▓▓▓"
]))
(withForeColor defAttr magenta)
True),
('y',
Box
(Location 'g' (-4) 0)
(Original (makeWalls [
"▓▓▓▓▓▓▓▓▓",
"▓▓▓▓▓▓▓▓▓",
"▓▓▓▓▓▓▓▓▓",
"▓▓▓▓▓▓▓▓▓",
"▓▓▓▓▓▓▓ ",
"▓▓▓▓▓▓▓▓▓",
"▓▓▓▓▓▓▓▓▓",
"▓▓▓▓▓▓▓▓▓",
"▓▓▓▓▓▓▓▓▓"
]))
(withForeColor defAttr yellow)
False),
('1',
Box
(Location 'g' (-2) 0)
(Original (solid 9))
(withForeColor defAttr red)
True),
('2',
Box
(Location 'g' 2 0)
(Original (solid 9))
(withForeColor defAttr red)
True),
('3',
Box
(Location 'g' 2 (-2))
(Original (solid 9))
(withForeColor defAttr red)
True)
])
'p'
Set.empty
(Location 'y' 0 3)
player10 :: World
player10 =
World
(Map.fromList
[('a',
Box (Location 'a' 3 3)
(Original (makeWalls [
"▓▓▓▓▓▓▓▓▓",
"▓▓ ▓▓",
"▓▓ ▓▓",
"▓▓ ▓▓",
"▓▓ ▓▓",
"▓▓ ▓▓▓▓▓▓",
"▓▓ ▓▓▓",
"▓▓ ▓ ▓",
"▓▓▓▓▓▓▓▓▓"
]))
(withForeColor defAttr cyan)
False),
('p',
Box
(Location 'a' (-2) 0)
(Link 'c')
(withForeColor defAttr magenta)
True),
('C',
Box
(Location 'a' 0 2)
(Link 'c')
(withForeColor defAttr magenta)
True),
('c',
Box
(Location 'a' (-1) 0)
(Original (makeWalls [
"▓▓▓▓▓▓▓▓▓",
"▓▓▓▓▓▓▓▓▓",
"▓▓▓▓▓▓▓▓▓",
"▓▓▓▓▓ ",
"▓▓▓▓▓ ",
"▓▓▓▓▓ ",
"▓▓▓▓▓▓▓▓▓",
"▓▓▓▓▓▓▓▓▓",
"▓▓▓▓▓▓▓▓▓"
]))
(withForeColor defAttr magenta)
False),
('1',
Box
(Location 'a' (-3) 2)
(Original (solid 9))
(withForeColor defAttr blue)
True)
])
'p'
(Set.singleton (Location 'a' 2 1))
(Location 'a' 3 1)
player11 :: World
player11 =
World
(Map.fromList
[('_',
Box (Location '_' 3 3)
(Original (makeWalls [
"▓▓▓▓▓▓▓▓▓",
"▓▓▓▓▓▓▓▓▓",
"▓▓▓▓▓▓▓▓▓",
"▓▓▓▓▓▓▓▓▓",
"▓▓▓▓ ▓▓▓▓",
"▓▓▓▓▓▓▓▓▓",
"▓▓▓▓▓▓▓▓▓",
"▓▓▓▓▓▓▓ ▓",
"▓▓▓▓▓▓▓▓▓"
]))
(withForeColor defAttr cyan)
True),
('a',
Box
(Location '_' 0 0)
(Original (makeWalls [
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
]))
(withForeColor defAttr magenta)
True),
('A',
Box
(Location 'a' 0 0)
(Link 'a')
(withForeColor defAttr brightMagenta)
True),
('b',
Box
(Location 'a' (-1) (-4))
(Original (makeWalls [
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
]))
(withForeColor defAttr yellow)
False),
('1',
Box
(Location 'a' 0 4)
(Original (solid 9))
(withForeColor defAttr blue)
True)
])
'A'
(Set.fromList [Location 'a' 1 4, Location 'a' (-1) 4])
(Location 'a' 1 (-4))
player18 :: World
player18 =
World
(Map.fromList
[('c',
Box (Location 'c' (-1) (-1))
(Original (makeWalls [
"▓▓▓▓▓▓▓▓▓",
"▓▓▓▓▓▓▓▓▓",
"▓▓ ▓▓",
"▓▓ ▓▓",
"▓▓ ",
"▓▓ ▓▓",
"▓▓ ▓▓",
"▓▓▓▓▓▓▓▓▓",
"▓▓▓▓▓▓▓▓▓"
]))
(withForeColor defAttr yellow)
False),
('u',
Box
(Location 'c' 0 0)
(Original (makeWalls [
"▓▓▓▓ ▓▓▓▓",
"▓▓▓▓ ▓▓▓▓",
"▓▓▓▓ ▓▓▓▓",
"▓▓ ▓▓",
"▓▓ ▓▓",
"▓▓ ▓▓",
"▓▓▓▓▓▓▓▓▓",
"▓▓▓▓▓▓▓▓▓",
"▓▓▓▓▓▓▓▓▓"
]))
(withForeColor defAttr magenta)
False),
('1',
Box
(Location 'c' (-1) 1)
(Original (solid 9))
(withForeColor defAttr blue)
True),
('2',
Box
(Location 'c' 1 (-1))
(Original (solid 9))
(withForeColor defAttr blue)
True),
('3',
Box
(Location 'c' 1 1)
(Original (solid 9))
(withForeColor defAttr blue)
True)
])
'u'
(Set.singleton (Location 'u' (-1) 2))
(Location 'u' 1 (-2))

View File

@ -14,7 +14,8 @@ type Coord = (Int, Int)
data Box = Box { data Box = Box {
boxLocation :: Location, boxLocation :: Location,
boxType :: BoxType, boxType :: BoxType,
boxColor :: Attr boxColor :: Attr,
boxBoring :: Bool
} }
deriving (Show, Read, Eq) deriving (Show, Read, Eq)

View File

@ -104,7 +104,7 @@ renderFlat locMap world =
intersperse (char borderAttr ' ') intersperse (char borderAttr ' ')
[renderBox world locMap b n 2 [renderBox world locMap b n 2
| (n,b) <- Map.assocs (worldBoxes world) | (n,b) <- Map.assocs (worldBoxes world)
, Original{} <- [boxType b]] , not (boxBoring b)]
drawNestedWorld :: Map Location Char -> World -> Image drawNestedWorld :: Map Location Char -> World -> Image
drawNestedWorld locMap world = drawNestedWorld locMap world =