From 8ff18178b182a95e021dc361a4ee49a597ffbc57 Mon Sep 17 00:00:00 2001 From: justin Date: Tue, 8 Mar 2022 23:19:14 +0000 Subject: [PATCH] Example use of fallback in placement room positions --- src/Dodge/PlacementSpot.hs | 5 +++++ src/Dodge/Room/Tanks.hs | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Dodge/PlacementSpot.hs b/src/Dodge/PlacementSpot.hs index fcf12f295..3b5e9073d 100644 --- a/src/Dodge/PlacementSpot.hs +++ b/src/Dodge/PlacementSpot.hs @@ -37,6 +37,11 @@ unusedSpotAwayFromLink x = PSPos f (const id) Nothing -> Just (PS p a,UsedSpot p a t) _ -> Nothing +setFallback :: Placement -> Placement -> Placement +setFallback fallback plmnt = plmnt + & plSpot . psFallback .~ Just fallback + & plIDCont %~ fmap (fmap $ setFallback fallback) + unusedOffPathAwayFromLink :: Float -> PlacementSpot unusedOffPathAwayFromLink x = PSPos f (const id) Nothing where diff --git a/src/Dodge/Room/Tanks.hs b/src/Dodge/Room/Tanks.hs index 0ab55775d..1bd583af8 100644 --- a/src/Dodge/Room/Tanks.hs +++ b/src/Dodge/Room/Tanks.hs @@ -36,12 +36,14 @@ tanksRoom crs its = do thetank <- randomTank <&> plSpot .~ unusedOffPathAwayFromLink 50 let room = roomRectAutoLinks w h nwestlnks = length $ filter ((OnEdge West `S.member`) . _rlType) $ _rmLinks room + girderPosOrder <- shuffle [1 .. nwestlnks - 2] let plmnts = - --[ twoRoomPoss (isUnusedLinkType (OnEdge West)) (isUnusedLinkType (OnEdge East)) $ \ps1 ps2 -> - [ twoRoomPoss (isUnusedLinkType (FromSouth i)) (isUnusedLinkType (FromSouth i)) $ \ps1 ps2 -> + --ok, this has become complicated + foldr1 setFallback [ twoRoomPoss (isUnusedLinkType (FromSouth i)) + (isUnusedLinkType (FromSouth i)) $ \ps1 ps2 -> sps0 $ PutShape $ girderV 96 20 10 (_psPos ps1) (_psPos ps2) - | i <- [1 .. nwestlnks - 2]] - ++ map (\it -> sps0 (PutFlIt it) & plSpot .~ anyUnusedSpot) its + | i <- girderPosOrder] + : map (\it -> sps0 (PutFlIt it) & plSpot .~ anyUnusedSpot) its ++ map (\cr -> sps0 (PutCrit cr) & plSpot .~ unusedSpotAwayFromLink 50) crs ++ replicate ntanks thetank -- , sps0 $ PutShape $ colorSH orange $ pipePP 2 (V3 50 50 25) (V3 50 120 25)