and what do you mean by your second part “your telling your friends to move x plus one, but what x are they going to move apon same for the y cordinates”
you say to them move one x more but you need to do friend.pos.x + 1
this is my code now
while True:
friends = hero.findFriends()
# Use for-loop and for each friend:
for friend in friends:
# If they see an enemy then command to attack.
enemy = friend.findNearestEnemy
if enemy:
hero.command(friend, "attack", enemy)
# Command to move east by small steps.
hero.command(friend, "move", {'friend.pos.x' + 1, 'friend.pos.y'})
it says dont know how to transform: set
i didn’t tell you to delete the “x”: and the “y”: parts
This line should be:
hero.command(friend,"move", {"x": friend.pos.x+1, "y": friend.pos.y})
Now it says "Attack’s argument target should have type unit but got function. target a unit
post your code
20000000000000
while True:
friends = hero.findFriends()
# Use for-loop and for each friend:
for friend in friends:
# If they see an enemy then command to attack.
enemy = friend.findNearestEnemy
if enemy:
hero.command(friend, "attack", enemy)
# Command to move east by small steps.
hero.command(friend, "move", {'x': friend.pos.x + 1, 'y': friend.pos.y})
put a else: before this line
while True:
friends = hero.findFriends()
# Use for-loop and for each friend:
for friend in friends:
# If they see an enemy then command to attack.
enemy = friend.findNearestEnemy
if enemy:
hero.command(friend, "attack", enemy)
# Command to move east by small steps.
else:
hero.command(friend, "move", {'x': friend.pos.x + 1, 'y': friend.pos.y})
still not working. I think it has something to do with the friend.findNearestEnemy
found it put parenthesis after friend.findNearestEnemy btw parenthesis are ()
oh, right, totally should have realised
Thanks @Eric_Tang! It worked
Did you get the bonus for the level?
No. But at least I’m past it
@Chaboi_3000 or @Eric_Tang or someone else please help two flowers. My code:
# If the peasant is damaged, the flowers will shrink!
def pickUpNearestCoin():
items = hero.findItems()
nearestCoin = hero.findNearest(items)
if nearestCoin:
hero.move(nearestCoin.pos)
# This function has your hero summon a soldier.
def summonSoldier():
# If hero.gold is greater than the cost of the "soldier":
if hero.gold > hero.costOf("soldier"):
# Then summon a "soldier":
hero.summon("soldier")
pass
# This function commands your soldiers to attack their nearest enemy.
def commandSoldiers():
for soldier in hero.findFriends():
enemy = soldier.findNearestEnemy()
if enemy and friend.type != "peasant":
hero.command(soldier, "attack", enemy)
while True:
# In your loop, you can "call" the functions defined above.
# The following line causes the code inside the "pickUpNearestCoin" function to be executed.
pickUpNearestCoin()
# Call summonSoldier here
summonSoldier()
# Call commandSoldiers here
commandSoldiers()
sorry i cant right now i am stuck on that level as well
Oh wow! that’s interesting
What I did was copy the previous level’s code and added not peasant
Edit: you can just attack attack attack without summoning soldiers…