[SOLVED] Mad Maxer Gets Greedy (python)

while True:
    bestCoin = None
    maxRating = 0
    coinIndex = 0
    coins = hero.findItems()
    # Try calculating "value / distance" to decide which coins to get.
    while coinIndex < len(coins):
        coin = coins[coinIndex]
        if coin:
            distance = hero.distanceTo(coin)
            if coin.value < maxRating:
                maxRating = coin.value / distance
                bestCoin = coin
        coinIndex += 1
    if bestCoin:
        pos = bestCoin.pos

So the only problem, is move() doesn’t work.
Help greatly appreciated
Here is linkity link

if coin.value < maxRating:

You are comparing coin.value, the worth of the coin, to maxRating, which represents the value / distance of another coin. Comparing variables representing different types of values doesn’t make sense!

Try if coin.value / distance > maxRating:

Thank you for your help!

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.