# Collect all the coins!
def commandPeasant(peasant, coins):
# Find the nearest coin to the `peasant` from the `coins` array,
friends = hero.findFriends()
for peasant in friends:
coin= peasant.findNearestItem()
if coin:
hero.command(peasant, "move", {'x': coin.pos.x, 'y': coin.pos.y})
pass
friends = hero.findFriends()
peasants = {
"Aurum": friends[0],
"Argentum": friends[1],
"Cuprum": friends[2]
}
while True:
items = hero.findItems()
goldCoins = []
silverCoins = []
bronzeCoins = []
for item in items:
if item.value == 3:
goldCoins.append(item)
# Put bronze and silver coins in their approriate array:
if item.value == 2:
silverCoins.append(item)
if item.value == 1:
bronzeCoins.append(item)
commandPeasant(peasants.Aurum, goldCoins)
commandPeasant(peasants.Argentum, silverCoins)
commandPeasant(peasants.Cuprum, bronzeCoins)
my code just makes one peasant move to the coin then it stops and says this