I need help with the Backwoods Brawl level (https://codecombat.com/play/level/backwoods-brawl). While submitting, I put a flag there, and I think it’s the reason my hero doesn’t move AT ALL. Even after hitting ⟳ RELOAD, the flag is still there. If I don’t get rid of the flag somehow, I may never be able to finish the level! Help?
Well, let’s see. What did you command your hero to do when there is a flag placed?
Here is all of the code I put:
enemy = self.findNearestEnemy() if enemy: self.attack(enemy) flag=self.findFlag() if flag:
Okay…are you telling me that when you place a flag, you tell your hero to attack?
I actually made a mistake putting that reply. You put your reply while I edited mine.
Okay, so when you’re running the program (not submitted), the flag is still there, correct? What happens once the flag appears?
The hero doesn’t do anything. Both before, during, and after the flag’s appearance, even though the code says “attack the nearest enemy, if there is one”, he does nothing, the enemies come kill him, but he just sits there like a lump.
Stuff that could work:
Put theDIDN’T WORK
flagfunction before the
- Submit again, but don’t do anything. Sure, I’ll have to wait 24 hours to do this again, but once it’s been a day, I’ll see if this works. TESTING. JUST GOTTA WAIT A DAY.
From your code it looks like you forgot the loop.
Yeah, I just realized I should do a loop. All I need to do is wait 20 hours and stack up on protection and I should be done in no time.
loop: flag=self.findFlag() if flag: self.pickUpFlag(flag) enemy = self.findNearestEnemy() if enemy: if self.isReady("cleave"): self.cleave(enemy) self.attack(enemy) self.attack(enemy)
Almost done! I had to get a lot from the store to increase my health. Only 19 hours to go and I can submit it and beat the level!
Their are ways to beat this with only 500 health
Before this I only had like 200-something health
I don’t think has beat it with that
Exactly. Now I have 339 health.
I still don’t think that is enough
Might not be. I don’t really know
Just beat it actually.
Now I’m having the same problem with “Sarven Shepherd”. What’s wrong with my code?
# Use while loops to pick out the ogre loop: enemies = self.findEnemies() enemyIndex = 0 # Wrap this logic in a while loop to attack all enemies. while enemyIndex<len(enemies): enemy = enemies[enemyIndex] # "!=" means "not equal to." if enemy.type != "sand-yak": # While the enemy's health is greater than 0, attack it! while enemy.health>0: self.attack(enemy) enemyIndex+=1 else: # Between waves, move back to the center. self.moveXY(40, 32)
I’ve noticed the hero’s always going to the center. So I commented out the part about going to the center, and this popped up:
Where did I put in the code something about numbers greater than 3 million?