Hi I am really stuck in this level
here is my code
# You must collect the required amount of gold.
# The gate keeper will tell you how much you need.
# Always move in the direction of the exit.
# For each row you can take only one coin.
# Choose only one from the nearest coins in the next row.
# Distance between rows and coins.
distanceX = 4
distanceY = 6
zeroPoint = {"x": 14, "y": 14}
coinLines = 10
def makeGoldMap(coins):
template = [[0 for j in range(2 * coinLines - 1)] for i in range(coinLines)]
for coin in coins:
row = int((coin.pos.y - zeroPoint.y) / distanceY)
col = int((coin.pos.x - zeroPoint.x) / distanceX)
template[row][col] = coin.value
return template
# Prepare the gold map. It looks like:
# [[1, 0, 9, 0, 4],
# [0, 1, 0, 9, 0],
# [8, 0, 2, 0, 9]]
goldMap = makeGoldMap(hero.findItems())
# Find your path.
def findBestItem(items):
best = None
bestValue = 0
itemIndex = 0
while itemIndex < len(items):
item = items[itemIndex]
if item.pos.y == hero.pos.y+6:
if item.pos.x == hero.pos.x+4:
if item.value > bestValue:
best = item
bestValue = item.value
elif item.pos.x == hero.pos.x-4:
if item.value > bestValue:
best = item
bestValue = item.value
itemIndex +=1
return best
while True:
item = findBestItem(hero.findItems())
if item:
while item:
hero.move(item.pos)
please help !I don’t now what to do