I’m having the same trouble on this level. Based upon what I’ve read here, the code should be working.
# Collect more coins than your doppelganger.
# You only have a few seconds to collect coins. Choose your path wisely!
bestCoin = None
maxRating = 0
coinIndex = 0
coins = self.findItems()
# Try calculating "value / distance" to decide which coins to get.
while coinIndex < len(coins):
coin = coins[coinIndex]
coinIndex += 1
if coin.value / self.distanceTo(coin) > maxRating:
maxRating = coin.value / self.distanceTo(coin)
bestCoin = coin
if self.isPathClear(self.pos, bestCoin.pos):
I’ve tried changing the position of coin.value and self.distanceTo(coin) but it doesn’t change the outcome. My guy appears to be heading for the lowest value coin. Sometimes he will head for the silver coins but I have yet to see him head for the gold first. Not sure what to do at this point.
Any help is greatly appreciated.