Fix bug not adding last positioned room to list
This commit is contained in:
@@ -34,6 +34,9 @@ safeHead :: [a] -> Maybe a
|
|||||||
safeHead (x:_) = Just x
|
safeHead (x:_) = Just x
|
||||||
safeHead _ = Nothing
|
safeHead _ = Nothing
|
||||||
|
|
||||||
|
errorHead :: String -> [a] -> a
|
||||||
|
errorHead _ (x:_) = x
|
||||||
|
errorHead s [] = error s
|
||||||
|
|
||||||
you :: World -> Creature
|
you :: World -> Creature
|
||||||
you w = _creatures w IM.! _yourID w
|
you w = _creatures w IM.! _yourID w
|
||||||
|
|||||||
+7
-6
@@ -47,12 +47,12 @@ initialAnoTree = padSucWithCorridors $ treeFromTrunk
|
|||||||
-- ]
|
-- ]
|
||||||
-- ]
|
-- ]
|
||||||
-- ,[SpecificRoom $ return $ connectRoom lasTunnel ]
|
-- ,[SpecificRoom $ return $ connectRoom lasTunnel ]
|
||||||
,[SpecificRoom $ fmap singleUseAll slowDoorRoom ]
|
-- ,[SpecificRoom $ fmap singleUseAll slowDoorRoom ]
|
||||||
,[Corridor]
|
-- ,[Corridor]
|
||||||
,[Corridor]
|
-- ,[Corridor]
|
||||||
,[SpecificRoom $ fmap singleUseAll roomCCrits]
|
-- ,[SpecificRoom $ fmap singleUseAll roomCCrits]
|
||||||
,[AirlockAno]
|
-- ,[AirlockAno]
|
||||||
,[Corridor]
|
-- ,[Corridor]
|
||||||
------ ,[SpecificRoom roomCCrits]
|
------ ,[SpecificRoom roomCCrits]
|
||||||
------ ,[Corridor]
|
------ ,[Corridor]
|
||||||
------ ,[SpecificRoom . pure . pure . UseAll $ roomGlassOctogon 400
|
------ ,[SpecificRoom . pure . pure . UseAll $ roomGlassOctogon 400
|
||||||
@@ -113,6 +113,7 @@ layoutLevelFromSeed i seed = do
|
|||||||
++ " attempt(s), Successful generation of level with seed "
|
++ " attempt(s), Successful generation of level with seed "
|
||||||
++ show seed
|
++ show seed
|
||||||
--return (fmap setLastLinkToUsed rs)
|
--return (fmap setLastLinkToUsed rs)
|
||||||
|
putStrLn $ show (Prelude.length rs) ++ " rooms in total"
|
||||||
return rs
|
return rs
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
putStr $ "Level generation with seed " ++ show seed ++ " failed: "
|
putStr $ "Level generation with seed " ++ show seed ++ " failed: "
|
||||||
|
|||||||
@@ -16,11 +16,14 @@ import Control.Monad.State
|
|||||||
lockRoomKeyItems :: RandomGen g => [ (Int -> State g (SubCompTree Room) , State g ItemIdentity ) ]
|
lockRoomKeyItems :: RandomGen g => [ (Int -> State g (SubCompTree Room) , State g ItemIdentity ) ]
|
||||||
lockRoomKeyItems =
|
lockRoomKeyItems =
|
||||||
[ (lasCenSensEdge, takeOne [Launcher] )
|
[ (lasCenSensEdge, takeOne [Launcher] )
|
||||||
|
-- , (const $ fmap singleUseAll slowDoorRoom, return MiniGun)
|
||||||
]
|
]
|
||||||
|
|
||||||
itemRooms :: RandomGen g => [(ItemIdentity, State g (SubCompTree Room))]
|
itemRooms :: RandomGen g => [(ItemIdentity, State g (SubCompTree Room))]
|
||||||
itemRooms =
|
itemRooms =
|
||||||
[ (Launcher , corridorBoss launcherCrit ) ]
|
[ (Launcher , corridorBoss launcherCrit )
|
||||||
|
-- , (MiniGun , join $ takeOne [roomMiniIntro, minigunFakeout] )
|
||||||
|
]
|
||||||
|
|
||||||
corridorBoss :: RandomGen g => Creature -> State g (SubCompTree Room)
|
corridorBoss :: RandomGen g => Creature -> State g (SubCompTree Room)
|
||||||
corridorBoss cr = do
|
corridorBoss cr = do
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ import Control.Lens
|
|||||||
import System.Random
|
import System.Random
|
||||||
--import qualified Data.IntMap.Strict as IM
|
--import qualified Data.IntMap.Strict as IM
|
||||||
|
|
||||||
minigunfakeout :: RandomGen g => State g (SubCompTree Room)
|
minigunFakeout :: RandomGen g => State g (SubCompTree Room)
|
||||||
minigunfakeout = do
|
minigunFakeout = do
|
||||||
rcol <- rezColor
|
rcol <- rezColor
|
||||||
ncor <- state $ randomR (0,2)
|
ncor <- state $ randomR (0,2)
|
||||||
roomwithmini <- randomiseAllLinks $ roomRectAutoLinks 150 150
|
roomwithmini <- randomiseAllLinks $ roomRectAutoLinks 150 150
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ module Dodge.Tree.Compose
|
|||||||
) where
|
) where
|
||||||
import Dodge.Tree.Compose.Data
|
import Dodge.Tree.Compose.Data
|
||||||
import Dodge.Tree.Polymorphic
|
import Dodge.Tree.Polymorphic
|
||||||
|
import Dodge.Base
|
||||||
import Data.Tree
|
import Data.Tree
|
||||||
|
|
||||||
expandTree :: CompTree a -> Tree a
|
expandTree :: CompTree a -> Tree a
|
||||||
@@ -24,7 +25,8 @@ expandTree (Node root extChildren) = case root of
|
|||||||
$ map (:[]) extChildren ++ repeat []
|
$ map (:[]) extChildren ++ repeat []
|
||||||
|
|
||||||
overwriteLabel :: Int -> (a -> ComposingNode a) -> SubCompTree a -> [SubCompTree a] -> SubCompTree a
|
overwriteLabel :: Int -> (a -> ComposingNode a) -> SubCompTree a -> [SubCompTree a] -> SubCompTree a
|
||||||
overwriteLabel i f t ts = head $ updateSingleNode islabel update t
|
overwriteLabel i f t ts = errorHead ("tried to overwriteLabel " ++ show i)
|
||||||
|
$ updateSingleNode islabel update t
|
||||||
where
|
where
|
||||||
islabel (UseLabel j _) | i == j = True
|
islabel (UseLabel j _) | i == j = True
|
||||||
islabel _ = False
|
islabel _ = False
|
||||||
|
|||||||
+13
-10
@@ -29,16 +29,13 @@ posRms :: [ConvexPoly]
|
|||||||
-> Seq (Tree RoomInt)
|
-> Seq (Tree RoomInt)
|
||||||
-> IO (Maybe [Room])
|
-> IO (Maybe [Room])
|
||||||
posRms bounds (parent,_) _ [] st = case st of
|
posRms bounds (parent,_) _ [] st = case st of
|
||||||
Empty -> return $ Just []
|
Empty -> return $ Just [parent]
|
||||||
Node childi ts :<| tseq
|
Node childi ts :<| tseq
|
||||||
-> fmap (finalLinksUpdate parent:) <$> posRms bounds childi 0 ts tseq
|
-> fmap (finalLinksUpdate parent:) <$> posRms bounds childi 0 ts tseq
|
||||||
posRms bounds parenti@(pr,i) numChild (t@(Node (cr,i') _):ts) tseq = do
|
posRms bounds parenti numChild (t@(Node childi _):ts) tseq = do
|
||||||
putStr $ rpns 20 (_rmName cr ++ "-" ++ show i')
|
printInfo parenti numChild childi
|
||||||
++ rpns 9 (" child " ++ show numChild )
|
|
||||||
++ rpns 25 (" of " ++ _rmName pr ++ "-" ++ show i )
|
|
||||||
tryLinks (0::Int) (init $ _rmLinks parent)
|
tryLinks (0::Int) (init $ _rmLinks parent)
|
||||||
where
|
where
|
||||||
rpns x s = rightPadNoSquash x ' ' s
|
|
||||||
parent = fst parenti
|
parent = fst parenti
|
||||||
tryLinks _ [] = putStrLn "all links tried" >> return Nothing
|
tryLinks _ [] = putStrLn "all links tried" >> return Nothing
|
||||||
tryLinks j (l:ls)
|
tryLinks j (l:ls)
|
||||||
@@ -48,11 +45,9 @@ posRms bounds parenti@(pr,i) numChild (t@(Node (cr,i') _):ts) tseq = do
|
|||||||
mayrs <- posRms (convexBounds ++ bounds)
|
mayrs <- posRms (convexBounds ++ bounds)
|
||||||
(first upr parenti) (numChild + 1) ts (tseq |> shiftedt)
|
(first upr parenti) (numChild + 1) ts (tseq |> shiftedt)
|
||||||
case mayrs of
|
case mayrs of
|
||||||
--Nothing -> putStr ("Backtracking to room " ++ show i' ++ ": ") >> tryLinks (j+1) ls
|
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
putStr $ "Backtracking to " ++ rpns 20 (_rmName cr ++ "-" ++ show i')
|
putStr "Backtrack: "
|
||||||
++ rpns 9 (" child " ++ show numChild )
|
printInfo parenti numChild childi
|
||||||
++ rpns 25 (" of " ++ _rmName pr ++ "-" ++ show i )
|
|
||||||
tryLinks (j+1) ls
|
tryLinks (j+1) ls
|
||||||
Just rs -> return (Just rs)
|
Just rs -> return (Just rs)
|
||||||
where
|
where
|
||||||
@@ -63,6 +58,14 @@ posRms bounds parenti@(pr,i) numChild (t@(Node (cr,i') _):ts) tseq = do
|
|||||||
r' = doRoomShift . fst $ rootLabel shiftedt
|
r' = doRoomShift . fst $ rootLabel shiftedt
|
||||||
shiftedt = applyToRoot (first $ shiftRoomShiftToLink l') t
|
shiftedt = applyToRoot (first $ shiftRoomShiftToLink l') t
|
||||||
|
|
||||||
|
printInfo :: RoomInt -> Int -> RoomInt -> IO ()
|
||||||
|
printInfo (parentrm,parenti) childn (childrm,childi) = do
|
||||||
|
putStr $ rpns 20 (_rmName childrm ++ "-" ++ show childi)
|
||||||
|
++ rpns 9 (" child " ++ show childn )
|
||||||
|
++ rpns 25 (" of " ++ _rmName parentrm ++ "-" ++ show parenti )
|
||||||
|
where
|
||||||
|
rpns x s = rightPadNoSquash x ' ' s
|
||||||
|
|
||||||
doLnkEff :: (Point2,Float) -> Room -> Room
|
doLnkEff :: (Point2,Float) -> Room -> Room
|
||||||
doLnkEff x rm = case _rmLinkEff rm of
|
doLnkEff x rm = case _rmLinkEff rm of
|
||||||
(eff:effs) -> eff x $ rm & rmLinkEff .~ effs
|
(eff:effs) -> eff x $ rm & rmLinkEff .~ effs
|
||||||
|
|||||||
Reference in New Issue
Block a user