Beispiel #1
0
 def test_Strategy(self, stand_on_value, stand_on_soft, cards,
                   expected_stand, expected_score):
     strat = blackjack3.Strategy(stand_on_value, stand_on_soft)
     hand = blackjack3.Hand(cards)
     (stand, score) = strat.stand(hand)
     self.assertEqual(stand, expected_stand)
     self.assertEqual(score, expected_score)
Beispiel #2
0
 def test_stand_on_soft_rubric(self):
     STAND_ON_SOFT = True
     HIT_ON_SOFT = False
     """Soft strategy """
     # below stand on value, never stand
     pS = blackjack3.Strategy(16, STAND_ON_SOFT)
     h = blackjack3.Hand([5, 8])
     self.assertFalse(pS.stand(h))
     h = blackjack3.Hand([5, 7, 3])
     self.assertFalse(pS.stand(h))
     # at stand on value, always stand
     h = blackjack3.Hand([5, 7, 2, 2])
     self.assertTrue(pS.stand(h))
     h = blackjack3.Hand([5, 5, 5, 1])
     self.assertTrue(pS.stand(h))
     h = blackjack3.Hand([5, 1])
     self.assertTrue(pS.stand(h))
     # above stand value,always stand
     h = blackjack3.Hand([3, 3, 1])
     self.assertTrue(pS.stand(h))
     h = blackjack3.Hand([5, 5, 3, 4])
     self.assertTrue(pS.stand(h))
     """Hard strategy"""
     # below stand on value, never stand
     pS = blackjack3.Strategy(16, HIT_ON_SOFT)
     h = blackjack3.Hand([5, 7, 3])
     self.assertFalse(pS.stand(h))
     h = blackjack3.Hand([5, 8])
     self.assertFalse(pS.stand(h))
     # at stand on value, and the hand is hard....stand
     h = blackjack3.Hand([5, 7, 2, 2])
     self.assertTrue(pS.stand(h))
     h = blackjack3.Hand([5, 5, 5, 1])
     # at stand on value, and the hand is soft...no stand
     self.assertTrue(pS.stand(h))
     h = blackjack3.Hand([5, 1])
     self.assertFalse(pS.stand(h))
     # above stand value , always stand
     h = blackjack3.Hand([3, 3, 1])
     self.assertTrue(pS.stand(h))
     h = blackjack3.Hand([5, 5, 3, 4])
     self.assertTrue(pS.stand(h))
Beispiel #3
0
 def test_play_hand(self):
     ret = blackjack3.Strategy(13, True).play()
     self.assertTrue(ret.score()[0] >= 13)
Beispiel #4
0
 def test_stand_hard(self):
     ret = blackjack3.Strategy(16, False).stand(blackjack3.Hand([1, 7]))
     self.assertFalse(ret[0])
Beispiel #5
0
 def test_stand_soft(self):
     ret = blackjack3.Strategy(16, True).stand(blackjack3.Hand([1, 7]))
     self.assertTrue(ret[0])