$\footnotesize{\color{white}{\mathsf{\textbf{B}}}}$

$\footnotesize{\bgcolor{#E2DFF8}{\mathbf{%v}}}$

$\footnotesize{\color{white}{{\mathsf{\textbf{A}}}}}$

#4D4D4D

$\text{NEW MAP}$

Reset app

#006758

#B00020

#252525

#757575

#949494

#E44461

#DA2570

#E66B9E

#3A6ED6

#5991FF

#008475

#0F8538

#00a83c

#5145A8

#6557D2

#8575FF

#903D14

#BD6C43

#C75000

#E07415

#eeeeee

#2E006758

#2EB00020

$\bgcolor{#E2DFF8}{\mathbf{%v}}$

%v

x

y

$%v$

$\text{RESET MAP}$

\text{No more moves. 
Reset the map}

A

B

setup

allRandoms = RandomUniform(0, 0.99, 200)
numRandoms: 10
listXSequence = Sequence(1, 11)
countQuestion = 0
randIndex: (Mod[countQuestion, floor(Length[allRandoms] / numRandoms)] * numRandoms) + 1
currentRandomSeeds = Take(allRandoms, randIndex, randIndex + numRandoms - 1)
x1 = If(countQuestion ≟ 0, 7, Element[listXSequence, 1 + floor((currentRandomSeeds(1) * 11))])
listXSequence1: listXSequence \ {x1}
x2 = Element(listXSequence1, 1 + floor((currentRandomSeeds(2) * 10)))
listXSequence2: listXSequence1 \ {x2}
x3 = Element(listXSequence2, 1 + floor((currentRandomSeeds(3) * 9)))
randomVerticals: {x1, x2, x3}
listYSequence = Sequence(1, 8)
y1 = If(countQuestion ≟ 0, 1, Element[listYSequence, 1 + floor((currentRandomSeeds(4) * 8))])
listYSequence1: listYSequence \ {y1}
y2 = Element(listYSequence1, 1 + floor((currentRandomSeeds(5) * 7)))
listYSequence2: listYSequence1 \ {y2}
y3 = Element(listYSequence2, 1 + floor((currentRandomSeeds(6) * 6)))
randomHorizontals: {y1, y2, y3}
stop1Choices = KeepIf(n > 0 ∧ n ≠ randomVerticals(1) ∧ n ≠ randomVerticals(2) ∧ n ≠ randomVerticals(3), n, Sequence[1, 11])
randomStops: (randomVerticals, randomHorizontals)
PointStop1Start = Element(randomStops, Mod[countQuestion, Length[randomStops]] + 1)
PointStop2Start = Element(randomStops, Mod[countQuestion + 1, Length[randomStops]] + 1)
stop2Choices = KeepIf(n > 0 ∧ (n < randomHorizontals(1) - 2 ∨ n > randomHorizontals(1)) ∧ (n < randomHorizontals(2) - 2 ∨ n > randomHorizontals(2)) ∧ (n < randomHorizontals(3) - 2 ∨ n > randomHorizontals(3)), n, Sequence[1, 9])
pulsing = 2.11 (slider from 0 to 3, step 0.01)
streetsHorizontal = Zip(Segment[(0.1, n), (12.4, n)], n, randomHorizontals)
PointRandomStop2: (x(PointStop2Start), stop2Choices(Mod[y(PointStop2Start), Length[stop2Choices]] + 1))
streetsVertical = Zip(Segment[(n, 0.1), (n, 9.4)], n, randomVerticals)
intersections = Flatten({Sequence[Sequence[Intersect[streetsHorizontal(n), streetsVertical(k)], n, 1, 3], k, 1, 3], PointRandomStop2})
startOctOuter = Zip(n - (0.17, 0.17 / tan(22.5°)), n, intersections)
startOct = Zip(n - (0.15, 0.15 / tan(22.5°)), n, intersections)
textPaths: {}
numClicks = 0
numCol1 = If(numClicks < 10, Mod[numClicks, 10], 10)
PointStart: (7, 1)
sameYBelow = KeepIf(y(n) ≟ y(PointStart) ∧ x(n) < x(PointStart), n, intersections)
sameXBelow = KeepIf(x(n) ≟ x(PointStart) ∧ y(n) < y(PointStart), n, intersections)
sameYAbove = KeepIf(y(n) ≟ y(PointStart) ∧ x(n) > x(PointStart), n, intersections)
sameXAbove = KeepIf(x(n) ≟ x(PointStart) ∧ y(n) > y(PointStart), n, intersections)
PointStartAnimation: (7, 1)
validPoints = RemoveUndefined({ClosestPoint[sameYAbove, PointStartAnimation], ClosestPoint[sameYBelow, PointStartAnimation], ClosestPoint[sameXAbove, PointStartAnimation], ClosestPoint[sameXBelow, PointStartAnimation]})
MoveToPoint: (7, 1)
destinationReached: MoveToPoint ≟ PointRandomStop2
destinationError: numClicks ≥ 10 ∧ (¬destinationReached)
startOctInner = Zip(n - (0.13, 0.13 / tan(22.5°)), n, intersections)
animationSlider = 0 (slider from 0 to animationRange, step 0.01)
PointRandomStop1 = If(countQuestion ≟ 0, (7, 1), (stop1Choices(Mod[x(PointStop1Start), Length[stop1Choices]] + 1), y(PointStop1Start)))
numHorizontalDistance: abs(x(MoveToPoint) - x(PointStartAnimation))
showbuttons = true
pixelsRight: 16
pixelsLeft: 16
pixelsBottom: 16
pixelsTop: 24
borderBox = Polygon(Zip[PixelsToPoint[Corner[1], Corner[3], Corner[5], A], A, {(pixelsLeft, pixelsTop), (pixelsLeft, y(Corner[5]) - pixelsBottom), Corner[5] - (pixelsRight, pixelsBottom), (x(Corner[5]) - pixelsRight, pixelsTop)}])
Dims = Corner(5)
mapArea = Polygon({(-1, -1), (-1, 9.5), (12.5, 9.5), (12.5, -1)})
xAxisLine = Segment((0, 0), (12.5, 0))
yAxisLine = Segment((0, 0), (0, 9.5))
mapBackground = Polygon({(0.01, 0.01), (0.01, 9.5), (12.5, 9.5), (12.5, 0.01)})
numVerticalDistance: abs(y(MoveToPoint) - y(PointStartAnimation))
animationRange = If(Distance[MoveToPoint, PointStartAnimation] ≟ 0, 0.5, Distance[MoveToPoint, PointStartAnimation])
horizontalDirection = If(x(MoveToPoint) - x(PointStartAnimation) < 0, "left", x(MoveToPoint) - x(PointStartAnimation) > 0, "right", "horizontally")
verticalDirection = If(y(MoveToPoint) - y(PointStartAnimation) < 0, "down", y(MoveToPoint) - y(PointStartAnimation) > 0, "up", "vertically")
showText: numClicks > 0
PointFirstAnimation = PartitionPoint(PointStartAnimation, MoveToPoint, animationSlider, animationRange)
segmentAnimation1 = Segment(PointStartAnimation, PointFirstAnimation)
segmentHorizontal = Segment((x(PointStartAnimation), -1), (x(PointFirstAnimation), -1))
segmentBackground1: segmentAnimation1
stopSignLine1 = Polygon(startOct(1), startOct(1) + (0.3, 0), 8)
stopSignLine2 = Polygon(startOct(2), startOct(2) + (0.3, 0), 8)
stopSignLine3 = Polygon(startOct(3), startOct(3) + (0.3, 0), 8)
stopSignLine4 = Polygon(startOct(4), startOct(4) + (0.3, 0), 8)
stopSignLine5 = Polygon(startOct(5), startOct(5) + (0.3, 0), 8)
stopSignLine6 = Polygon(startOct(6), startOct(6) + (0.3, 0), 8)
stopSignLine7 = Polygon(startOct(7), startOct(7) + (0.3, 0), 8)
stopSignLine8 = Polygon(startOct(8), startOct(8) + (0.3, 0), 8)
stopSignLine9 = Polygon(startOct(9), startOct(9) + (0.3, 0), 8)
stopSign1 = Polygon(startOctInner(1), startOctInner(1) + (0.26, 0), 8)
stopSign2 = Polygon(startOctInner(2), startOctInner(2) + (0.26, 0), 8)
stopSign3 = Polygon(startOctInner(3), startOctInner(3) + (0.26, 0), 8)
stopSign4 = Polygon(startOctInner(4), startOctInner(4) + (0.26, 0), 8)
stopSign5 = Polygon(startOctInner(5), startOctInner(5) + (0.26, 0), 8)
stopSign6 = Polygon(startOctInner(6), startOctInner(6) + (0.26, 0), 8)
stopSign7 = Polygon(startOctInner(7), startOctInner(7) + (0.26, 0), 8)
stopSign8 = Polygon(startOctInner(8), startOctInner(8) + (0.26, 0), 8)
stopSign9 = Polygon(startOctInner(9), startOctInner(9) + (0.26, 0), 8)
travelPath: {}
travelSegments = Zip(Segment[F, G], F, Append[PointRandomStop1, First[travelPath, Length[travelPath] - 1]], G, travelPath)
showPath = First(travelSegments, numClicks - 1)
showPathWhite = First(travelSegments, numClicks - 1)
numDistance = Sum(Flatten[travelSegments])
stopNum = 0
boolIntersect = Zip(n ∈ validPoints ∧ (¬destinationReached) ∧ (¬destinationError), n, intersections)
numLabel: floor(segmentAnimation1)
textVerticalPath: "" + (LaTeX[numVerticalDistance]) + " block" + (LaTeX[If[numVerticalDistance > 1, "s", ""]]) + " " + (LaTeX[verticalDirection]) + ""
textHorizontalPath: "" + (LaTeX[numHorizontalDistance]) + " block" + (LaTeX[If[numHorizontalDistance ≟ 1, "", "s"]]) + " " + (LaTeX[horizontalDirection]) + ""
directionVertical: numVerticalDistance > 0
directionHorizontal: numHorizontalDistance > 0
textLabel: " " + (LaTeX[numLabel]) + ""
segmentVertical = Segment((-1, y(PointStartAnimation)), (-1, y(PointFirstAnimation)))
currentSegments = Segment(PointStartAnimation, MoveToPoint)
speed: 25 / animationRange
textComplete: "\text{" + (LaTeX[If[destinationReached, "\color{" + colorTealSuccess + "}{Destination reached!}", destinationError, "\color{" + colorRedError + "}{" + textError + "}", ""]]) + "}"
stopSignLine1a = Polygon(startOctOuter(1), startOctOuter(1) + (0.34, 0), 8)
stopSignLine2a = Polygon(startOctOuter(2), startOctOuter(2) + (0.34, 0), 8)
stopSignLine3a = Polygon(startOctOuter(3), startOctOuter(3) + (0.34, 0), 8)
stopSignLine4a = Polygon(startOctOuter(4), startOctOuter(4) + (0.34, 0), 8)
stopSignLine5a = Polygon(startOctOuter(5), startOctOuter(5) + (0.34, 0), 8)
stopSignLine6a = Polygon(startOctOuter(6), startOctOuter(6) + (0.34, 0), 8)
stopSignLine7a = Polygon(startOctOuter(7), startOctOuter(7) + (0.34, 0), 8)
stopSignLine8a = Polygon(startOctOuter(8), startOctOuter(8) + (0.34, 0), 8)
stopSignLine9a = Polygon(startOctOuter(9), startOctOuter(9) + (0.34, 0), 8)
activeSegs = Zip(Segment[MoveToPoint, n], n, validPoints)
boolCurrent = Zip(n ≟ PointFirstAnimation, n, intersections)
segmentStop1 = Segment(PointRandomStop1, PointRandomStop1 + (0, 0.3))
segmentStop2 = Segment(PointRandomStop2, PointRandomStop2 + (0, 0.3))
busStop2_{1}, busStop2_{2}, busStop2_{3}, busStop2_{4}, busStop2_{5} = busStopN(PointRandomStop2 + (0, 0.65))
busStop1_{1}, busStop1_{2}, busStop1_{3}, busStop1_{4}, busStop1_{5} = busStopN(PointRandomStop1 + (0, 0.65))
shake(x) = (0.5 * sin(((5 * pi) * x)) / ℯ^(x))
animationSlider1 = If(pulsing < 1 ∨ pulsing > 2, 0, pulsing ≤ 2, pulsing - 1)
stopSign1ShakeA = Rotate(stopSign1, shake(animationSlider1), intersections(1))
stopSign2ShakeA = Rotate(stopSign2, shake(animationSlider1), intersections(2))
stopSign3ShakeA = Rotate(stopSign3, shake(animationSlider1), intersections(3))
stopSign4ShakeA = Rotate(stopSign4, shake(animationSlider1), intersections(4))
stopSign5ShakeA = Rotate(stopSign5, shake(animationSlider1), intersections(5))
stopSign6ShakeA = Rotate(stopSign6, shake(animationSlider1), intersections(6))
stopSign7ShakeA = Rotate(stopSign7, shake(animationSlider1), intersections(7))
stopSign8ShakeA = Rotate(stopSign8, shake(animationSlider1), intersections(8))
stopSign9ShakeA = Rotate(stopSign9, shake(animationSlider1), intersections(9))
stopSign1ShakeB = Rotate(stopSignLine1, shake(animationSlider1), intersections(1))
stopSign2ShakeB = Rotate(stopSignLine2, shake(animationSlider1), intersections(2))
stopSign3ShakeB = Rotate(stopSignLine3, shake(animationSlider1), intersections(3))
stopSign4ShakeB = Rotate(stopSignLine4, shake(animationSlider1), intersections(4))
stopSign5ShakeB = Rotate(stopSignLine5, shake(animationSlider1), intersections(5))
stopSign6ShakeB = Rotate(stopSignLine6, shake(animationSlider1), intersections(6))
stopSign7ShakeB = Rotate(stopSignLine7, shake(animationSlider1), intersections(7))
stopSign8ShakeB = Rotate(stopSignLine8, shake(animationSlider1), intersections(8))
stopSign9ShakeB = Rotate(stopSignLine9, shake(animationSlider1), intersections(9))
stopSign1ShakeC = Rotate(stopSignLine1a, shake(animationSlider1), intersections(1))
stopSign2ShakeC = Rotate(stopSignLine2a, shake(animationSlider1), intersections(2))
stopSign3ShakeC = Rotate(stopSignLine3a, shake(animationSlider1), intersections(3))
stopSign4ShakeC = Rotate(stopSignLine4a, shake(animationSlider1), intersections(4))
stopSign5ShakeC = Rotate(stopSignLine5a, shake(animationSlider1), intersections(5))
stopSign6ShakeC = Rotate(stopSignLine6a, shake(animationSlider1), intersections(6))
stopSign7ShakeC = Rotate(stopSignLine7a, shake(animationSlider1), intersections(7))
stopSign8ShakeC = Rotate(stopSignLine8a, shake(animationSlider1), intersections(8))
stopSign9ShakeC = Rotate(stopSignLine9a, shake(animationSlider1), intersections(9))
speed1: 2
stopSignCurrent = Polygon(MoveToPoint - (0.17, 0.17 / tan(22.5°)), MoveToPoint - (0.17, 0.17 / tan(22.5°)) + (0.34, 0), 8)
busStop2Animate1 = Rotate(busStop2_{1}, shake(animationSlider1), PointRandomStop2 + (0, 0.65))
busStop2Animate2 = Rotate(busStop2_{2}, shake(animationSlider1), PointRandomStop2 + (0, 0.65))
busStop2Animate3 = Rotate(busStop2_{3}, shake(animationSlider1), PointRandomStop2 + (0, 0.65))
busStop2Animate4 = Rotate(busStop2_{4}, shake(animationSlider1), PointRandomStop2 + (0, 0.65))
busStop2Animate5 = Rotate(busStop2_{5}, shake(animationSlider1), PointRandomStop2 + (0, 0.65))
textBAnimate = RotateText(textB, shake(animationSlider1))
PointLabel = If(directionVertical, Midpoint[segmentVertical] - (0.7, -0.35), Midpoint[segmentHorizontal] - (0.25, 0.2))
textMoves: "$\text{Moves: " + (LaTeX[numClicks]) + "/10}"
busPoint2: PointFirstAnimation + (0.3, -0.3)
busPoint1: PointFirstAnimation - (0.3, 0.3)
textQuestion: "\textsf{Click adjacent stop signs to travel from bus stop }A\textsf{ at }\[" + (LaTeX[PointRandomStop1]) + "\]\textsf{ to bus stop }B\textsf{ at }\[" + (LaTeX[PointRandomStop2]) + "\]\textsf{.}"
listForArray = Zip("&\textsf{" + (n) + " to}&\[" + (m) + "\]\\", n, First[textPaths, numClicks - 1], m, First[travelPath, numClicks - 1])
textMovement: "\text{\begin{array}{c}\begin{array}{rll}
\multicolumn{2}{r}{\textsf{Start at}}&\[" + (LaTeX[PointRandomStop1]) + "\]\\ " + (LaTeX[textForArray]) + "" + (LaTeX[If[numClicks > 1, "+", ""]]) + "&\textsf{" + (LaTeX[textPaths(numClicks)]) + " to}&\[" + (LaTeX[travelPath(numClicks)]) + "\]\\
&" + (LaTeX[If[numClicks > 1, "------------------", "\phantom{------------------}"]]) + "&\\
&\multicolumn{2}{l}{\textsf{" + (LaTeX[numDistance]) + " block" + (LaTeX[If[numDistance > 1, "s", ""]]) + " traveled in all}}\\
\end{array}\\\\" + (LaTeX[textComplete]) + "\end{array}
}"
tabOrder: {textQuestion, stopSign1ShakeA, stopSign2ShakeA, stopSign3ShakeA, stopSign4ShakeA, stopSign5ShakeA, stopSign6ShakeA, stopSign7ShakeA, stopSign8ShakeA, stopSign9ShakeA, busStop2Animate5, btnResetMap, btnNew}

Tool: PixelsToPoint
PixelsToPoint(Corner1,Corner3,Corner5,PixelCoords)
Input: Corner1, Corner3, Corner5, InputPixels
Output: OutputPoint

InputPixels: (100, 200)
xRight: x(Corner3)
xLeft: x(Corner1)
yTop: y(Corner3)
yBottom: y(Corner1)
yCoord: yTop - (y(InputPixels) / y(Corner5) * (yTop - yBottom))
xCoord: (x(InputPixels) / x(Corner5) * (xRight - xLeft)) + xLeft
OutputPoint: (xCoord, yCoord)

Tool: PixelsToPoint (command PixelsToPoint1)
PixelsToPoint(Corner1,Corner3,Corner5,PixelCoords)
Input: Corner1, Corner3, Corner5, InputPixels
Output: OutputPoint

InputPixels: (100, 200)
xRight: x(Corner3)
xLeft: x(Corner1)
yTop: y(Corner3)
yBottom: y(Corner1)
yCoord: yTop - (y(InputPixels) / y(Corner5) * (yTop - yBottom))
xCoord: (x(InputPixels) / x(Corner5) * (xRight - xLeft)) + xLeft
OutputPoint: (xCoord, yCoord)

Tool: PartitionPoint
PartitionPoint(P1,P2,Num,Den)
Input: SimMove, solutionPoint, animation1Slider, animation1Range
Output: Animation1Point

$\textbf{\mathsf{F}}$

Animation1Point: SimMove + (animation1Slider * (solutionPoint - SimMove) / animation1Range)

Tool: twoPointRect
twoPointRect[ <Point>, <Point> ]
Input: A, B
Output: q1

q1 = Polygon({A, (x(B), y(A)), B, (x(A), y(B))})

Tool: stopSign
Input: A
Output: c, c', c'_{1}, c'_{2}, q1

q1 = Polygon({A + (0.5, 0.4), A + (0.5, -0.4), A + (-0.5, -0.4), A + (-0.5, 0.4)})
B: A + (0.4, 0.4)
C: A + (0.5, 0.3)
D: A + (0.4, 0.3)
c = CircleSector(D, C, B)
c' = Mirror(c, A)
c'_{1} = Mirror(c, y = y(A))
c'_{2} = Mirror(c, x = x(A))

Tool: busStop
busStop[ <Point> ]
Input: A
Output: c'_{2}, c', q1, c'_{1}, c

q1 = Polygon({A + (0.5, 0.4), A + (0.5, -0.4), A + (-0.5, -0.4), A + (-0.5, 0.4)})
B: A + (0.4, 0.4)
C: A + (0.5, 0.3)
D: A + (0.4, 0.3)
c = CircleSector(D, C, B)
c' = Mirror(c, A)
c'_{1} = Mirror(c, y = y(A))
c'_{2} = Mirror(c, x = x(A))

Tool: busStopN
Input: A
Output: c, c', c'_{1}, c'_{2}, poly1

B: A + (0.4, 0.4)
C: A + (0.5, 0.3)
D: A + (0.4, 0.3)
c = CircleSector(D, C, B)
c' = Mirror(c, A)
c'_{1} = Mirror(c, y = y(A))
c'_{2} = Mirror(c, x = x(A))
poly1 = Polygon({A + (0.4, 0.4), A + (0.4, 0.3), A + (0.5, 0.3), A + (0.5, -0.3), A + (0.4, -0.3), A + (0.4, -0.4), A + (-0.4, -0.4), A + (-0.4, -0.3), A + (-0.4, -0.3), A + (-0.5, -0.3), A + (-0.5, 0.3), A + (-0.4, 0.3), A + (-0.4, 0.4)})