Black Diamond <-- Help Needed

All my guy does is move to the first couple of gems and then stop. I can’t figure out why he’s not returning to the middle.

while True:
    gem = hero.findNearest(hero.findItems())
    whiteX = {"x": 40, "y": 35}
    if gem:
        clear = hero.isPathClear(hero.pos, gem.pos)
        # The isPathClear method tells you if there’s an obstacle in the way.
        # If it’s clear, move() to gem.pos.
        if clear:
            hero.move(gem.pos)
            # Else, move back to the center point.
        elif hero.isPathClear(hero.pos, whiteX):
            hero.move(whiteX)

Hangs on elif statement.

Try switching your elif to an else statement, that way you have an if and a else, and throw a if statement to check if path is clear to white x inside of that else statement.

I agree that those are good ideas but I’ve already tried them. Whenever I change the elif statement to else, it gives a red error telling me that the else statement needs to be indented correctly with the if statement. It gives this error no matter where the else statement is indented to. :confused:

In this level you don’t need to check if the path to the center point is clear. Just do an else: instead of the elif:.

Sadly. Not sure what to do then.

What gear are you using? I switch your elif to and else: and it works fine.

Using compound boots with move or moveXY available.

Send an email to team@codecombat.com please, lemme look.

I’m home and on a different machine now and just followed your suggestion. It’s no longer giving me the indentation error when I change to else instead of elif. I’m not sure what was going on there.

After getting rid of the if statement it’s working. Thank you.