Tweak tree level generation

This commit is contained in:
2021-04-20 19:45:32 +02:00
parent b911a013e0
commit 732e5281a8
3 changed files with 20 additions and 2 deletions
+10
View File
@@ -28,6 +28,16 @@ addLock i t = do
padCorridors :: Tree [Annotation] -> Tree [Annotation]
padCorridors (Node x xs) = Node [Corridor] [Node x (map padCorridors xs)]
randomPadCorridors :: RandomGen g => Tree [Annotation] -> State g (Tree [Annotation])
randomPadCorridors (Node x xs) = do
n <- state $ randomR (1, 3)
xs' <- mapM randomPadCorridors xs
return $ treeTrunk (replicate n [Corridor]) (Node x xs')
annoToRoom :: RandomGen g => [Annotation] -> State g Room
annoToRoom [Corridor] = takeOne [corridor]
annoToRoom _ = randLinks $ roomRectAutoLinks 200 200
annoToRoom' :: [Annotation] -> Room
annoToRoom' [Corridor] = corridor
annoToRoom' _ = roomRectAutoLinks 200 200
+1 -1
View File
@@ -47,7 +47,7 @@ Randomly generate a small tree.
aTreeStrut :: RandomGen g => State g (Tree ())
aTreeStrut = do
d <- state $ randomR (9,11:: Int)
nbs <- state $ randomR (2,5)
nbs <- state $ randomR (2,4)
bds <- takeN nbs [1 .. d - 1]
bs <- replicateM nbs smallBranch
let trunk = treePath d