Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Golden Choice Python

Hi I need help in golden choice for python. my problem is in finding the right coin to go to I get the error that gold is not an object but an array. plz help

# 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())
hero.moveXY(14, 8)
hero.moveXY(14, 14)
# Find your path.

while True:
    for gold in goldMap:
        if hero.distanceTo(gold) > 6:

also what does the make template thing do I can’t understand it.

Hi tv337,

‘makeGoldMap’ makes an array of arrays - this is something you’ve probably met before, for example on Snowdrops and on Danger Valley. Have another look at these levels if you need a refresher.

So ‘gold in goldMap’ is still an array, which is why you’re getting the error message.


1 Like