Can you show me your code?
Andrei
Can you show me your code?
Andrei
# Collect 80 gold
while hero.gold < 80:
item = hero.findNearestItem()
hero.moveXY(item.pos.x, item.pos.y)
# Build 4 soldiers to use as bait
for i in range(4):
hero.summon("soldier")
# Send your soldiers into position
points = []
points[0] = { "x": 13, "y": 73 }
points[1] = { "x": 51, "y": 73 }
points[2] = { "x": 51, "y": 53 }
points[3] = { "x": 90, "y": 52 }
friends = hero.findFriends()
# Use range to make an array to loop over.
# Match the friends to the points and command them to move
for i in range(len(soldiers)):
hero.command(soldiers[i], "move", points[i])
Soldiers is undefined because you haven’t defined it. You’ve defined friends but not soldiers.
Danny
And still you haven’t done everyting that I told you to do.
Andrei
i finished the level! thanks @AnSeDra and @Deadpool198
No problem! And congratulations for completing the level and the bonus!
im stuck (20 characters)
never mind i got it…
next time you are stuck make sure to post your code correctly by pressing the </> button.
i need help with noble sacrifice
while True:
hero.findNearestItem()
hero.move(item.pos)
hero.summon(“soldier”)
hero.summon(“soldier”)
hero.summon(“soldier”)
hero.summon(“soldier”)
points =
points[0] = { “x”: 13, “y”: 73 }
points[1] = { “x”: 51, “y”: 73 }
points[2] = { “x”: 51, “y”: 53 }
points[3] = { “x”: 90, “y”: 52 }
friends = hero.findFriends()
hero.command(friend, “point”, [j])Preformatted text
i need help with noble sacrifice
while True:
hero.findNearestItem()
if item:
hero.move(item.pos)
for j in range(4):
hero.summon(“soldier”)
points =
points[0] = { “x”: 13, “y”: 73 }
points[1] = { “x”: 51, “y”: 73 }
points[2] = { “x”: 51, “y”: 53 }
points[3] = { “x”: 90, “y”: 52 }
friends = hero.findFriends()
hero.command(friend, “point”, [j])
As do I,
while hero.gold < 80:
item = hero.findNearestItem()
hero.move(item.pos)
# Build 4 soldiers to use as bait
for i in range(4):
hero.summon("soldier")
# Send your soldiers into position
points = []
points[0] = { "x": 13, "y": 73 }
points[1] = { "x": 51, "y": 73 }
points[2] = { "x": 51, "y": 53 }
points[3] = { "x": 90, "y": 52 }
friends = hero.findFriends()
# Use range to make an array to loop over.
# Match the friends to the points and command them to move
for i in range(len(soldiers)):
#here make soldier soldiers[i]
#here make pos points[i]
hero.command(soldier, "move", pos)
while hero.gold < 80:
item = hero.findNearestItem()
hero.move(item.pos)
# Build 4 soldiers to use as bait
for i in range(4):
hero.summon("soldier")
# Send your soldiers into position
points = []
points[0] = { "x": 13, "y": 73 }
points[1] = { "x": 51, "y": 73 }
points[2] = { "x": 51, "y": 53 }
points[3] = { "x": 90, "y": 52 }
soldiers = hero.findFriends()
# Use range to make an array to loop over.
# Match the friends to the points and command them to move
for soldier in soldiers:
for pos in points:
#here make soldier soldiers[i]
#here make pos points[i]
hero.command(soldier, "move", pos)
my soldiers move to the point closest to the yeti, all of them, and then they don’t move back along the other points… I don’t know why they do this… Please help…
You’re telling each soldier to move to each point. for soldier in soldier
operates on each soldier individually. For that single soldier, you’re commanding it to move to each point in points
. Instead, try dealing with both in the same loop, instead of nesting the loops. This should be pretty easy because the length of the soldiers
array and the length of the points
array are the same.