[SOLVED] Mined Gems (python)

# 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 > innerRadius):
        hero.move(gem.pos)
        hero.moveXY(40, 34)

my hero just stands there doing nothing

Two things:

  1. What are you expecting to be returned here?
return a > b + 0.5
  1. What’s the difference between
def definitelyGreater(a, b)

and

if (definitelyGreater >
1 Like

what do you mean?(20chars)

Change this

# 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 > innerRadius):
        hero.move(gem.pos)
        hero.moveXY(40, 34)

into this

# 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(something, something) > innerRadius):
        hero.move(gem.pos)
        hero.moveXY(40, 34)

You need to enter the parameters for any input function. if you use definitelyGreater, it will give you nothing (0). So, it will not work

Can you please delete the working code and leave only this because some people could use it to “cheat” at the level?

Andrei

1 Like

sorry(20 chaaaaaaaars)

Is that ok now?(20 chars)

anyways what should i do

yep it’s ok(20chars)

you want to input something into your function when you are using it

sorry i don’t understand

definitelyGreater function need two inputs. (def definitelyGreater (a, b))

the function is check if a is (way) bigger than b

It’s very late in my time zone/11:15p.m. so bye

oh ok bye (20chars).

can anybody help me i’m still stuck

Can you send me the link to this level and your newest code?
Lydia

oh i haven’t really changed much
the link
codecombat.com/play/level/mined-gems?

I think Mine Gems is a subscriber level, so I can’t access it. Sorry :frowning_face: :frowning_face:
Lydia

i wrote the wrong link sorry and i don’t think you finished it