Ogre Gorge Gouger Help

i haven’t been able to pass this level for about a week and i am in need of some help

while (hero.time < 20) or (hero.gold:60):
    #Collect coins
    hero.say("I should pick up a coin")
    item = hero.findNearestItem()
    if item:
        hero.moveXY(item.pos.x, item.pos.y)
    if hero.time>20 and hero.gold:60:
        break
    

while hero.time>22:
    hero.moveXY(16, 37)
    hero.buildXY("fence", 21, 37)

Your code is slightly more complicated than it needs to be.
For the first while loop, what you want to check is if hero.gold < 60. That’s all. You don’t need to check time, and : doesn’t work, you need to use < (less than).
You also don’t need this:

Because while loops automatically break when their condition is satisfied (e.g. when you have more than 60 gold).
You also don’t need this:

Because moveXY and buildXY don’t need to be looped. They will work fine without a loop.
You also don’t need this:

I realise it may be for debugging purposes, but once you’ve made the above changes that I’ve mentioned, you won’t need it.
Danny

This first while-loop. should be while hero.gold < 60:
And then in this, delete these two:

In this while-loop, the start should be while hero.time > 16
Then move behind the fence (exact coordinates are 15,37)
And then outside of all while-loops, and under all. Build a fence at 21,37
Lydia
P.S. Comments really help!

Your first while loop should be:

while hero.time < 20:

Delete your hero.say() statement. Delete your if statement with the break. Then, delete you second while loop. You don’t need it. Just move behind the fence wall, and build a fence to protect yourself.

You got everything right but this. Delete this and you are good to go.

it still says ran out of time, let me know if this looks correct to you.

while (hero.gold<60):
    #collect coins
    item = hero.findNearestItem()
    if item:
        hero.moveXY(item.pos.x, item.pos.y)
    
hero.moveXY(16, 37)
hero.buildXY("fence", 21, 37)

That code works perfectly for me. It must be your equipment… Please could you post a screenshot of your equipment and of the level screen.
Danny

While your time is less than 20, collect coins until a certain time, then retreat. The sixty is just a bonus to get within the time.

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