Forest Miners: Is this a bug?

Hi guys so I was just playing the level Forest Miners and I not sure if this is a bug or not but when my hero say Clear after that an ogre spawn and started to attack me and my peasant.:confused:
Just in case here is my code

# Check if the mines are safe for the workers.
def checkEnemyOrSafe(target):
    # If target (the parameter) exists:
    if target:
        # Then attack target.
        hero.attack(target)
    # Otherwise:
    else:
        # Use say() to call the peasants.
        hero.say("Clear!!!!!")
    pass
while True:
    # Move to, and check the top right X mark.
    hero.moveXY(64, 54)
    enemy = hero.findNearestEnemy()
    checkEnemyOrSafe(enemy)
    # Move to the bottom left X mark.
    hero.moveXY(16, 14)
    # Save the result of findNearestEnemy() in a variable.
    enemy = hero.findNearestEnemy()
    # Call checkEnemyOrSafe(), and pass the
    # result of findNearestEnemy as the argument.
    checkEnemyOrSafe(enemy)
1 Like

Maybe just a timing issue? Try experimenting with different types of boots. Different boots have different speeds and can get you there faster (or slower in the case of the Defensive Boots) depending on what you want. If you are a subscriber, try testing with different classes of heroes (warrior, ranger, wizard).

2 Likes

Twilight Glasses or Enchanted Lenses?

4 Likes

Enchanted Lenses and also should I change it to a fast hero?

2 Likes

I am using Boots of Leaping. Is that good enough?

2 Likes


After one second.

1 Like

Hm, itā€™s weird. The speed should be fixed here. Could you say your CodeCombat nickname? I will try to research that problem.

2 Likes

Thanks, I think my nickname is Minh2007 but Iā€™m not sure.

2 Likes

Thanks. I suppose I know where a problem is. Iā€™ll fix it ASAP. you can try your code with a warrior with Long Sword for example.

3 Likes

Thank you so much. :smile::sweat_smile::smile:

2 Likes

Hi, i have the same problem here.

Iā€™ve try without pet, without infinity lenses, different boots, but canā€™t come to ā€œsynchronisationā€ with the orcs.

My Pseudo is Mr_Tea! Thx

Post your code so we can judge whether or not itā€™s a timing issue. Try not to revive dead threads if you can.

The issue is exactly the same as Minh.

Iā€™ve try several version of code and some copy-paste (like the one of Minh), always same result, the same as Minh.

Check if the mines are safe for the workers.

def checkEnemyOrSafe(target):
if target:
hero.attack(target)
else:
hero.say(ā€œQuick !ā€)
pass

while True:
# Move to, and check the top right X mark.
hero.moveXY(64, 54)
enemy1 = hero.findNearestEnemy()
checkEnemyOrSafe(enemy1)

# Move to the bottom left X mark.
hero.moveXY(16, 14)
# Save the result of findNearestEnemy() in a variable.
enemy2 = hero.findNearestEnemy();
# Call checkEnemyOrSafe, and pass the
# result of findNearestEnemy as the argument.
checkEnemyOrSafe(enemy2)

Please format your code according to the FAQ by using ctrl + shift + c so it is easier to read
argh this is a subscription level. Canā€™t help you on this one :frowning: ask Chaboi_3000 or one of the subscribed helpers for help instead.

I havenā€™t seen the format problem, iā€™ve tried to correct it, but failed.
I try again tomorrow. Thx

I donā€™t see this as a fix and am now experiencing this years later. What was the fix?

@thebluemeanie Welcome to the forum. If you have future questions make sure you visit previous topics about the ā€˜problem levelā€™. Almost any level can be solved only by reading the right topic with almost no
programming knowledge - itā€™s like solving a puzzle :slight_smile:

The answer is given in Hellenarā€™s post:ā€œTry experimenting with different types of bootsā€¦with different classes of heroesā€ You can succeed with the most basic equipment:


If you have the weakest sword use this construction to be sure youā€™re attacking the target until its health is below zero:

    if target:
        while target.health >  0:
            hero.attack(target)

Turns out I wasnā€™t using the ā€œelseā€ function of all of the ā€œif/elseā€ functions. Lesson learned there. I luv learning :slight_smile: