#!/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))
def setup(self): box = shutthebox.Box() dice = shutthebox.Dice() self.turn = shutthebox.HumanTurn(box, dice)
def test_number_of_flaps_non_int(self): shutthebox.Box(1.5)
def test_get_available_flaps_returns_correct_flaps(self): small_box = shutthebox.Box(3) assert list(small_box.get_available_flaps().keys()) == [1, 2, 3] small_box.flaps[2].lower() assert list(small_box.get_available_flaps().keys()) == [1, 3]
def test_number_of_flaps_too_small(self): shutthebox.Box(0)
def test_non_default_number_of_flaps(self): new_box = shutthebox.Box(3) assert new_box.num_flaps == 3 assert len(new_box.flaps) == 3
def setup(self): self.box = shutthebox.Box() self.big_box = shutthebox.Box(12)
def setup(self): box = shutthebox.Box() dice = shutthebox.Dice() self.turn = shutthebox.ComputerTurn(box, dice)
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)