def setup(self):
     box = shutthebox.Box()
     dice = shutthebox.Dice()
     self.turn = shutthebox.HumanTurn(box, dice)
Beispiel #2
0
 def test_number_of_dice_non_int(self):
     shutthebox.Dice(1.5)
#!/usr/bin/env python3

"""
Simulate many turns of Shut the Box using Durango Bill's optimal
strategy. Output the score for each turn to the command line.
"""

import shutthebox

# pylint: disable=invalid-name

box = shutthebox.Box()
dice = shutthebox.Dice()

turn = shutthebox.ComputerTurn(box, dice)

for n in range(0, 10000):
    print(turn.perform_turn(
        flap_decision_method=turn.make_flap_decision_bill))
Beispiel #4
0
 def test_number_of_dice_too_small(self):
     shutthebox.Dice(0)
Beispiel #5
0
 def setup(self):
     self.two_dice = shutthebox.Dice()
     self.one_die = shutthebox.Dice(1)
Beispiel #6
0
 def setup(self):
     box = shutthebox.Box()
     dice = shutthebox.Dice()
     self.turn = shutthebox.ComputerTurn(box, dice)
Beispiel #7
0
 def test_flap_decision_bill_no_file(self):
     box = shutthebox.Box()
     dice = shutthebox.Dice()
     turn = shutthebox.ComputerTurn(box, dice, bill_filename='wrong.txt')
     turn.make_flap_decision_bill(9,
                                  turn.make_num_dice_decision_one_if_poss)
#!/usr/bin/env python3
"""
Output the differences between the flap decision methods
make_flap_decision_highest and make_flap_decision_next_roll_probability
for combinations of flaps with length 4-9 i.e. always summing to more
than 6.
"""

import itertools
import shutthebox

DICE = shutthebox.Dice()

# 4-9 flaps i.e. always summing to more than 6
for length in range(9, 4 - 1, -1):
    for this_combination in itertools.combinations(range(1, 9 + 1), length):
        for this_dice_sum in range(2, 12 + 1):
            # prepare instance with particular flaps raised
            box = shutthebox.Box()
            turn = shutthebox.ComputerTurn(box, DICE)
            turn.box.lower_flaps_except(this_combination)

            highest = turn.make_flap_decision_highest(
                this_dice_sum, turn.make_num_dice_decision_one_if_poss)
            if highest is False:  # not possible to lower any flaps
                break
            next_roll_prob = turn.make_flap_decision_next_roll_probability(
                this_dice_sum, turn.make_num_dice_decision_one_if_poss)

            highest.sort()
            next_roll_prob.sort()