Example #1
0
    # Play a bunch of rounds
    for game in range(1, 10000):
        # Generate a new set of payouts
        payouts = GameSimulator.generate_payouts()

        # From those payouts generate weighted_power values
        weighted_powers = GameSimulator.get_weighted_powers(payouts)

        # Let each player place their bets.
        bob.place_bets(payouts)
        carl.place_bets(payouts)
        adam.place_bets(payouts)
        melanie.place_bets(payouts)

        # BANG!! And Their Off!!
        winners = GameSimulator.play(weighted_powers)

        # Let each player check to see if they won anything.
        bob.check_win(winners)
        carl.check_win(winners)
        adam.check_win(winners)
        melanie.check_win(winners)

        # Store some statistics about this round.
        winnings_paid.append(payouts[str(winners.keys()).replace(" ", "")])
        try:
            tally[str(winners.keys())] = tally[str(winners.keys())] + 1
        except KeyError:
            tally[str(winners.keys())] = 1

    # Print a tally of how many times each pair of horses won a race.