I don’t understand the infinite loop error and here what it look like:
If anyone know what it mean can you please tell me.
Here is my code:
def castinvisibility():
if hero.canCast("invisibility"):
hero.cast("invisibility", hero)
def flag():
flag = hero.findFlag("green")
if flag:
hero.pickUpFlag(flag)
def commandArcher():
friends = hero.findFriends()
archers = (friend for friend in friends if friend.type == "archer")
patrolCenter = {'x': hero.pos.x, 'y': hero.pos.y}
patrolTimeScale = 0.40
archerrs = (friend for friend in friends if friend.type == "archer")
radius = 2 + 2.5 * Math.log1p(len(archers))
angleStep = Math.PI * 2 / len(archers)
for index, archer in enumerate(archers):
enemy = archer.findNearestEnemy()
if enemy and archer.distanceTo(enemy) <= 25:
hero.command(archer, "attack", enemy)
else:
hero.command(archer, "move",
{'x': patrolCenter.x + radius * Math.cos(angleStep * index - hero.time * patrolTimeScale),
'y': patrolCenter.y + radius * Math.sin(angleStep * index - hero.time * patrolTimeScale)})
def commandPaladin():
friends = hero.findFriends()
paladins = (friend for friend in friends if friend.type == "paladin")
patrolCenter = {'x': hero.pos.x, 'y': hero.pos.y}
patrolTimeScale = 0.30
archerrs = (friend for friend in friends if friend.type == "paladin")
radius = 2 + 2.5 * Math.log1p(len(paladins))
angleStep = Math.PI * 2 / len(paladins)
for index, paladin in enumerate(paladins):
enemy = paladin.findNearestEnemy()
if enemy and paladin.distanceTo(enemy) <= 10:
hero.command(paladin, "attack", enemy)
else:
hero.command(paladin, "move",
{'x': patrolCenter.x + radius * Math.cos(angleStep * index - hero.time * patrolTimeScale),
'y': patrolCenter.y + radius * Math.sin(angleStep * index - hero.time * patrolTimeScale)})
loop:
enemy = hero.findNearestEnemy()
castinvisibility()
flag()
commandArcher()
if enemy and enemy.type == "shaman":
hero.scattershot(enemy)
if enemy and hero.distanceTo(enemy) <= 30:
hero.scattershot(enemy)
patrolCenter = {'x': hero.pos.x, 'y': hero.pos.y}
patrolTimeScale = 0.60 # set to 0.0 if you don't want the soldiers to walk around while in the circle
summonTypes = ["archer", "archer", "paladin", "paladin", "soldier", "soldier", "soldier", "soldier", "soldier", "soldier", "soldier", "archer", "archer", "archer", "archer"]
summonType = summonTypes[len(hero.built) % len(summonTypes)]
if hero.gold >= hero.costOf(summonType):
hero.summon(summonType)
friends = hero.findFriends()
soldiers = (friend for friend in friends if friend.type == "soldier")
radius = 2 + 2.5 * Math.log1p(len(soldiers))
angleStep = Math.PI * 2 / len(soldiers)
for index, soldier in enumerate(soldiers):
enemy = soldier.findNearestEnemy()
if enemy and soldier.distanceTo(enemy) <= 15:
hero.command(soldier, "attack", enemy)
else:
hero.command(soldier, "move",
{'x': patrolCenter.x + radius * Math.cos(angleStep * index - hero.time * patrolTimeScale),
'y': patrolCenter.y + radius * Math.sin(angleStep * index - hero.time * patrolTimeScale)})
for friend in hero.findFriends():
if friend.type == "paladin":
enemy = hero.findNearestEnemy()
if (friend.canCast("heal")) and hero.health < hero.maxHealth:
self.command(friend, "cast", "heal", self)
elif (friend.canCast("heal")) and hero.health == hero.maxHealth and soldier and soldier.health < soldier.maxHealth:
self.command(friend, "cast", "heal", soldier)
elif (friend.canCast("heal")) and hero.health == hero.maxHealth and friend and friend.health < friend.maxHealth:
self.command(friend, "cast", "heal", friend)
else:
commandPaladin()
Here is my gear:
The level that I am playing is Cavern Survival.