hero.findNearest(units) method

I try to optimize the next movement.
First move to gold, them silver, and bronze.
But the program breaks at first gold.
It said there is a error in hero.moveXY(gold.pos.x, gold.pos.y)

I think method this.findNearest(units) can not work with this.findItems()

Thanks a lot.

golds = []
silvers = []

while True:
# Find coins and/or attack the enemy.
# Use flags and your special moves to win!
items = hero.findItems()
for item in items:
if item.value == 3:
golds.append = item
elif item.value == 2:
silvers.append = item
else:
pass

if golds:
    hero.say("Oro")
    gold = hero.findNearest(golds)
    hero.moveXY(**gold.pos**.x, gold.pos.y)
elif silvers:
    hero.say("Plata")
    silver = hero.findNearest(silvers)
    hero.moveXY(silver.pos.x, silver.pos.y)
else:
    hero.say("Bronce")
    item = hero.findNearestItem()
    hero.moveXY(item.pos.x, item.pos.y)
1 Like

You are not using append function correctly
golds.append(item)
silvers.append(item)

2 Likes

btw for your own knowledge if you say item = golds.append

you can use item(item) to append the array golds

You are saying that the object + function is equal a new function item

1 Like