Help Needed: Decoy Drill - Python


#1

May I ask why does Anya walks straight to Naria to report decoysBuilt? Will appreciate it if you could help me point out my problem.
Below is my code. :innocent:

We are field testing a new battle unit: the decoy.

Build 4 decoys, then report the total to Naria.

decoysBuilt = 0
self.gold = 0

loop:
item = self.findNearestItem()
# Loot the coin!
x = item.pos.x
y = item.pos.y
self.moveXY(x, y)
# Each decoy costs 25 gold. Use the Quartz Sense Stone
# to know when you have more than 25 gold with self.gold.
self.gold += item.value
if self.gold >=25:
self.buildXY(“decoy”, self.pos.x - 5, self.pos.y)
# Keep a count of decoys you built as you go along.
decoysBuilt = decoysBuilt +1
# Break out of the loop when you have built 4.
elif decoysBuilt = 4:

Go to Naria and say how many decoys you built.

    self.moveXY(14, 36)    
    self.say("4")

#2

Use elif decoysBuilt == 4, with double ==, not =. == is equality test, = is assignment. (Programming is weird.)

Also, in this one, you don’t assign to self.gold. You just read from it–the Quartz Sense Stone keeps track of your gold for you, unlike the previous level. You just keep track of how many decoys you have built.


#3

Thank you for the clarification (about “=/==”) but I solved the level using the hard way already :smiley: