Implement terminals
This commit is contained in:
+24
-16
@@ -8,6 +8,7 @@ module Dodge.PlacementSpot
|
||||
, anyUnusedSpot
|
||||
, unusedSpotAwayFromLink
|
||||
, isUnusedLnk
|
||||
, isUnusedLnk'
|
||||
, isInLnk
|
||||
, unusedSpotNearInLink
|
||||
, randDirPS
|
||||
@@ -21,7 +22,7 @@ module Dodge.PlacementSpot
|
||||
, twoRoomPoss
|
||||
, isUnusedLinkType
|
||||
, rprBoolShift
|
||||
, rpBool
|
||||
, rprBool
|
||||
, shiftInBy
|
||||
, resetPLUse
|
||||
) where
|
||||
@@ -47,11 +48,18 @@ randDirPS ps = do
|
||||
a <- state $ randomR (0,pi*2)
|
||||
return $ setDirPS a ps
|
||||
|
||||
rpBool :: (RoomPos -> Bool) -> PlacementSpot
|
||||
rpBool t = PSPos (useRoomPosCond t) (const id) Nothing
|
||||
isUnusedLnk :: RoomPos -> Room -> Bool
|
||||
isUnusedLnk rp _ = case _rpLinkStatus rp of
|
||||
UnusedLink {} -> _rpPlacementUse rp == 0
|
||||
_ -> False
|
||||
|
||||
isUnusedLnk' :: RoomPos -> Bool
|
||||
isUnusedLnk' rp = case _rpLinkStatus rp of
|
||||
UnusedLink {} -> _rpPlacementUse rp == 0
|
||||
_ -> False
|
||||
|
||||
anyUnusedSpot :: PlacementSpot
|
||||
anyUnusedSpot = rpBool $ \rp -> _rpLinkStatus rp == NotLink && _rpPlacementUse rp == 0
|
||||
anyUnusedSpot = rprBool $ \rp _ -> _rpLinkStatus rp == NotLink && _rpPlacementUse rp == 0
|
||||
|
||||
rprBool :: (RoomPos -> Room -> Bool) -> PlacementSpot
|
||||
rprBool t = PSPos (useRoomPosRoomCond t) (const id) Nothing
|
||||
@@ -98,18 +106,18 @@ unusedSpotAwayFromInLink x = rprBool $ \rp r -> _rpLinkStatus rp == NotLink
|
||||
--twoUnusedLinks :: (PlacementSpot -> PlacementSpot -> Placement) -> Placement
|
||||
--twoUnusedLinks = twoRoomPoss isUnusedLnk isUnusedLnk
|
||||
|
||||
twoRoomPoss :: (RoomPos -> Bool)
|
||||
-> (RoomPos -> Bool)
|
||||
twoRoomPoss :: (RoomPos -> Room -> Bool)
|
||||
-> (RoomPos -> Room -> Bool)
|
||||
-> (PlacementSpot -> PlacementSpot -> Placement)
|
||||
-> Placement
|
||||
twoRoomPoss cond1 cond2 f = Placement (rpBool cond1) PutNothing Nothing
|
||||
$ \pl1 -> Just $ Placement (rpBool cond2) PutNothing Nothing
|
||||
twoRoomPoss cond1 cond2 f = Placement (rprBool cond1) PutNothing Nothing
|
||||
$ \pl1 -> Just $ Placement (rprBool cond2) PutNothing Nothing
|
||||
$ \pl2 -> Just $ f (_plSpot pl1) (_plSpot pl2)
|
||||
|
||||
isUnusedLnk :: RoomPos -> Bool
|
||||
isUnusedLnk rp = case _rpLinkStatus rp of
|
||||
UnusedLink {} -> _rpPlacementUse rp == 0
|
||||
_ -> False
|
||||
--isUnusedLnk :: RoomPos -> Bool
|
||||
--isUnusedLnk rp = case _rpLinkStatus rp of
|
||||
-- UnusedLink {} -> _rpPlacementUse rp == 0
|
||||
-- _ -> False
|
||||
|
||||
isInLnk :: RoomPos -> Bool
|
||||
isInLnk rp = case _rpLinkStatus rp of
|
||||
@@ -117,7 +125,7 @@ isInLnk rp = case _rpLinkStatus rp of
|
||||
_ -> False
|
||||
|
||||
useUnusedLnk :: PlacementSpot
|
||||
useUnusedLnk = rpBool isUnusedLnk
|
||||
useUnusedLnk = rprBool isUnusedLnk
|
||||
|
||||
isUsedLnkUnplaced :: RoomPos -> Bool
|
||||
isUsedLnkUnplaced rp = case _rpLinkStatus rp of
|
||||
@@ -125,8 +133,8 @@ isUsedLnkUnplaced rp = case _rpLinkStatus rp of
|
||||
UsedInLink {} -> _rpPlacementUse rp == 0
|
||||
_ -> False
|
||||
|
||||
useRoomPosCond :: (RoomPos -> Bool) -> RoomPos -> Room -> Maybe (PlacementSpot,RoomPos)
|
||||
useRoomPosCond f = useRoomPosRoomCond $ \rp _ -> f rp
|
||||
useRoomPosCond :: (RoomPos -> Room -> Bool) -> RoomPos -> Room -> Maybe (PlacementSpot,RoomPos)
|
||||
useRoomPosCond f = useRoomPosRoomCond $ \rp r -> f rp r
|
||||
|
||||
useRoomPosRoomCond :: (RoomPos -> Room -> Bool) -> RoomPos -> Room -> Maybe (PlacementSpot,RoomPos)
|
||||
useRoomPosRoomCond t rp r
|
||||
@@ -159,7 +167,7 @@ usedRoomLinkPoss r = mapMaybe f $ _rmPos r
|
||||
_ -> Nothing
|
||||
|
||||
atFstLnkOut :: PlacementSpot
|
||||
atFstLnkOut = rpBool $ \rp -> rp ^? rpLinkStatus . rplsChildNum == Just 0
|
||||
atFstLnkOut = rprBool $ \rp _ -> rp ^? rpLinkStatus . rplsChildNum == Just 0
|
||||
|
||||
atNthLnkOutShiftBy :: Int -> ((Point2,Float) -> (Point2,Float)) -> PlacementSpot
|
||||
atNthLnkOutShiftBy n = rprBoolShift
|
||||
|
||||
Reference in New Issue
Block a user