diff --git a/examples/configs/Task11.hs b/examples/configs/Task11.hs index f153fd3..025794c 100644 --- a/examples/configs/Task11.hs +++ b/examples/configs/Task11.hs @@ -288,7 +288,7 @@ test = oneOf (\p -> hasRelation (p `isLeftOf` p)) eggChoices <||> oneOf (\p -> hasRelation (p `isRightOf` p)) eggChoices complain "Eggs are above the grass?" $ - oneOf (\p -> hasRelation (p `isAbove` grass)) (take 3 eggChoices) <||> + oneOf (\p -> hasRelation (p `isAbove` grass)) eggChoices <||> hasRelation (polyEggThick `atSamePosition` grass) complain "Cannot detect movement. Make sure you are not ignoring parameter 't'." @@ -369,7 +369,8 @@ test = fromMaybe 0 (getExactCircleRadius normalized) , x == 0 , isEgg normalized - , abs (y - eggSize) <= eggSize*0.5 + , abs (y - eggSize) <= eggSize*0.5 || + any (normalized `contains`) curveEggs ] diff --git a/src/CodeWorld/Test/AbstractHelpers.hs b/src/CodeWorld/Test/AbstractHelpers.hs index 9e67014..fe7c0b4 100644 --- a/src/CodeWorld/Test/AbstractHelpers.hs +++ b/src/CodeWorld/Test/AbstractHelpers.hs @@ -158,15 +158,15 @@ largerY = reNormalize $ scaled 1 2 Draw an abstract, open curve with this many segments. -} someCurve :: Int -> AbstractPicture -someCurve points = normalizeAndAbstract $ - curve $ take (points+1) $ iterate (both (+0.1)) (1,0) +someCurve segments = normalizeAndAbstract $ + curve $ take (segments+1) $ iterate (both (+0.1)) (1,0) {- | Draw an abstract, filled in and closed curve with this many segments. -} someSolidCurve :: Int -> AbstractPicture -someSolidCurve points = normalizeAndAbstract $ - solidClosedCurve $ take (points+1) $ iterate (both (+0.1)) (1,0) +someSolidCurve segments = normalizeAndAbstract $ + solidClosedCurve $ take segments $ iterate (both (+0.1)) (1,0) {- | Compose two abstract pictures. diff --git a/src/CodeWorld/Test/Rewrite.hs b/src/CodeWorld/Test/Rewrite.hs index adb4fc2..b4d6a3b 100644 --- a/src/CodeWorld/Test/Rewrite.hs +++ b/src/CodeWorld/Test/Rewrite.hs @@ -10,7 +10,7 @@ module CodeWorld.Test.Rewrite ( import Data.Fixed (mod') import Data.Generics.Uniplate.Data (rewrite) -import Data.List.Extra (sort, takeEnd) +import Data.List.Extra (sort, takeEnd, dropEnd) import CodeWorld.Tasks.Color (black) import CodeWorld.Tasks.VectorSpace ( @@ -84,10 +84,12 @@ rewriting (AnyRectangle s l w) = toWideRectangle s l w rewriting (AnyArc s a1 a2 r) = checkArc s a1 a2 r rewriting (AnyPolyline (Closed (Outline mOutline)) ps) = AnyPolyline (Open mOutline) $ toOpenShape ps -rewriting (AnyPolyline s (removeSurplus -> ps)) = checkForRectangle s $ toOpenShape ps +rewriting (AnyPolyline s (removeSurplus -> ps)) = checkForRectangle s $ case s of + Closed Solid -> toOpenShape ps + Open _ -> ps rewriting (AnyCurve (Closed (Outline mOutline)) ps) = AnyCurve (Open mOutline) $ toOpenShape ps -rewriting (AnyCurve s ps) = handlePointList (AnyCurve s) $ toOpenShape ps +rewriting (AnyCurve s ps) = handlePointList (AnyCurve s) ps rewriting (Lettering "") = Blank rewriting (StyledLettering _ _ "") = Blank @@ -261,7 +263,9 @@ handleLikeFreeShapes s1 ps1 ps2 checkForRectangle :: Shape -> [Point] -> Picture checkForRectangle shape ps = case pointsToRectangle shape ps of - Nothing -> handlePointList (AnyPolyline shape) ps + Nothing -> handlePointList (AnyPolyline shape) $ case shape of + Closed Solid -> dropEnd 1 ps + _ -> ps Just r -> r pointsToRectangle :: Shape -> [Point] -> Maybe Picture