Help with Cloudrip Commander

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)

It says there is a python bug can someone help?

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

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)

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)

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

whats the use of coding than if your just gonna cheat

1 Like

and you wasted time of people that care enough to help u

2 Likes