Пример #1
0
class TestGame(unittest.TestCase):
    """Test cases for the Game class."""
    
    def setUp(self):
        """Sets up the tests."""
        self.game = Game()

    def testName(self):
        self.game.play_pass_line(5)
        self.game.roll(d1_value=1, d2_value=3)
        self.assertEqual(True, self.game.coming_out, "msg")
        self.assertEqual(0, self.game.winnings(), "msg")
        self.game.roll(d1_value=3, d2_value=1)
        self.assertEqual(10, self.game.winnings(), "Expected 10 got %s" % self.game.winnings())
    
    def testHardways(self):
        # set hard four
        self.game.roll(d1_value=2, d2_value=2)
        self.assertTrue(self.game.is_hard_four(), "didn't get hard 4")
        self.game.roll(d1_value=3, d2_value=1)
        self.assertFalse(self.game.is_hard_four(), "Got hard 4 when not")
        # set hard six
        self.game.roll(d1_value=3, d2_value=3)
        self.assertTrue(self.game.is_hard_six(), "didn't get hard 6")
        self.game.roll(d1_value=5, d2_value=1)
        self.assertFalse(self.game.is_hard_six(), "Got hard 6 when not")
        # set hard eight
        self.game.roll(d1_value=4, d2_value=4)
        self.assertTrue(self.game.is_hard_eight(), "didn't get hard 8")
        self.game.roll(d1_value=3, d2_value=5)
        self.assertFalse(self.game.is_hard_eight(), "Got hard 8 when not")
        # set hard ten
        self.game.roll(d1_value=5, d2_value=5)
        self.assertTrue(self.game.is_hard_ten(), "didn't get hard 10")
        self.game.roll(d1_value=6, d2_value=4)
        self.assertFalse(self.game.is_hard_ten(), "Got hard 10 when not")
Пример #2
0
                stake -= line_odds
            # place place bets if we can
            p_on = g.point_on()
            have_place = g.have_place_bets()
            if stake >= 32 and p_on and not have_place:
#                print "Playing across"
                for i in [4, 5, 6, 8, 9, 10]:
                    if i != 6 and i != 8 and i != g.point:
                        g.play_the_number(i, 5)
                        stake -= 5
                    if i != g.point and (i == 6 or i == 8):
                        g.play_the_number(i, 6)
                        stake -= 6
#           print "Stake = %s" % stake
            g.roll(verbose=False)
            win = g.winnings()
#            print "rolled %s won $%s" % (g.last_roll, win)
            if win:
                stake += win
        print "Ending Stake = %s, ATM withdraws = %s" % (stake, atm)
        stakes.append(stake)
        atms.append(atm)
        profits.append(stake - atm)

    print "Stake (min, mean, max) = (%s, %s, %s)" % (min(stakes), stats.mean(stakes), max(stakes))
    print "ATM (min, mean, max) = (%s, %s, %s)" % (min(atms), stats.mean(atms), max(atms))
    print "Profits (min, mean, max) = (%s, %s, %s)" % (min(profits), stats.mean(profits), max(profits))
    hist = stats.histogram(profits)
    stake_bins = hist[0]
    stake_start = hist[1]
    stake_width = hist[2]