sorry but Nope
This is my code now:
def commandSoldier(soldier, soldierIndex, numSoldiers):
angle = Math.PI * 2 * soldierIndex / numSoldiers
defendPos = {"x": 41, "y": 40}
defendPos.x += 10 * Math.cos(angle)
defendPos.y += 10 * Math.sin(angle)
hero.command(soldier, "defend", defendPos);
def findStrongestTarget():
mostHealth = 0
enemies = hero.findEnemies()
enemyIndex = 0
for enemy in hero.findEnemies():
if enemy.health > mostHealth:
bestTarget = enemy
mostHealth = enemy.health
if bestTarget and bestTarget.health > 15:
return bestTarget
else:
return None
def commandArcher(archer):
nearest = archer.findNearestEnemy()
if archerTarget:
hero.command(archer, "attack", archerTarget)
elif nearest:
hero.command(archer, "attack", nearest)
archerTarget = None
while True:
if not archerTarget or archerTarget.health <= 0:
archerTarget = findStrongestTarget()
friends = hero.findFriends()
soldiers = hero.findByType("soldier")
archers = hero.findByType("archer")
for i, soldier in enumerate(soldiers):
commandSoldier(soldier, i, len(soldiers));
for i in range(len(archers)):
archer = archers[i]
commandArcher(archer)
Hey Ansedra I have to go can you come back on at 5pm.
Try to delete 4 empty spaces before those lines. Can you send me a link to the level?
Ok last one then come back at 11am pleaseCodecombat
bye
Here try to put
for archer in archers:
commandArcher(archer)
Does it work now?
nope it says to slow
The code?(20 characters)
I just turned on the codecombat level and It said success!!!
Then congratulations for completing the level! ( PS you mark as solution the post that helped you the most in the course of solving the level)
Ansedra I also need help on The spy among us please go to my topic
Please do not post on an unrelated topic asking for help in another topic. The fact that you created the other topic is all it takes to ask the entire forum for help. Those of us who are able, will respond in time.
Sorry
Itβs ok, most new users donβt know all the rules. We only get angry if it happens multiple timesβ¦ (we never reallly get angry)
Danny