I will check if the nearest enemy is a warlock and put all last lines in a loop because you need to command every one of your archers to attack the enemy continuously. Donāt think the line āareAntipodes(friend, enemy) is Falseā is needed.
> for friend in friends:
> for enemy in enemies:
> if areAntipodes(friend, enemy):
> hero.command(friend, "move", enemy.pos)
> else:
> hero.command(friend, "attack", enemy)
why it couldnāt deal like this? when i use this, all is in fight.
and if i look for the warlock, all is in fightā¦
In your case everyone of your friends will attack every enemy only once and that will be insufficient. Put the code in āwhile Trueā loop and see if you need the line if areAntipodes(friend, enemy):
the link to above ācodeā is https://goo.gl/uDgSbt
if you want to loop only 3 times: https://goo.gl/h8C8wd
the site is http://pythontutor.com/ , VISUALIZE Python, Java, JavaScript, TypeScript, Ruby, C, and C++