hi. i’ having trouble with this level, can anyone help me?
here’s my code:
while True:
gem = hero.findNearest(hero.findItems())
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 hero.isPathClear(gem.pos, {"x":40, "y":35}) == False:
hero.moveXY(40, 35)
if clear:
hero.move(gem.pos)
My code let me collect all the gems with a ‘if clear move to gem; else move to the middle’ structure. If you’ve tried it and it still isn’t working, can you post your code again?