Rich Forager Help


#1

I am having trouble with the level “Rich Forager” here is my code so far (Python)

loop:
flag = self.findFlag()
enemy = self.findNearestEnemy()
item = self.findNearestItem()

if flag:
self.pickUpFlag(flag)

elif enemy:
self.attack(enemy)

elif item:
self.findNearestItem()


#2

Okay, well, what, exactly, is your problem?


#3

Please format your code properly

Read the FAQ!!!


#4

Formatting the code, and letting us know what the issue is that you are seeing would be really good. You may also want to look at moving your character to the item, so it picks it up.


#5

Well guess wut I FAILED


#6

Larkin, this information is not helping, so if you would please be more specific on what you need help with?


#8

Sorry its been a while since i was on but my character doesnt do any thing but attack enemies i try to make him follow the flags and find the coins but still he does nothing, here is my code.

(Python)

loop:
flag = self.findFlag()
enemy = self.findNearest(self.findEnemies())
item = self.findNearest(self.findItems())

if flag:
self.pickUpFlag(flag)

elif enemy:
self.attack(enemy)


elif item:
self.findNearest(self.findItems())

#9

Hello, Larkin. As Feinty and Matt said, please properly format your code.

First things first:
#Whitespace saves lives!

In Python, indentations are important to the running of your program. Put them in, and see whether your hero still has problems.