[SOLVED] Mined Gems (python)

Yes, unfortunately I have not finished it.
Lydia

Sure, @Destroyer5023 I can help you. Could you please post your latest code?

# Collect 4 gems. Don't touch gems from the inner circle.
# The radius of the gem-trap circle.
innerRadius = hero.distanceTo(hero.findNearestItem())

# This function check that a is definitely greater than b.
def definitelyGreater(a, b):
    return a > b + 0.5

gems = hero.findItems()


# Iterate all gems:
for gem in gems:
    # Use definitelyGreater to check if a gem's distance
    # is greater than the inner radius:
    if (definitelyGreater(a, b)) > innerRadius:
        hero.move(gem.pos)
        hero.moveXY(40, 34)

@Lydia_Song it is no sub-only level.

@Destroyer5023 try putting this:centre = {"x": 40, "y": 34} above gems = hero.findItems()

Mumbo_6

1 Like

and your entire if-statement needs to be replaced with this:

if definitelyGreater(hero.distanceTo(gem), innerRadius):
        hero.moveXY(gem.pos.x, gem.pos.y)
        hero.moveXY(centre.x, centre.y)
3 Likes

thank you so much i was stuck on it for so long

2 Likes

No problem at all! And :partying_face: for beating the level :smile:

2 Likes

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.