[Solved] power point

# 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

# 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]
        hero.say(pointValue)
        hero.say("next")
        # If it's a positive number:
        if pointValue > 0 and pointValue % 1==0:
            # Use convert to get XY coordinates.
            pos = covert(i,j)
            # Move there, say "VENI" and be prepared!
            hero.moveXY(pos.x, pos.y)
            hero.say("VENI")
            item = hero.findNearest(hero.findItems())
            enemy = hero.findNearest(hero.findEnemies())
            if enemy:
                hero.attack(enemy)
            else:
                hero.moveXY(item.pos.x, item.pos.y)

There is a typo

pos = covert(i,j)
should be convert(i,j)

I think everything else is fine

1 Like

nope

# 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

# 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]
        hero.say(pointValue)
        hero.say("next")
        # If it's a positive number:
        if pointValue > 0 and pointValue % 1==0:
            # Use convert to get XY coordinates.
            covert(i,j)
            # Move there, say "VENI" and be prepared!
            hero.moveXY(pos.x, pos.y)
            hero.say("VENI")
            item = hero.findNearest(hero.findItems())
            enemy = hero.findNearest(hero.findEnemies())
            if enemy:
                hero.attack(enemy)
            else:
                hero.moveXY(item.pos.x, item.pos.y)

This is correct. Your function is defined as convert(row, col), but you call the function as covert. Also, even with this spelling error you will run out of time because with the two hero.say lines in the for j loop, you are iterating through all the points. Each time the hero says something it takes 1 second. Remove those lines and correct the spelling in your original code and you should be good to go.

Note that the code you posted the second time removed the pos variable definition and it won’t work now with the above corrections unless you put that back.

1 Like

Oh! I thought it said convert but it said covert XDDDD

1 Like

Put [Solved].
(20 chars)

1 Like

okay.
(20 characters)

1 Like