Source

privateer / risky_business / market.py

Full commit
import lotteries
import privateers

def value_of_one_trade(trader):
    "one round of market trading"
    lottery = trader.choose_lottery([lotteries.get_lottery() for i in range(3)])
    return lottery.decide()

def value_of_lifetime(genome, Klass=privateers.CARATrader, rounds=10):
    "several rounds of market trading"
    trader = Klass(genome)
    for round in range(rounds):
        trader.wealth += value_of_one_trade(trader)
    return trader.wealth