Random tree structure generation of rooms

This commit is contained in:
2021-04-20 02:01:24 +02:00
parent 38d67520cc
commit b911a013e0
14 changed files with 407 additions and 235 deletions
+11 -2
View File
@@ -5,6 +5,10 @@ module Dodge.Layout.Tree.Annotate
where
import Dodge.RandomHelp
import Dodge.Layout.Tree.Polymorphic
import Dodge.Room.Procedural
import Dodge.Room.Link
import Dodge.Room.Data
import Dodge.Room
import Data.Tree
import Control.Monad.State
@@ -13,6 +17,7 @@ import System.Random
data Annotation
= Lock Int
| Key Int
| Corridor
addLock :: RandomGen g => Int -> Tree [Annotation] -> State g (Tree [Annotation])
addLock i t = do
@@ -20,5 +25,9 @@ addLock i t = do
newBefore <- applyToRandomNode (Key i :) beforeLock
return $ addToTrunk newBefore [Node [Lock i] afterLock]
--annoToRoom :: RandomGen g => [Annotation] -> State g (Either Room Room)
--annoToRoom as = undefined
padCorridors :: Tree [Annotation] -> Tree [Annotation]
padCorridors (Node x xs) = Node [Corridor] [Node x (map padCorridors xs)]
annoToRoom :: RandomGen g => [Annotation] -> State g Room
annoToRoom [Corridor] = takeOne [corridor]
annoToRoom _ = randLinks $ roomRectAutoLinks 200 200