示例#1
0
    def get_weighted_powers(payouts):
        # everyone starts even.
        values = [0.2, 0.2, 0.2, 0.2, 0.2]

        # Loop through all of the payouts
        for pair in payouts.keys():

            # Tally up each horses potential value
            if "1" in pair:
                values[0] += payouts[pair]
            if "2" in pair:
                values[1] += payouts[pair]
            if "3" in pair:
                values[2] += payouts[pair]
            if "4" in pair:
                values[3] += payouts[pair]
            if "5" in pair:
                values[4] += payouts[pair]

        # Grab a few useful values
        max_val = max(values)
        min_val = min(values)
        med_value = med(values)

        for i, cur_val in enumerate(values):
            # Mystical mathematical equation to turn potential value into a suitable power.
            # The gist of it is higher value -> lower power AND lower value -> higher power.
            values[i] = (1.1 - (cur_val / max_val)) * 5

            # Old mystical formula. Kept for posterity.
            # values[i] = (max_val + 10 - cur_val) / 500

        # print (values)
        return values
示例#2
0
    def place_bets(self, payouts):
        med_payout = med(payouts.values())
        self.bets.clear()
        for pair, payout in payouts.iteritems():
            if payout == med_payout:
                self.bets[pair] = payout

        self.credits -= len(self.bets)

        return self.bets