Reward and Ruination problem

Hi all

I am just stuck on this level everything works fine until the ogre gets the item and my Peon gets it as well, then the hero says there is a enemy at the same position and fires and kills the ogre and the peon as well so that makes me fail the mission.

thank you for your help in advance

here is the code:

while True:
enemy = hero.findNearestEnemy()
item = hero.findNearestItem()
if enemy:
enemyPos = enemy.pos.x + " " + enemy.pos.y
hero.say("Enemy at " + enemyPos)

    if item:
        itemPos = item.pos.x + " " + item.pos.y
        hero.say("Gem at " + itemPos)

I have the same problem and my code is almost identical…
If someone could help, that’d be great!

I believe I have fixed this problem just now, please give it another try and let me know!

Hi!
Having a problem with the same level, but on JS


The first part of code was given in beginning and the part about items was done by just copying the first one and renaming enemies on items

When I start the game nobody moves


the cannon shooting the enemy is fine but when the last enemy comes the cannon does not shoot the enemy.
it also shot the fourth enemy twice. Please, can someone help me?

I used your code and it worked fine for me. The only suggestion I can make for improvement would be to carefully compare line 17 with line 8. But even that doesn’t really change/modify the behavior because it’s just a string.

Also, I don’t know if it will make a difference, but I was using the Rough Sense Stone and regular wooden glasses.

That’s all I’ve got for suggestions.

Here’s my code, same problem as John Doe:

while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        enemyPos = enemy.pos.x + " " + enemy.pos.y
        hero.say("Enemy at " + enemyPos)
        pass
    # Now that you have sweet revenge,
    # why not have your cake and eat it, too?
    # Find the item's position and 
    # say it for your artillery to target.
    item = hero.findNearestItem()
    if item:
        hero.say("Gem is at " + item.pos.x + ", " + item.pos.y + "!")
    pass

The cannon doesn’t shoot the last enemy when its position is mentioned. I believe there’s a bug.

Also, use of the word “peon” in this thread/level is confusing. It means the ogres/enemies, right? OP is calling the peasants who get the gems for us the peons, but on the other hand, they’re the once we should defeat in this level - so the ogres, right?