SARVEN DESERT: "Don't Rush Be Quiet" (Python)

Hey all,
Technically, I’m not having any problems solving this in code (I already had). But mathematically, I’m kind of lost :sweat:. I understand the concepts of mod30 and mod40 functions (modulo), they return either time - (30 or 40) or just time itself; depending on which interval the time is in:

def mod30(n):
    if n >= 30:
        return n - 30
    else:
        return n

Later in the “while-True” loop the code updates the new (x, y) coordinates for next movements:

while True:
    time = hero.time
    x = mod30(time) + 25
    y = mod40(time) + 10
    hero.moveXY(x, y)

Let’s say that:

  • Hero’s next position = (x, y)
  • Game’s time = t

When t = 0, position is (25, 10):

  • x = 25
  • y = 10

Let’s just put it into tracks (segments) for x and y:

  1. 00.0 < t < 30.0
  2. 30.0 =< t < 33.7
  3. 33.7 =< t < 40.0
  4. 40.0 =< t < 45.0
  5. 45.0 =< t < 55.7


Level: (link - location)

1. In each track, what happens to the (x, y) positions of the hero, when time passes (0 : 55.7)?

2. How does the hero move horizontally (-x) like in track 2 or vertically (-y) like in track 4 and keeps moving diagonally?

  1. With the current code, it would continue with:
    image

Although, modulo (%) is actually different than currently presented (Hint 2). You will learn the true modulo in the FizzBuzz level in Cloudrip Mtn. https://codecombat.com/play/level/fizzbuzz-path
modulo

  1. When the time is greater than 30 it subtracts 30 from the x position, (2), resetting your x == 25.
def mod30(n):
    if n >= 30:
        return n - 30

When the time is greater than 40, it subtracts 40 from the y position, (4) resetting y=10. Since they are using the moveXY(), your hero doesn’t recalculate the time until you reach the current x,y.

1 Like

Oh! That explains the horizontal and vertical travel…
Now I get it! Thanks… :+1: