Rich Forager (when submitted)


#1

On Rich Forager I can’t finish the level because when I press submit I place the flags. After my 3rd flag it dose not want to continue the level. I try again. The same thing happens only with for the 7th. Can enyone help?


#2

Code please @Xzanos(20 chars)


#3
loop: 
    flag = self.findFlag() 
    enemy = self.findNearestEnemy()
    item = self.findNearestItem() 
    if enemy: 
        if self.isReady("cleave"):
            self.cleave(enemy)
        else:
            self.attack(enemy)
    elif flag:
        self.moveXY(flag.pos.x, flag.pos.y)
        self.pickUpFlag(flag) 
    elif item: 
        pos = item.pos 
        itemX = pos.x 
        itemY = pos.y 
        self.moveXY(itemX, itemY)

#4

But it is not the code. It is when I submit then put down the flags is when the troubel starts


#5

Ok I get it @Xzanos, change this code:

elif flag:
    self.moveXY(flag.pos.x, flag.pos.y)
    self.pickUpFlag(flag) 

to an if statement
and change this:

if enemy: 
    if self.isReady("cleave"):
        self.cleave(enemy)
    else:
        self.attack(enemy)

To an elif statement.


#6

Indentation error???


#7

Do you know how to fix that @Xzanos?


#8

all it say is Indentation error for this part of the code

    elif enemy: 
        if self.isReady("cleave"):
            self.cleave(enemy)
        else:
            self.attack(enemy)

#9

I was just asking, do you know how to fix that.


#10

no.
No I do not at all


#11

can you take a screenshot of the code?


#13

Change the elif to an if.


#14

I did that but the same thing happen.


#15

Change if enemy: toelif enemy:``


#16

From the screenshot of your code I noticed that the elif enemy seemingly has an extra space after it as well as the loop and other elif. I am not sure what if that is the problem but it could effect the code. Also you do not need elifs unless using it as an else but with something after it.

if enemy:
     if self.isReady("cleave"):
          self.cleave(enemy)
elif item:
     self.moveXY(itemX, itemY)

So it could assume that the elif is an indention error when it should be if.


#18

It is not the code it is the game


#19

It just stops in the middle of the submit


#20

I just tryed to use java script. It did not work.


#21

FYI it is not J.S (20 chars)


#22

But no matter what I do the game freezes but animations are still going and it is not the code, it is codecombat.