AlexeySapsay / Python_solution_CodeCombat_2018

In that repository I will post my sollution for codecombat.com games for study Python
1 stars 0 forks source link

Mad Maxer Gets Greedy(grab money- 65/77) not solved #185

Open AlexeySapsay opened 6 years ago

AlexeySapsay commented 6 years ago
# Follow me on youtube  channel Phy Tu
# Help with programming on Python, school math, physics
# https://www.youtube.com/channel/UCP5ycahCEZ24qmRRgNnko5Q

# To grab the most gold quickly, just go after gold coins.

while True:
    coins = hero.findItems()
    coinIndex = 0
    closestGold = None
    minGoldDist = 9001

    # Wrap this into a loop that iterates over all coins.

    while coinIndex<len(coins):
        coin = coins[coinIndex]
        distance = hero.distanceTo(coin)/coin.value
        if minGoldDist > distance:
            closestGold = coin
            minGoldDist = distance

            hero.moveXY(coin.pos.x,coin.pos.y)
            pass
        coinIndex+=1