"Backwoods Brawl"


#1

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?


#2

Well, let’s see. What did you command your hero to do when there is a flag placed?


#3

Here is all of the code I put:

enemy = self.findNearestEnemy()
if enemy:
    self.attack(enemy)
flag=self.findFlag()
if flag:

#4

Okay…are you telling me that when you place a flag, you tell your hero to attack?


#5

I actually made a mistake putting that reply. You put your reply while I edited mine.


#6

Okay, so when you’re running the program (not submitted), the flag is still there, correct? What happens once the flag appears?


#7

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.


#8

Stuff that could work:

  1. Put the flag function before the enemy function DIDN’T WORK
  2. 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.

#9

From your code it looks like you forgot the loop.


#10

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)

#11

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!


#12

Their are ways to beat this with only 500 health


#13

Before this I only had like 200-something health


#14

I don’t think has beat it with that


#15

Exactly. Now I have 339 health.


#16

I still don’t think that is enough


#17

Might not be. I don’t really know


#18

Just beat it actually.


#19

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)

#20

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?