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
+8 -7
View File
@@ -1,3 +1,4 @@
{-# LANGUAGE TupleSections #-}
module Dodge.Room.Room where
import Data.Tile
import Dodge.Data
@@ -200,7 +201,7 @@ weaponUnderCrits i = do
let plmnts =
[--sPS (V2 20 0) 0 $ RandPS randFirstWeapon
sPS (V2 20 0) (negate $ pi/2) randC1
,sPS (V2 20 20) (negate $ pi/2) randC1
,sPS (V2 20 20) ( pi/2) randC1
]
addwpat p = rmPmnts .:~ PickOnePlacement i (sPS p 0 $ RandPS randFirstWeapon)
let continuationRoom = treeFromTrunk
@@ -288,13 +289,13 @@ deadEndRoom = defaultRoom
where
lnks = [(V2 0 30 ,0) ]
{- A random Either tree with a weapon and melee monster challenge. -}
weaponRoom :: RandomGen g => Int -> State g (SubCompTree Room)
weaponRoom :: RandomGen g => Int -> State g (SubCompTree Room, String)
weaponRoom i = join $ takeOne
[ weaponEmptyRoom
, weaponUnderCrits i
, weaponBehindPillar
, weaponBetweenPillars
, weaponLongCorridor
[ weaponEmptyRoom <&> (, "weaponEmptyRoom")
, weaponUnderCrits i<&> (, "weaponUnderCrits")
, weaponBehindPillar<&> (, "weaponBehindPillar")
, weaponBetweenPillars<&> (, "weaponBetweenPillars")
, weaponLongCorridor<&> (, "weaponLongCorridor")
]
roomCCrits :: RandomGen g => State g Room
+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