コード例 #1
0
 def test_handle_seven_out(self):
     hw = CreateNewHardways(8, 5.0)
     simulator = CrapsSimulator()
     simulator.set_sample_data(np.array([[4, 6], [3, 4], [3, 3], [3, 4]]))
     simulator.add_bets(hw)
     simulator.simulate()
     self.assertEqual(
         2, len([x for x in simulator.events if x.id == Events.LOST_BET]))
コード例 #2
0
 def test_event_flow(self):
     simulator = CrapsSimulator()
     simulator.set_sample_data(np.array([[4, 4], [3, 3], [3, 3], [3, 3]]))
     simulator.simulate()
     self.assertEqual([
         Events.NEW_SHOOTER, Events.ESTABLISH_POINT, Events.ROLL,
         Events.ROLL, Events.ROLL
     ], [x.id for x in simulator.events])
コード例 #3
0
 def test_seven_out(self):
     simulator = CrapsSimulator()
     simulator.set_sample_data(
         np.array([[1, 2], [4, 4], [3, 4], [2, 3], [3, 4]]))
     simulator.simulate()
     self.assertEqual(
         2,
         len([x.id for x in simulator.events if x.id == Events.SEVEN_OUT]))
コード例 #4
0
 def test_handle_seven_always_working(self):
     hw = CreateNewHardways(8, 5.0, always_work=True)
     simulator = CrapsSimulator()
     simulator.set_sample_data(np.array([[4, 6], [5, 5], [4, 4], [4, 4]]))
     simulator.add_bets(hw)
     simulator.simulate()
     self.assertEqual(
         2,
         len([
             x for x in simulator.events if x.id == Events.COLLECT_WINNINGS
         ]))
コード例 #5
0
 def test_handle_roll_lost(self):
     hw = CreateNewHardways(8, 5.0)
     simulator = CrapsSimulator()
     simulator.set_sample_data(np.array([[3, 3], [5, 3]]))
     simulator.add_bets(hw)
     simulator.simulate()
     self.assertEqual(
         1, len([x for x in simulator.events if x.id == Events.LOST_BET]))
     self.assertEqual(
         0,
         len([
             x for x in simulator.events if x.id == Events.COLLECT_WINNINGS
         ]))
コード例 #6
0
 def test_point_made_lost_bet(self):
     hw = CreateNewHardways(8, 5.0, play_when_point_is_hard_way=True)
     simulator = CrapsSimulator()
     simulator.set_sample_data(np.array([[4, 4], [5, 3]]))
     simulator.add_bets(hw)
     simulator.simulate()
     self.assertEqual(
         1, len([x for x in simulator.events if x.id == Events.LOST_BET]))
     self.assertEqual(
         0,
         len([
             x for x in simulator.events if x.id == Events.COLLECT_WINNINGS
         ]))
コード例 #7
0
 def test_multiple_wins_and_losses(self):
     hw = CreateNewHardways(8, 5.0)
     simulator = CrapsSimulator()
     simulator.set_sample_data(
         np.array([[3, 3], [5, 3], [2, 4], [2, 3], [4, 3], [4, 2], [4, 4],
                   [3, 3], [2, 3], [4, 4]]))
     simulator.add_bets(hw)
     simulator.simulate()
     self.assertEqual(
         2, len([x for x in simulator.events if x.id == Events.LOST_BET]))
     self.assertEqual(
         2,
         len([
             x for x in simulator.events if x.id == Events.COLLECT_WINNINGS
         ]))
コード例 #8
0
 def test_extend_hardways(self):
     t = TripleParleyHardWays()
     t.original_bet_amount = 5
     t.bet_amount = 5
     t.set_hard_way = 8
     t.play_when_point_is_hard_way = True
     simulator = CrapsSimulator()
     simulator.add_bets([t])
     simulator.generate_rolls(10000)
     results = simulator.simulate()
     print(
         f" money lost: {np.sum(results['shooters']['money_lost'])} money won: {np.sum(results['shooters']['money_won'])}"
     )