Help with Cloudrip Commander


#1

Summon some soldiers, then direct them to your base.

Each soldier costs 20 gold.

while self.gold > self.costOf(“soldier”):
self.summon(“soldier”)

Add a while loop to command all the soldiers.

while (soldiers = self.findFriends):
soldierIndex = 0
soldier = soldiers[soldierIndex]
self.command(soldier, “move”, {“x”: 50, “y”: 40})

Go join your comrades!

self.moveXY(50, 41)


#2

It says there is a python bug can someone help?


#3

Please format your code properly so we can read it — see the FAQ.


#4

Summon some soldiers, then direct them to your base.

Each soldier costs 20 gold.
while self.gold > self.costOf(“soldier”):
self.summon(“soldier”)

Add a while loop to command all the soldiers.

while (soldiers = self.findFriends):
soldierIndex = 0
soldier = soldiers[soldierIndex]
self.command(soldier, “move”, {“x”: 50, “y”: 40})

Go join your comrades!

self.moveXY(50, 41)


#5

I see a couple problems here:

You have not formatted your code properly. Please do that.

while (soldiers = self.findFriends): and the content inside the loop won’t work at all. You should move soldierIndex outside of the loop and define soldiers beforehand. You also forgot to increment soldierIndex after all the actions are taken.

In order to fix this, your code would look something like this:

#Summon some soldiers, then direct them to your base.

#Each soldier costs 20 gold.
while self.gold > self.costOf("soldier"):
    self.summon("soldier")
soldiers = self.findFriends() #Define these OUTSIDE the while-loop
soldierIndex = 0
#Add a while loop to command all the soldiers.
while (soldierIndex < len(soldiers)):
    #Do all your actions here

#Go join your comrades!
self.moveXY(50, 41)


#7

TROOLED! Lol, I beat this level by moving to 50, 40 and then summoning soldiers. EASY.