# Attack when your soldiers' total health is greater
# than the ogres' total health
# This function return the sum of all the units' health.
def sumHealth(units):
totalHealth = 0
# Complete this function:
return totalHealth
while True:
friends = hero.findFriends()
enemies = hero.findEnemies()
# Get the total health of your soldiers and the ogres.
if sumHealth(friends) <= sumHealth(enemies):
hero.say("Wait")
# Say "Attack" when your side has more total health.
else:
hero.say("ATTACK!!!")
# Attack when your soldiers' total health is greater
# than the ogres' total health
# This function return the sum of all the units' health.
def sumHealth(units):
totalHealth = 0
# Complete this function:
sum(totalHealth)
return totalHealth
while True:
friends = hero.findFriends()
enemies = hero.findEnemies()
# Get the total health of your soldiers and the ogres.
if sumHealth(friends) <= sumHealth(enemies):
hero.say("Wait")
# Say "Attack" when your side has more total health.
else:
hero.say("ATTACK!!!")
# Attack when your soldiers' total health is greater
# than the ogres' total health
# This function return the sum of all the units' health.
def sumHealth(units):
totalHealth = 0
# Complete this function:
for unit in units:
totalHealth += unit.Health
return totalHealth
while True:
friends = hero.findFriends()
enemies = hero.findEnemies()
# Get the total health of your soldiers and the ogres.
if sumHealth(friends) <= sumHealth(enemies):
hero.say("Wait")
# Say "Attack" when your side has more total health.
else:
hero.say("ATTACK!!!")