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])
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]))
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]))
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 ]))
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 ]))
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 ]))
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'])}" )
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 ]))
def test_combination_builder(self): simulator = CrapsSimulator() self.assertEqual([[1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1]], simulator.combinations(7))
def test_flip_established_point(self): simulator = CrapsSimulator() previous_value = simulator.is_point_established simulator.flip_established_point() self.assertNotEquals(previous_value, simulator.is_point_established)
def test_establishing_point(self): simulator = CrapsSimulator() self.assertFalse(simulator.establishing_point(np.array([3, 4]))) self.assertTrue(simulator.establishing_point(np.array([4, 4])))