This is my first post. Thank you to whoever helps.
The level Backwoods Standff appears to have changed, so most threads about solutions are no longer relevant.
I’m having an issue that a few people have realized: my hero cleaves and continues to attack during the reset phase, but he still dies. Que paso?
Here is the task and my code.
Munchkins are attacking!
The swarms will come at regular intervals.
Whenever you can, cleave to clear the mass of enemies.
while True:
enemy = hero.findNearestEnemy()
# Use an if-statement with isReady to check “cleave”:
if hero.isReady(“cleave”):
# Cleave!
hero.cleave(enemy)
# Else, if cleave is not ready:
else:
# Attack the nearest ogre!
hero.findNearestEnemy()
hero.attack(enemy)
The second to last line: ***hero.findNearestEnemy(), is probably not necessary, and doesn’t appear to serve a functional difference to the process.
I know people don’t post solutions, but I’d appreciate some help. Maybe I’m supposed to focus on Ogre and not Munchkins?
Hero is not a variable. It is an object that represents the character (a.k.a, the guy you control)
Just tested this out on Python. It could be an indentation error. Make sure everything is inside the while loop. Correct indentation would look something like this:
while True:
enemy = hero.findNearestEnemy()
if hero.isReady("cleave"):
hero.cleave(enemy)
else:
hero.attack(enemy)
However, if your code is like this,
while True:
enemy = hero.findNearestEnemy()
if hero.isReady("cleave"):
hero.cleave(enemy)
else:
hero.attack(enemy)
the program will recognize that hero.findNearestEnemy, is the only line of code inside the while loop and hero.isReady is a whole new line, meaning that everything that comes after enemy = hero.findNearestEnemy() is actually out of the loop.
What I am referring to is the indentation of the code. For example, in this while loop, everything indented is inside the loop, and everything not indented, the program recognizes is not inside the loop. In this case, everything is inside the while loop:
while True:
enemy = hero.findNearestEnemy()
if hero.isReady("cleave"):
hero.cleave(enemy)
else:
hero.attack(enemy)
However, in this case:
while True:
enemy = hero.findNearestEnemy()
if hero.isReady("cleave"):
hero.cleave(enemy)
else:
hero.attack(enemy)
Nothing is indented, so the program thinks there is nothing inside the while loop. Therefore, your code will not continuously loop.
What I want you to do is paste your code again. Go to the line above where your code starts and put three of these: `, then go to one line below your code and put three more. I’ll show you an example.
your code here
the ‘tick’ marks is simply the key to the left your ‘1’ key. The key directly above tab and below escape.
also, when doing loops, everything within a loop must be indented 4 spaces, or 1 tab length. so this would be correct:
while True:
thisLineHasFourSpaces.correct()
if noSpaces:
Incorrect.thisWontWork()
I don’t understand why you posted that “your code here”, and I don’t see what you’re trying to show me with it.
I downloaded whatever that is, but have no idea what to do with it.
Can someone personally contact me to give a solution?
I have no idea why you’re talking about tabs and indentation, mine appears exactly as the, allegedly, correct code above. There is literally nothing different in the code.
When you want to paste your code into this forum the indentations will get all messed up.
To fix that, you can put three tick marks before your code, then paste your code, then put three more tick marks at the end of your code. Then all of your indentations will be as you had them in the game. This is needed because sometimes the whole problem has to do with how things are indented.
In the game you never use the tick marks.
I just tried your code as you have it but without the tick marks and it is working.
In order to use cleave you do need to equip a weapon with the cleave ability. I think the long sword is the only one.
Thank you for the post, and for trying my code to see if it worked.
I’ve run the code and it still isn’t working. The character is getting slightly further and appears to be on the last swarm when he is finally killed.
If the code is wrong, and I’ve tried different browsers and cleared my history and cookies, what can I do to get it to run correctly? Why would it still not be working?