Forest 27 - Logical path


#1

I can’t beat Forest 27 - Logical path, and I don’t know why.
Here’s the code I have so far (in Python):

while True:
    if secretA or secretB and hero.pos.x !=  38:
        hero.moveXY(hero.pos.x + 6, hero.pos.y + 9)
        hero.moveXY(hero.pos.x + 6, hero.pos.y - 9)
    elif secretA or secretB:
        hero.moveXY(hero.pos.x + 6, hero.pos.y - 9)
        hero.moveXY(hero.pos.x + 6, hero.pos.y + 9)


#2

you haven’t stated any values for secretA or secretB. The way you have it worded, you are merely checking for the existence of those values. Is secretA true or is secretA != true?

Also, when checking for the position of hero, the way you have that worded the value will return true for any other value of x except 38. Is that really what you wanted?


#3

At the beginning, it automatically detected the values for secrets with:

secretA = hero.findNearestFriend().getSecretA()
secretB = hero.findNearestFriend().getSecretB()

#4

No, in the beginning it obtains the values, but you don’t know if those values are true or false or what to do with those values. That’s why you need to write the code to determine the outcome.

if secretA is True and secretB is True:
    hero.moveXY(x, y)
else:
    hero.moveXY(x, y)

or

if secretA != True or secretB != True:
    hero.moveXY(x, y)
else:
    hero.moveXY(x, y)

Using this format you can see all the possible combinations from there. This tests for the True or False value and determines what to do with the values. The condition, “if secretA” all by itself, as you currently have it written, is not determining a true or false value. It just looks to see if the secret exists.


#5

it actually sees if it is true or false


#6

Not the way HappyBoulder has it written in the original post. That’s what I was referring to in that sentence.