# Power Points pos error

``````# You need to find and destroy 3 skeletons.
# Skeletons and items are summoned at points of power.
# Move to a point and say the spell: "VENI".
# To find the required points, use the wizard's map.
# 0s are bad points. Positive numbers are good.

spell = "VENI"
# The map of points is a 2D array of numbers.
wizard = hero.findNearest(hero.findFriends())
powerMap = wizard.powerMap

def heroattack():
while True:
enemies = hero.findEnemies()
enemy = hero.findNearestEnemy()
if enemy:
if hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
hero.electrocute(enemy)
else:
hero.attack(enemy)
elif len(enemies) == 0:
break

# This function converts grid into x-y coordinates.
def convert(row, col):
return {'x': 16 + col * 12, 'y': 16 + row * 12}

# Loop through the powerMap to find positive numbers.
# First, loop through indexes of rows.
for i in range(len(powerMap)):
# Each row is an array. Iterate through it.
for j in range(len(powerMap[i])):
# Get the value of the i row and j column.
pointValue = powerMap[i][j]
# If it's a positive number:
if pointValue != 0:
tx = i
ty = j
# Use convert to get XY coordinates.
tar = convert(tx, ty)
# Move there, say "VENI" and be prepared!
hero.moveXY(tar.x, tar.y)
hero.say(spell)
heroattack()
``````

everything work fine until my hero reach the 3rd location, it start to freeze and if the hero even manage to get to the last skeleton he is going to die. Something wrong with the code but I am not sure what is it, there might be an endless loop somewhere

nvm I managed to do it. Not sure why but I was getting errors only because my hero was dying