示例#1
0
文件: player.py 项目: hngchiming/misc
def play(justdice):
    # XXX Define your strategy here.
    win = 0     # Win count.
    nroll = 40  # Roll n times.

    amount = Decimal('0')     # Amount in BTC to bet.
    roll_hi = False
    win_chance = Decimal('2') # %.

    for _ in xrange(nroll):
        if roll_dice(justdice, win_chance, amount, roll_hi):
            win += 1

    return win, nroll
示例#2
0
文件: player.py 项目: bencoin/misc
def play(justdice):
    # XXX Define your strategy here.
    win = 0     # Win count.
    nroll = 40  # Roll n times.

    amount = Decimal('0')     # Amount in BTC to bet.
    roll_hi = False
    win_chance = Decimal('2') # %.

    for _ in xrange(nroll):
        if roll_dice(justdice, win_chance, amount, roll_hi, True)[0]:
            win += 1

    sys.stderr.write("\nWin ratio: %d/%d = %s\n" % (
        win, nroll, Decimal(win) / nroll if nroll else 0))
示例#3
0
def play(justdice):
    # XXX Define your strategy here.
    win = 0  # Win count.
    nroll = 40  # Roll n times.

    amount = Decimal('0')  # Amount in BTC to bet.
    roll_hi = False
    win_chance = Decimal('2')  # %.

    for _ in xrange(nroll):
        if roll_dice(justdice, win_chance, amount, roll_hi, True)[0]:
            win += 1

    sys.stderr.write("\nWin ratio: %d/%d = %s\n" %
                     (win, nroll, Decimal(win) / nroll if nroll else 0))