But I didn’t test this code. I just correct @Lydia_Song’s code. Maybe it isn’t working.
Ok, but I wanted to say that you should try to let @Lydia_Song correct the code herself and not correct it and then send the code because she also must learn how to correct the code herself.
Andrei
Ok, I deleted it, but everyone can click on the"pensil"and see this program.
What hero and equipment did you guys use for restless dead and passed it? PLease Help!!
Show me your equipments, I honestly don’t think it the equipments matter as much.
This is my newly and revised code. But it says that in hero.command(friend, “attack”, enemy), it should have a unit, not a number. Please HElp!
while True:
enemy = hero.findNearestEnemy()
item = hero.findNearestItem()
if enemy:
if hero.isReady("throw"):
hero.throw(enemy)
else:
hero.attack(enemy)
elif item:
hero.moveXY(item.pos.x, item.pos.y)
elif hero.gold > hero.costOf("soldier"):
hero.summon("soldier")
friends = hero.findFriends()
if friends:
for friend in range(len(friends)):
hero.command(friend, "attack", enemy)
else:
hero.moveXY(19, 40)
You don’t need this part delete it. because you already have for friend
Try correcting this part to for friend in friends
Hope it helps
Do you have a higher boss star or is it all you have.
This is all I have. (20)
Like this?
Yes, try like that. (20 chars)
My soldiers still won’t move.
while True:
enemy = hero.findNearestEnemy()
item = hero.findNearestItem()
if enemy:
if hero.isReady("throw"):
hero.throw(enemy)
else:
hero.attack(enemy)
elif item:
hero.moveXY(item.pos.x, item.pos.y)
elif hero.gold > hero.costOf("soldier"):
hero.summon("soldier")
friends = hero.findFriends()
for friend in friends:
hero.command(friend, "attack", enemy)
else:
hero.moveXY(19, 40)
Sorry I made an error you didn’t find the enemy for soldiers.
Try this
friends = hero.findFriends()
for friend in friends:
enemy = friend.findNearestEnemy()
if enemy:
hero.command(friend, "attack", enemy)
I Don’t know why but the soldiers still just stand there and do nothing!!! (They’re lazy)
while True:
enemy = hero.findNearestEnemy()
item = hero.findNearestItem()
if enemy:
if hero.isReady("throw"):
hero.throw(enemy)
else:
hero.attack(enemy)
elif item:
hero.moveXY(item.pos.x, item.pos.y)
elif hero.gold > hero.costOf("soldier"):
hero.summon("soldier")
friends = hero.findFriends()
for friend in friends:
enemy = friend.findNearestEnemy()
if enemy:
hero.command(friend, "attack", enemy)
else:
hero.moveXY(19, 40)
Can you summon archers?
I dont think so. It’s 1 boss star.
Try:
friends = hero.findFriends()
if friends:
for friend in friends:
if friend:
enemy = friend.findNearestEnemy()
if enemy:
hero.command(friend, "attack", enemy)
I hope it’ll work.
In all these “fors” you always have to write
if friends:
for friend in friends:
if friend:
Or you can use:
friends = hero.findFriends()
if friends
for i in range(len(friends)):
friend = friends[i]
if friend:
hero.command(friend, what you want to do)
Thats just more complicated, you can just do this.
for friend in hero.findFriends():
if friend and friend.type == "soldier":
enemy = friend.findNearestEnemy()
if enemy:
hero.command(friend, "attack", enemy)
No, you have to write:
friends = hero.findFriends()
if friends:
for friend in friends:
if friend: