Move towards better annotations when generating layouts

This commit is contained in:
2022-05-20 11:14:11 +01:00
parent 887dd547d9
commit 1739d648fe
6 changed files with 52 additions and 29 deletions
+16 -11
View File
@@ -1,3 +1,4 @@
{-# LANGUAGE TupleSections #-}
module Dodge.Room.Start where
import Dodge.Data
import Dodge.LevelGen.Data
@@ -48,14 +49,16 @@ powerFakeout = do
,PassDown keyholeCorridor,PassDown corridor])
`treeFromPost` UseAll door
startRoom :: RandomGen g => Int -> State g (SubCompTree Room)
startRoom :: RandomGen g => Int -> State g (SubCompTree Room,String)
startRoom i = join $ uncurry takeOneWeighted $ unzip
[ (,) (0.5::Float) $ chainUses <$> sequence [powerFakeout,weaponRoom i]
, (,) one rezBoxesWp
[ (,) (0.5::Float) ((chainUses <$> sequence [powerFakeout,fmap fst $weaponRoom i])
<&> (,"chainUses <$> sequence [powerFakeout,weaponRoom i]"))
, (,) one (rezBoxesWp <&> (, "rezBoxesWp"))
, (,) one (rezBoxThenWeaponRoom i)
, (,) one rezBoxesWpCrit
, (,) 1 $ runPastStart i
, (,) 1 $ startCrafts >>= roomsContaining [] >>= rezBoxThenRooms
, (,) one (rezBoxesWpCrit <&> (,"rezBoxesWpCrit"))
, (,) one (runPastStart i <&> (,"runPastStart " ++ show i))
, (,) one (startCrafts >>= roomsContaining [] >>= rezBoxThenRooms <&>
(,"startCrafts >>= roomsContaining [] >>= rezBoxThenRooms"))
]
where
one = 1::Float
@@ -77,16 +80,18 @@ rezBoxStart = do
ls <- rezColor
return $ treeFromPost [PassDown $ rezBox ls] (UseAll door)
rezBoxesThenWeaponRoom :: RandomGen g => Int -> State g (SubCompTree Room)
rezBoxesThenWeaponRoom :: RandomGen g => Int -> State g (SubCompTree Room,String)
rezBoxesThenWeaponRoom i = do
rboxes <- rezBoxes
wroom <- weaponRoom i
return $ rboxes `passUntilUseAll` [wroom]
wroom <- fmap fst $ weaponRoom i
return (rboxes `passUntilUseAll` [wroom] , "rezBoxesThenWeaponRoom " ++ show i)
rezBoxThenWeaponRoom :: RandomGen g => Int -> State g (SubCompTree Room)
rezBoxThenWeaponRoom :: RandomGen g => Int -> State g (SubCompTree Room,String)
rezBoxThenWeaponRoom i = do
rcol <- rezColor
treeFromTrunk [PassDown $ rezBox rcol,PassDown door] <$> weaponRoom i
(wroom,wroomname) <- weaponRoom i
return $ (treeFromTrunk [PassDown $ rezBox rcol,PassDown door] wroom
, "rezBoxThenWeaponRoom "++ show i ++ ":" ++ wroomname)
rezBoxThenRoom :: RandomGen g => Room -> State g (SubCompTree Room)
rezBoxThenRoom r = do