Level decoy drill


#1

???

# We are field testing a new battle unit: the decoy.
# Build 4 decoys, then report the total to Naria.
# Each decoy costs 25 gold. Use the Quartz Sense Stone
# to know when you have more than 25 gold with self.gold.
# Keep a count of decoys you built as you go along.
# Break out of the loop when you have built 4.
decoysBuilt = 0
loop:
    item = self.findNearest(self.findItems())
    if self.gold < 25 :
        self.moveXY(item.pos.x, item.pos.y)
    else:
        self.buildXY("decoy", self.pos.x - 2, self.pos.y -2)
        decoysBuilt = decoysBuilt+1
        if decoysBuilt < 4 :
            break
self.say("Done building decoys!")
# Go to Naria and say how many decoys you built.
self.moveXY(14, 36)

#2

Yes, and what is the problem you are seeing?

I’m guessing its finishing after just building one decoy? Because decoysBuild < 4? But hard to tell from the ??? description.


#3

Help us help you…

What happens when you run this code that you thing shouldn’t happen? This makes it eaiser for us to figure out what is wrong.

One I can see without even thinking is that you never tell Naria how many you built.

With a little thinking I see that you have ‘<’ when you should have ‘>=’ …

Since I don’t know for sure what is going wrong, I’ll not look any harder. :wink:


#4

thx guys fixed problem