コード例 #1
0
 def test_too_high(self):
     config = Configuration(base_bet=1, payout=10000)
     self.assertFalse(
         config.check_valid_payout(), "Invalid payout value of"
         " 10000 was marked as"
         " valid, but it is too"
         "high")
コード例 #2
0
 def test_roll_under_change(self):
     config = Configuration(base_bet=2, payout=2)
     config.set_payout(3)
     self.assertEqual(
         config.get_roll_under_value(), 33.0,
         "Roll under value was not also set when set_payout"
         " was called")
コード例 #3
0
    def test_increase_integer(self):
        config = Configuration(base_bet=4, payout=2, loss_adder=100)
        simulation = Simulation(config=config, account=self.account)

        simulation.increase_bet()
        self.assertEqual(simulation.current_bet, 8,
                         "Current bet was not increased properly in Test 1")
コード例 #4
0
 def test_lose_0_adder(self):
     config = Configuration(base_bet=10, payout=2, loss_adder=0)
     simulation = Simulation(config=config, account=self.account)
     simulation.lose_roll()
     self.assertEqual(
         simulation.current_bet, 10,
         "Bet did not remain constant after loss when"
         " loss_adder was 0")
コード例 #5
0
 def test_frac_adder(self):
     config = Configuration(base_bet=4, payout=2, loss_adder=50)
     simulation = Simulation(config=config, account=self.account)
     simulation.lose_roll()
     self.assertEqual(
         simulation.current_bet, 6,
         "Bet was not correctly increased after single loss"
         " with 50% loss increase")
コード例 #6
0
 def test_multiple_loose_roll(self):
     config = Configuration(base_bet=4, payout=2, loss_adder=100)
     simulation = Simulation(config=config, account=self.account)
     for _ in range(4):
         simulation.lose_roll()
     self.assertEqual(
         simulation.current_bet, 64,
         "Bet was not correctly increased after multiple"
         " losses with 100% loss increase")
コード例 #7
0
    def test_reset_without_rolling(self):
        config = Configuration(base_bet=1, payout=5, loss_adder=100)
        simulation = Simulation(config=config, account=self.account)
        # No increases or decreases made
        simulation.reset_bet()

        self.assertEqual(
            simulation.current_bet, 1,
            "Bet was not reset properly when no changes were made"
            " between resets")
コード例 #8
0
 def test_win(self):
     config = Configuration(base_bet=1, payout=2)
     simulation = Simulation(config=config,
                             account=self.account,
                             random_seed=20)
     # First roll with random_seed(20) is 24.77
     # Roll under value is 49.5 with payout=2
     self.assertTrue(
         simulation.roll(), "Lost roll that should have been"
         " won with standard payout (2)")
コード例 #9
0
    def test_reset_single_roll(self):
        config = Configuration(base_bet=7, payout=2, loss_adder=200)
        simulation = Simulation(config=config, account=self.account)
        simulation.increase_bet()
        simulation.reset_bet()

        self.assertEqual(
            simulation.current_bet, 7,
            "Bet was not reset properly after it was increased a"
            " single time")
コード例 #10
0
 def test_lose(self):
     config = Configuration(base_bet=1, payout=2)
     simulation = Simulation(config=config,
                             account=self.account,
                             random_seed=12)
     # First roll with random_seed(12) is 77.75
     # Roll under value is 49.5 with payout=2
     self.assertFalse(
         simulation.roll(), "Lost roll that should have been"
         " won with standard payout (2)")
コード例 #11
0
 def test_win_high_payout(self):
     config = Configuration(base_bet=1, payout=3)
     simulation = Simulation(config=config,
                             account=self.account,
                             random_seed=20)
     # First roll with random_seed(20) is 24.77
     # Roll under value is 33.00 with payout=3
     self.assertTrue(
         simulation.roll(), "Lost roll that should have been"
         " won with high payout (3)")
コード例 #12
0
 def test_lose_high_payout(self):
     config = Configuration(base_bet=1, payout=3)
     simulation = Simulation(config=config,
                             account=self.account,
                             random_seed=5)
     # First roll with random_seed(5) is 41.85
     # Roll under value is 33.00 with payout=3
     self.assertFalse(
         simulation.roll(), "Won roll that should have been"
         " lost with high payout (3)")
コード例 #13
0
 def test_win_low_payout(self):
     config = Configuration(base_bet=1, payout=1.5)
     simulation = Simulation(config=config,
                             account=self.account,
                             random_seed=5)
     # First roll with random_seed(5) is 41.85
     # Roll under value is 66.00 with payout=1.5
     self.assertTrue(
         simulation.roll, "Lost roll that should have been won"
         " with low payout (1.5)")
コード例 #14
0
 def test_lose_low_payout(self):
     config = Configuration(base_bet=1, payout=1.5)
     simulation = Simulation(config=config,
                             account=self.account,
                             random_seed=12)
     # First roll with random_seed(12) is 77.75
     # Roll under value is 66.00 with payout=1.5
     self.assertFalse(
         simulation.roll(), "Won roll that should have been"
         " lost with low_payout (1.5)")
コード例 #15
0
    def test_reset_multiple_rolls(self):
        config = Configuration(base_bet=10, payout=2, loss_adder=200)
        simulation = Simulation(config=config, account=self.account)
        for _ in range(6):
            simulation.increase_bet()
        simulation.reset_bet()

        self.assertEqual(
            simulation.current_bet, 10,
            "Bet was not reset properly after it was increased"
            " multiple times")
コード例 #16
0
    def test_frac_payout(self):
        config = Configuration(base_bet=10, payout=1.5, loss_adder=50)
        account = Account(balance=100)
        simulation = Simulation(config=config, account=account)

        simulation.account.subtract(10)
        simulation.win_roll(simulation.account)
        self.assertEqual(
            simulation.account.get_balance(), 105,
            "Balance not properly increased with a payout of"
            " 1.5X")
コード例 #17
0
    def test_balance_not_changed(self):
        account = Account(balance=100)
        config = Configuration(base_bet=10, payout=2, loss_adder=0)
        simulation = Simulation(config=config, account=account)

        simulation.lose_roll()
        # The balance should not be changed after a roll is lost, because the
        # account is charged only once before the roll and is not charged again
        # regardless of a win or loss.
        self.assertEqual(simulation.account.get_balance(), 100,
                         "Balance was changed when roll was lost.")
コード例 #18
0
    def test_base_bet_2(self):
        config = Configuration(base_bet=2,
                               payout=2,
                               iterations=1,
                               loss_adder=100)
        account = Account(balance=10)
        simulation = Simulation(config=config, account=account, random_seed=12)
        sim_result = simulation.single_sim()

        self.assertEqual(
            sim_result.get_balances(), [10, 8, 12, 10, 6],
            "Incorrect sequence of balances in single simulation,"
            " base_bet=2")
コード例 #19
0
    def test_base_bet_1(self):
        config = Configuration(base_bet=1,
                               payout=2,
                               iterations=1,
                               loss_adder=100)
        account = Account(balance=5)
        simulation = Simulation(config=config, account=account, random_seed=4)
        sim_result = simulation.single_sim()

        self.assertEqual(
            sim_result.get_balances(),
            [5, 6, 5, 7, 6, 4, 8, 9, 10, 11, 10, 8, 12, 13, 14, 13, 11, 7],
            "Incorrect sequence of balances in "
            "single simulation, base_bet=1")
コード例 #20
0
    def test_multiple_rolls(self):
        config = Configuration(base_bet=1, payout=2)

        simulation = Simulation(config=config,
                                account=self.account,
                                random_seed=10)
        # Generated numbers with random seed of 10 are:
        # 93.61, 5.33, 70.26, 79.06, 94.71
        # A win is made by rolling a number less than 49.5 in this case
        # The sequence should then be loss, win, loss, loss, loss
        self.assertFalse(simulation.roll(), "Failed first roll of multiple"
                         " rolls")
        self.assertTrue(simulation.roll(), "Failed second roll of multiple"
                        " rolls")
        self.assertFalse(simulation.roll(), "Failed third roll of multiple"
                         " rolls")
        self.assertFalse(simulation.roll(), "Failed fourth roll of multiple"
                         " rolls")
        self.assertFalse(simulation.roll(), "Failed fifth roll if multiple"
                         " rolls")
コード例 #21
0
 def test_high_payout(self):
     config = Configuration(base_bet=1, payout=3)
     self.assertEquals(
         config.calc_roll_under_value(), 33.0,
         "Roll under value incorrectly calculated with high"
         " payout of 3")
コード例 #22
0
 def test_too_low(self):
     config = Configuration(base_bet=1, payout=1)
     self.assertFalse(
         config.check_valid_payout(), "Invalid payout value of"
         " 1 was marked as valid,"
         " but it is too low")
コード例 #23
0
 def test_valid_value(self):
     config = Configuration(base_bet=1, payout=3)
     self.assertTrue(config.check_valid_payout(), "Valid payout value of 3"
                     "was marked as invalid")
コード例 #24
0
 def test_payout_change(self):
     config = Configuration(base_bet=2, payout=2)
     config.set_payout(3)
     self.assertEqual(config.get_payout(), 3, "Payout was not set"
                      " appropriately")
コード例 #25
0
 def test_mid_payout(self):
     config = Configuration(base_bet=1, payout=2)
     self.assertEquals(
         config.calc_roll_under_value(), 49.5,
         "Roll under value incorrectly calculated with medium"
         " payout of 2")
コード例 #26
0
 def setUp(self):
     self.account = Account(balance=100)
     self.config = Configuration(base_bet=10, payout=2, iterations=200)
コード例 #27
0
 def test_increase_float(self):
     config = Configuration(base_bet=1, payout=3, loss_adder=50)
     simulation = Simulation(config=config, account=self.account)
     simulation.increase_bet()
     self.assertEqual(simulation.current_bet, 1.5,
                      "Current bet was not increased properly in Test 2")
コード例 #28
0
 def test_low_payout(self):
     config = Configuration(base_bet=1, payout=1.5)
     self.assertEquals(
         config.calc_roll_under_value(), 66.0,
         "Roll under value incorrectly calculated with low"
         " payout of 1.5")