# Kelvintaph-burgler with a little help

If you do not understand what Iâm saying, you get away with it, not that it was a joke

1 Like

my hero survives but can not find (Ice Yak)

1 Like

To post your code from the game, use the </> button or it wonât format properly. When you click the </> button, the following will appear:

Please paste ALL of your code inside the triple back tick marks.

# ``` <â Triple back tick marks.

Paste ALL of your code in here.

# ``` <â Triple back tick marks.

There are many people here willing and able to help. If you use the </> button correctly, then ALL of your code should look like this:

``````while True:
enemy = hero.findNearestEnemy()
if enemy:
hero.attack(enemy)
else:
hero.say("My code is formatted properly")
``````

If ALL of your code isnât formatted like the code above, then youâre doing it wrong and we canât see the structure of the code to troubleshoot whether or not that is the issue. Use the </> button and help us help you. This works when sending a private message as well.

Thank you.

3 Likes

ok

``````hero.moveXY(12, 6)
excepE = [âtowerâ]
dest = {âxâ: 78, âyâ: 39}
done = False

def getPos(obj):
return obj.pos.x, obj.pos.y

def toPos(x, y):
return {âxâ: x, âyâ: y}

def rushTo(xy):
hero.jumpTo(xy)
hero.move(xy)

def exclude(units, exceps):
return [u for u in units if u.type not in exceps]

def farthest(enemies):
farthestD = 0
for enemy in enemies:
d = hero.distanceTo(enemy)
if d > farthestD and enemy.health > 0:
farthestD = d
farthest = enemy
return farthest

def nearby(enemies, dis):
return sum([hero.distanceTo(e) < dis for e in enemies])

def selfDying(self):
if self.health < self.maxHealth / 2:
hero.command(self, âmoveâ, {âxâ: self.pos.x - 1, âyâ: self.pos.y})

x, y = getPos(hero)
orbs = hero.findEnemyMissiles()
if len(orbs):
orb = hero.findNearest(orbs)
if hero.distanceTo(orb) < 3:
if y > 14:
hero.moveXY(x, y - 7)
else:
hero.moveXY(x, y + 7)

def lowHP():
friends = hero.findFriends()
lowest = 9999
dying = None
if len(friends):
for friend in friends:
hp = friend.health
if hp < friend.maxHealth / 3 and hp < lowest and hp > 0:
lowest = hp
dying = friend
return dying

def soldierAtk(soldier):
selfDying(soldier)
enemies = hero.findByType(âIce yakâ)
if not len(enemies):
enemy = soldier.findNearestEnemy()
else:
enemy = enemies[0]
if enemy:
hero.command(soldier, âattackâ, enemy)
else:
hero.command(soldier, âmoveâ, soldier.pos)

def archerAtk(archer):
enemies = hero.findByType(âIce Yakâ)
if not len(enemies):
enemy = archer.findNearestEnemy()
else:
enemy = enemies[0]
if enemy and archer.pos.x > 53 and archer.pos.y < 40:
hero.command(archer, âattackâ, enemy)
elif hero.time > 6:
hero.command(archer, âmoveâ, dest)

def riderAtk(rider):
enemies = hero.findByType(ârobot-walkerâ)
if len(enemies):
hero.command(rider, âmoveâ, {âxâ: enemies[0].pos.x / 2 + enemies[1].pos.x / 2,
âyâ: enemies[0].pos.y / 2 + enemies[1].pos.y / 2})

def palaAtk(pala):
selfDying(pala)
dying = lowHP()
enemies = hero.findByType(âIce yakâ)
if not len(enemies):
enemy = pala.findNearestEnemy()
else:
enemy = enemies[0]
if dying and pala.canCast(âhealâ):
hero.command(pala, âcastâ, âhealâ, dying)
else:
hero.command(pala, âmoveâ, dest)
if pala.canCast(âhealâ) and hero.health < 2 * hero.maxHealth / 3:
hero.command(pala, âcastâ, âhealâ, hero)
if pala.pos == dest:
hero.command(pala, âshieldâ)

def summon(soldier):
while hero.gold >= hero.costOf(soldier):
hero.summon(soldier)

def command():
for unit in hero.findFriends():
t = unit.type
if t == âgriffin-riderâ:
riderAtk(unit)
elif t == âsoldierâ:
soldierAtk(unit)
palaAtk(unit)
elif t == âarcherâ:
archerAtk(unit)

def atk():
if hero.gold > hero.costOf(âgriffin-riderâ):
hero.summon(âgriffin-riderâ)
command()
enemies = hero.findByType(ârobot-walkerâ)
if len(enemies):
pass
else:
enemy = hero.findNearest([e for e in hero.findEnemies()if e.type not in [âchieftainâ, âwhitchâ]])
if enemy:
command()
if hero.canCast(âchain-lightningâ, enemy) and hero.time > 7:
hero.cast(âchain-lightningâ, enemy)
elif not len(enemies):
hero.move({âxâ: 78, âyâ: 14})
return True

def run():
while True:
atk()

run()
``````
1 Like

there is my code

• The soldiers do nothing att all

• The archers go towards the ogre with giant blades(chieftain)

• And the paladin passes from (Ice Yak) and also from the witch (the one with the sticks in the head) and goes directly to the cross.

1 Like

Okay, but you copied the code from here. Thus, the formatting is gone already. You have to copy it from the game.

I swear it is the same

1 Like

Do I have to copy it again?

1 Like

if you copied it from the game then you have some serious structural issues in your code. There are no indents and everything is aligned left. I do not believe that you could have made it this far in the game without knowing what proper structure and indents are.

You must highlight and copy the code in the game and then paste it here. It isnât rocket science. Itâs very easy. No one can help you unless we can see the structure and alignment of your code.

eeeeh is not

``````hero.moveXY(7 ,3)
excepE = ['tower']
dest = {'x': 78, 'y': 39}
done = False

def getPos(obj):
return obj.pos.x, obj.pos.y

def toPos(x, y):
return {'x': x, 'y': y}

def rushTo(xy):
hero.jumpTo(xy)
hero.move(xy)

def exclude(units, exceps):
return [u for u in units if u.type not in exceps]

def farthest(enemies):
farthestD = 0
for enemy in enemies:
d = hero.distanceTo(enemy)
if d > farthestD and enemy.health > 0:
farthestD = d
farthest = enemy
return farthest

def nearby(enemies, dis):
return sum([hero.distanceTo(e) < dis for e in enemies])

def selfDying(self):
if self.health < self.maxHealth / 2:
hero.command(self, "move", {'x': self.pos.x - 1, 'y': self.pos.y})

x, y = getPos(hero)
orbs = hero.findEnemyMissiles()
if len(orbs):
orb = hero.findNearest(orbs)
if hero.distanceTo(orb) < 3:
if y > 14:
hero.moveXY(x, y - 7)
else:
hero.moveXY(x, y + 7)

def lowHP():
friends = hero.findFriends()
lowest = 9999
dying = None
if len(friends):
for friend in friends:
hp = friend.health
if hp < friend.maxHealth / 3 and hp < lowest and hp > 0:
lowest = hp
dying = friend
return dying

def soldierAtk(soldier):
selfDying(soldier)
enemies = hero.findByType("ogre")
if not len(enemies):
enemy = soldier.findNearestEnemy()
else:
enemy = enemies[0]
if enemy:
hero.command(soldier, "attack", enemy)
else:
hero.command(soldier, "move", soldier.pos)

def archerAtk(archer):
enemies = hero.findByType("chieftain")
if not len(enemies):
enemy = archer.findNearestEnemy()
else:
enemy = enemies[0]
if enemy and archer.pos.x > 53 and archer.pos.y < 40:
hero.command(archer, "attack", enemy)
elif hero.time > 6:
hero.command(archer, "move", dest)

def riderAtk(rider):
enemies = hero.findByType("robot-walker")
if len(enemies):
hero.command(rider, "move", {'x': enemies[0].pos.x / 2 + enemies[1].pos.x / 2,
'y': enemies[0].pos.y / 2 + enemies[1].pos.y / 2})

def palaAtk(pala):
selfDying(pala)
dying = lowHP()
enemies = hero.findByType("witch")
if not len(enemies):
enemy = pala.findNearestEnemy()
else:
enemy = enemies[0]
if dying and pala.canCast('heal'):
hero.command(pala, "cast", 'heal', dying)
else:
hero.command(pala, "move", dest)
if pala.canCast('heal') and hero.health < 2 * hero.maxHealth / 3:
hero.command(pala, "cast", 'heal', hero)
if pala.pos == dest:
hero.command(pala, "shield")

def summon(soldier):
while hero.gold >= hero.costOf(soldier):
hero.summon(soldier)

def command():
for unit in hero.findFriends():
t = unit.type
if t == 'griffin-rider':
riderAtk(unit)
elif t == 'soldier':
soldierAtk(unit)
palaAtk(unit)
elif t == 'archer':
archerAtk(unit)

def atk():
if hero.gold > hero.costOf('griffin-rider'):
hero.summon('griffin-rider')
command()

enemies = hero.findByType("robot-walker")
if len(enemies):
pass
else:
enemy = hero.findNearest([e for e in hero.findEnemies() if e.type not in ['ice-yak', 'cow']])
if enemy:
command()
if hero.canCast("chain-lightning", enemy) and hero.time > 7:
hero.cast("chain-lightning", enemy)
elif not len(enemies):
hero.move({'x': 78, 'y': 14})
return True

def run():
while True: