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 == friend.findNearestEnemy():
friend.command(friend, “attack”, enemy)
# Command to move east by small steps.
else:
friend.command(friend, “move”, (“x”: friend.pos.x +1 “y”: friend.pos.y))
1 Like
Pls format your code pls?
4 Likes
Here is the formatted the code
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 == friend.findNearestEnemy():
friend.command(friend, “attack”, enemy)
# Command to move east by small steps.
else:
friend.command(friend, “move”, (“x”: friend.pos.x +1 “y”: friend.pos.y))
i do not know how plz tell me how
1 Like
Screenshot pls???
20 chars
1 Like
@Leonardo_White I found the problem
Why is the friend commanding the friend?
1 Like
Yes that is the problem.
It should be:
hero.command(friend, “attack”, enemy)
and
hero.command(friend, “move”, (“x”: friend.pos.x +1 “y”: friend.pos.y))
1 Like
this works better
hero.command(friend, “move”, {“x”: friend.pos.x +1 “y”: friend.pos.y})
1 Like
True, But they both work
1 Like
@Leonardo_White I think the solution is here
1 Like
You need a comma after friend.pos.x + 1
2 Likes
Remove the " " from the x and the y
1 Like
@Leonardo_White
These can help you
1 Like
OK, type what the error is
1 Like
The format for the position argument for the move command is {“x”: x-coordinate, “y”: y-coordinate}
2 Likes
Under the large text for the error, it says the program is expecting a certain character, but is finding a different one. This is because there is no comma separating x and y.
2 Likes