diff --git a/data/scenarios/Challenges/Ranching/_gated-paddock/bridged-gap.sw b/data/scenarios/Challenges/Ranching/_gated-paddock/bridged-gap.sw deleted file mode 100644 index 211e2d771e..0000000000 --- a/data/scenarios/Challenges/Ranching/_gated-paddock/bridged-gap.sw +++ /dev/null @@ -1,115 +0,0 @@ -def isFenced = s <- scan forward; return (case s (\_. false) (\x. x == "gate")); end; -def isBlockedOrFenced = b <- blocked; f <- isFenced; return (b || f); end; -def boolToInt = \b. if (b) {return 1} {return 0}; end; - -/** If one is standing on a fence, that means the fence has just been placed, -because it is not possible to move onto a fence that already exists. -We then inspect the 8 surrounding tiles. If at least two of them are "blocked" -or are a "gate", then we know that we have just closed a gap. -It may not have been that final gap, but it's a good time to run the full -enclosure test. - -Invoke as follows: - - countAdjacentBlockagesBroken 4 - -FIXME: This has VERY strange behavior. -The values of 'recVal' and 'total' are often inconsistent. -*/ -def countAdjacentBlockagesBroken = \i. - if (i > 0) { - turn left; - say "======"; - say $ format i; - say "------"; - amBlocked <- isBlockedOrFenced; - - say $ "amBlocked: " ++ format amBlocked; - - val <- boolToInt amBlocked; - say $ "val:" ++ format val; - recVal <- countAdjacentBlockagesBroken (i - 1); - - say $ "recVal: " ++ format recVal; - - let total = val + recVal in - say $ "total: " ++ format total; - return total; - } { - return 0; - }; - end; - - -def countAdjacentBlockages = - - turn left; - b1 <- isBlockedOrFenced; - c1 <- boolToInt b1; - - turn left; - b2 <- isBlockedOrFenced; - c2 <- boolToInt b2; - - turn left; - b3 <- isBlockedOrFenced; - c3 <- boolToInt b3; - - turn left; - b4 <- isBlockedOrFenced; - c4 <- boolToInt b4; - - return $ c1 + c2 + c3 + c4; - end; - -// Step forward, observing left and right. -def observeLeftAndRight = - move; - turn left; - amBlockedLeft <- isBlockedOrFenced; - val1 <- boolToInt amBlockedLeft; - - turn back; - amBlockedRight <- isBlockedOrFenced; - val2 <- boolToInt amBlockedRight; - - turn right; - move; - return $ val1 + val2; - end; - - -/** If the four cardinal directions have at most -one blockage, then there will exist an orientation -where both that direction and its opposite direction -are clear. -So we can step that direction, check to the left and -right of us, then step in the opposite direction -and do the same. This allows us to check the 4 -blocks that touch the corners of the center block. -*/ -def countDiagonalBlockages = - // First, orient to the clear front-to-back path - amBlocked <- isBlockedOrFenced; - if amBlocked {turn left;} {}; - - // Second, step to both sides - fwdCount <- observeLeftAndRight; - backCount <- observeLeftAndRight; - return $ fwdCount + backCount; - end; - -def isStandingOnBridge = - onFence <- ishere "fence"; - if (onFence) { - adjCount <- countAdjacentBlockages; - if (adjCount > 1) { - return true; - } { - diagCount <- countDiagonalBlockages; - return $ (adjCount + diagCount) > 1; - }; - } {return false}; - end; - -isStandingOnBridge; \ No newline at end of file