def _gen_split(self, wheel): """Generate all split bets and assign them to bins.""" # retrieve outcome odds for this bet outcome_odds = RoulettePayout.SplitBet # create all left-right split bets iterating all rows and first 2 cols for row in range(12): for col in range(1, 3): # create outcome left_num = 3 * row + col right_num = left_num + 1 outcome_name = "Split {}-{}".format(left_num, right_num) outcome = Outcome(outcome_name, outcome_odds) # assign outcome to bins wheel.add_outcome(left_num, outcome) wheel.add_outcome(right_num, outcome) # create all up-down split bets iterating first 11 rows and all cols for row in range(11): for col in range(1, 4): up_num = 3 * row + col down_num = up_num + 3 outcome_name = "Split {}-{}".format(up_num, down_num) outcome = Outcome(outcome_name, outcome_odds) # assign outcome to bins wheel.add_outcome(up_num, outcome) wheel.add_outcome(down_num, outcome)
def _gen_straight(self, wheel): """Generate all straight bets and assign them to bins.""" # retrieve outcome odds for this bet outcome_odds = RoulettePayout.StraightBet # create and assign outcomes for numbers from 1 to 36 for i in range(1, 37): # create outcome outcome_name = "Number " + str(i) outcome = Outcome(outcome_name, outcome_odds) # assign to bin wheel.add_outcome(i, outcome) # create zero outcome and assign it to 0 bin outcome_name = "Number 0" outcome = Outcome(outcome_name, outcome_odds) wheel.add_outcome(0, outcome) # create double zero outcome and assign it to 00 bin outcome_name = "Number 00" outcome = Outcome(outcome_name, outcome_odds) wheel.add_outcome(37, outcome)
def testSpinWheelUsingNonRandom(self): bin = self.wheel.next() self.assertIn(Outcome("15", 35), bin.outcomes) self.assertIn(Outcome("LOW", 1), bin.outcomes) self.assertIn(Outcome("BLACK", 1), bin.outcomes) self.assertIn(Outcome("ODD", 1), bin.outcomes)
def runTest(self): # call method to be tested self.bin_builder._gen_line(self.wheel) # create some outcomes that should be there self.outcome1 = Outcome("Line 1-2-3-4-5-6", RoulettePayout.LineBet) self.outcome2 = Outcome("Line 31-32-33-34-35-36", RoulettePayout.LineBet) self.outcome3 = Outcome("Line 10-11-12-13-14-15", RoulettePayout.LineBet) # check outcomes were created ok self.assertIn(self.outcome1, self.wheel.get(1)) self.assertIn(self.outcome1, self.wheel.get(2)) self.assertIn(self.outcome1, self.wheel.get(3)) self.assertIn(self.outcome1, self.wheel.get(4)) self.assertIn(self.outcome1, self.wheel.get(5)) self.assertIn(self.outcome1, self.wheel.get(6)) self.assertIn(self.outcome2, self.wheel.get(31)) self.assertIn(self.outcome2, self.wheel.get(34)) self.assertIn(self.outcome2, self.wheel.get(36)) self.assertIn(self.outcome3, self.wheel.get(11)) self.assertIn(self.outcome3, self.wheel.get(13)) self.assertIn(self.outcome3, self.wheel.get(14))
def setUp(self): """ set up data used in the tests. setUp is called before each test function execution. """ self.first = Outcome("red", 1) self.second = Outcome("red", 1) self.third = Outcome("5 way", 6)
def setUp(self): self.outcome_5 = Outcome("00-0-1-2-3", RoulettePayout.FiveBet) self.outcome_0 = Outcome("Number 0", RoulettePayout.StraightBet) self.outcome_00 = Outcome("Number 00", RoulettePayout.StraightBet) self.bin_0 = Bin(self.outcome_0, self.outcome_5) self.bin_00 = Bin(self.outcome_00, self.outcome_5) self.bin_add = Bin()
def setUp(self): self.outcome1 = Outcome("Red", 2) self.outcome2 = Outcome("Red", 2) self.outcome3 = Outcome("Black", 2) self.outcome4 = Outcome("Black", 3) self.bin1 = Bin(self.outcome1) self.bin2 = Bin(self.outcome1, self.outcome2) self.bin3 = Bin(self.outcome1, self.outcome3)
def setUp(self): self.sampleOutcomeOne = Outcome("1", 1) self.sampleOutcomeTwo = Outcome("Red", 17) self.outcomeOne = Outcome("0", 35) self.outcomeTwo = Outcome("00-0-1-2-3", 6) self.binOne = Bin(self.sampleOutcomeOne, self.sampleOutcomeTwo) self.binTwo = Bin(self.outcomeOne, self.outcomeTwo) self.rng = NonRandom() self.rng.setSeed(3) self.wheel = createWheel(self.rng)
class TestOutcome(unittest.TestCase): def setUp(self): self.outcome1 = Outcome(name="red", odds=17) self.outcome2 = Outcome("red", 17) self.outcome3 = Outcome("first-12", 2) self.outcome4 = Outcome("split-bet", 19) def test_setup(self): self.assertEqual(self.outcome1, self.outcome2) self.assertNotEqual(self.outcome1, self.outcome3) self.assertEqual(self.outcome1.getName(), self.outcome2.getName()) def test___eq__(self): self.assertTrue(self.outcome1.__eq__(self.outcome2)) self.assertFalse(self.outcome1.__eq__(self.outcome3)) def test___ne__(self): self.assertTrue(self.outcome1.__ne__(self.outcome3)) self.assertFalse(self.outcome1.__ne__(self.outcome1)) def test___str__(self): self.assertEqual(str(self.outcome1), "red (17:1)") self.assertEqual(self.outcome1.__str__(), "red (17:1)") def test___repr__(self): self.assertEqual(self.outcome1.__repr__(), "red (17:1)") def test_winAmount(self): self.assertEqual(self.outcome1.winAmount(10), 170) def test_hash(self): self.assertEqual(hash(self.outcome1), hash(self.outcome2)) self.assertNotEqual(hash(self.outcome1), hash(self.outcome3))
class OutcomeTest(unittest.TestCase): def setUp(self): """ set up data used in the tests. setUp is called before each test function execution. """ self.first = Outcome("red", 1) self.second = Outcome("red", 1) self.third = Outcome("5 way", 6) def test_equal(self): self.assertEquals(self.first, self.second, "%s is equal to %s" % (self.first, self.second)) self.assertEquals(self.second, self.first, "%s is equal to %s" % (self.second, self.first)) def test_unequal(self): self.assertNotEqual(self.first, self.third, "%s is not equal to %s" % (self.first, self.third)) self.assertNotEqual(self.second, self.third, "%s is not equal to %s" % (self.second, self.third)) def test_hash(self): self.assertTrue(self.first.__hash__() == self.second.__hash__(), "%d is equal to %d" % (self.first.__hash__(), self.second.__hash__())) self.assertFalse(self.first.__hash__() == self.third.__hash__(), "%d is not equals to %d" % (self.first.__hash__(), self.third.__hash__())) self.assertFalse(self.second.__hash__() == self.third.__hash__(), "%d is not equals to %d" % (self.second.__hash__(), self.third.__hash__())) def test_payout(self): self.assertTrue(self.first.win_amount(10) == 10); self.assertTrue(self.second.win_amount(5) == 5); self.assertTrue(self.third.win_amount(10) == 60);
def runTest(self): # call method to be tested self.bin_builder._gen_straight(self.wheel) # create some outcomes that should be there self.outcome1 = Outcome("Number 0", RoulettePayout.StraightBet) self.outcome2 = Outcome("Number 16", RoulettePayout.StraightBet) self.outcome3 = Outcome("Number 00", RoulettePayout.StraightBet) # check outcomes were created ok self.assertIn(self.outcome1, self.wheel.get(0)) self.assertIn(self.outcome2, self.wheel.get(16)) self.assertIn(self.outcome3, self.wheel.get(37))
class TestOutcome(TestCase): def setUp(self): self.sampleOutcomeOne = Outcome("1", 1) self.sampleOutcomeTwo = Outcome("Red", 17) self.sampleOutcomeThree = Outcome("Red", 17) def test_sameNameReturnsTrue(self): self.assertEqual(True, self.sampleOutcomeTwo.__eq__(self.sampleOutcomeThree)) self.assertEqual(True, self.sampleOutcomeThree.__eq__(self.sampleOutcomeTwo)) def test_sameNameReturnsSameHash(self): self.assertEqual( True, self.sampleOutcomeTwo.__hash__() == self.sampleOutcomeThree.__hash__()) self.assertEqual( True, self.sampleOutcomeThree.__hash__() == self.sampleOutcomeTwo.__hash__()) def test_winAmount(self): self.assertEqual(170, self.sampleOutcomeTwo.winAmount(10)) self.assertEqual(34, self.sampleOutcomeThree.winAmount(2))
class OutcomeTests(unittest.TestCase): def setUp(self): self.outcome1 = Outcome("Red", 2) self.outcome2 = Outcome("Red", 2) self.outcome3 = Outcome("Black", 2) self.outcome4 = Outcome("Black", 3) def testEquality(self): self.assertEqual(self.outcome1, self.outcome2, "Unequal outcomes with the same name") def testNonEquality(self): self.assertNotEqual(self.outcome1, self.outcome3, "Equal outcomes with the same name") def testEqualHash(self): self.assertEqual(self.outcome1, self.outcome2, "Unequal hashes of same name outcomes") def testUnequalHash(self): self.assertNotEqual(self.outcome1, self.outcome3, "Equal hashes of same name outcomes") def testWinAmount(self): self.assertEqual(self.outcome1.winAmount(10), 20, "Win amount wrong value")
def _addDozenBets(self): for dozen in range(1, 4): outcomeName = str(dozen) + '-' + str(dozen * 12) outcome = Outcome(outcomeName, self.DOZEN_VALUE) offset = 12 * (dozen - 1) + 1 for binIndex in range(12): self.wheel.addOutcome(binIndex + offset, outcome)
def testBetsIterator(self): betFour = Bet(3, Outcome("test4", 2)) betFive = Bet(2, Outcome("test5", 3)) self.table.placeBet(self.betOne) self.table.placeBet(self.betTwo) self.table.placeBet(betFour) self.table.placeBet(betFive) betStrings = [] for bet in self.table.bets: betStrings.append(str(bet)) self.assertTrue("1 on test1" in betStrings, MISSING_BET_STRINGS_VALUE) self.assertTrue("2 on test2" in betStrings, MISSING_BET_STRINGS_VALUE) self.assertTrue("3 on test4" in betStrings, MISSING_BET_STRINGS_VALUE) self.assertTrue("2 on test5" in betStrings, MISSING_BET_STRINGS_VALUE)
def testMartingaleLoss(self): bet = Bet(1.0, Outcome("BLACK", 1)) self.martingale.placeBets() self.martingale.lose(bet) self.assertEqual(1, self.martingale.lossCount) self.assertEqual(2, self.martingale.betMultiple)
def _addColumnBets(self): for column in range(1, 4): outcomeName = 'Column ' + str(column) outcome = Outcome(outcomeName, self.COLUMN_VALUE) for row in range(12): binIndex = 3 * row + column self.wheel.addOutcome(binIndex, outcome)
def runTest(self): # call method to be tested self.bin_builder._gen_split(self.wheel) # create some outcomes that should be there self.outcome1 = Outcome("Split 1-2", RoulettePayout.SplitBet) self.outcome2 = Outcome("Split 5-8", RoulettePayout.SplitBet) self.outcome3 = Outcome("Split 35-36", RoulettePayout.SplitBet) # check outcomes were created ok self.assertIn(self.outcome1, self.wheel.get(1)) self.assertIn(self.outcome1, self.wheel.get(2)) self.assertIn(self.outcome2, self.wheel.get(5)) self.assertIn(self.outcome2, self.wheel.get(8)) self.assertIn(self.outcome3, self.wheel.get(35)) self.assertIn(self.outcome3, self.wheel.get(36))
def generateLeftRightPairsRows(self, wheel): for rowIndex in range(0, 12): wheel.addOutcome( rowIndex * 3 + 1, Outcome( str(rowIndex * 3 + 1) + "-" + str(rowIndex * 3 + 2), 17)) wheel.addOutcome( rowIndex * 3 + 2, Outcome( str(rowIndex * 3 + 1) + "-" + str(rowIndex * 3 + 2), 17)) wheel.addOutcome( rowIndex * 3 + 2, Outcome( str(rowIndex * 3 + 2) + "-" + str(rowIndex * 3 + 3), 17)) wheel.addOutcome( rowIndex * 3 + 3, Outcome( str(rowIndex * 3 + 2) + "-" + str(rowIndex * 3 + 3), 17))
def _gen_five(self, wheel): """Generate five bet and assign them to its bins.""" # retrieve outcome odds for this bet outcome_odds = RoulettePayout.FiveBet outcome = Outcome("00-0-1-2-3", outcome_odds) # assign to bins for num in [0, 37, 1, 2, 3]: wheel.add_outcome(num, outcome)
def testMartingaleWin(self): bet = Bet(1.0, Outcome("BLACK", 1)) initialStake = self.martingale.stake - bet.amount self.martingale.placeBets() self.martingale.win(bet) winAmount = bet.winAmount() + initialStake self.assertEqual(0, self.martingale.lossCount) self.assertEqual(1, self.martingale.betMultiple) self.assertEqual(winAmount, self.martingale.stake)
def runTest(self): # call method to be tested self.bin_builder._gen_street(self.wheel) # create some outcomes that should be there self.outcome1 = Outcome("Street 16-17-18", RoulettePayout.StreetBet) self.outcome2 = Outcome("Street 1-2-3", RoulettePayout.StreetBet) self.outcome3 = Outcome("Street 34-35-36", RoulettePayout.StreetBet) # check outcomes were created ok self.assertIn(self.outcome1, self.wheel.get(16)) self.assertIn(self.outcome1, self.wheel.get(17)) self.assertIn(self.outcome1, self.wheel.get(18)) self.assertIn(self.outcome2, self.wheel.get(1)) self.assertIn(self.outcome2, self.wheel.get(2)) self.assertIn(self.outcome2, self.wheel.get(3)) self.assertIn(self.outcome3, self.wheel.get(34)) self.assertIn(self.outcome3, self.wheel.get(35)) self.assertIn(self.outcome3, self.wheel.get(36))
def runTest(self): # call method to be tested self.bin_builder._gen_even(self.wheel) # create some outcomes that should be there self.outcome1 = Outcome("Red", RoulettePayout.EvenBet) self.outcome2 = Outcome("Odd", RoulettePayout.EvenBet) self.outcome3 = Outcome("High", RoulettePayout.EvenBet) # check outcomes were created ok self.assertIn(self.outcome1, self.wheel.get(3)) self.assertIn(self.outcome1, self.wheel.get(23)) self.assertIn(self.outcome1, self.wheel.get(34)) self.assertIn(self.outcome2, self.wheel.get(1)) self.assertIn(self.outcome2, self.wheel.get(17)) self.assertIn(self.outcome2, self.wheel.get(35)) self.assertIn(self.outcome3, self.wheel.get(19)) self.assertIn(self.outcome3, self.wheel.get(31)) self.assertIn(self.outcome3, self.wheel.get(36))
def runTest(self): # call method to be tested self.bin_builder._gen_dozen(self.wheel) # create some outcomes that should be there self.outcome1 = Outcome("Dozen 1", RoulettePayout.DozenBet) self.outcome2 = Outcome("Dozen 2", RoulettePayout.DozenBet) self.outcome3 = Outcome("Dozen 3", RoulettePayout.DozenBet) # check outcomes were created ok self.assertIn(self.outcome1, self.wheel.get(1)) self.assertIn(self.outcome1, self.wheel.get(7)) self.assertIn(self.outcome1, self.wheel.get(12)) self.assertIn(self.outcome2, self.wheel.get(15)) self.assertIn(self.outcome2, self.wheel.get(16)) self.assertIn(self.outcome2, self.wheel.get(18)) self.assertIn(self.outcome3, self.wheel.get(25)) self.assertIn(self.outcome3, self.wheel.get(30)) self.assertIn(self.outcome3, self.wheel.get(36))
def runTest(self): # call method to be tested self.bin_builder._gen_column(self.wheel) # create some outcomes that should be there self.outcome1 = Outcome("Column 1", RoulettePayout.ColumnBet) self.outcome2 = Outcome("Column 2", RoulettePayout.ColumnBet) self.outcome3 = Outcome("Column 3", RoulettePayout.ColumnBet) # check outcomes were created ok self.assertIn(self.outcome1, self.wheel.get(1)) self.assertIn(self.outcome1, self.wheel.get(4)) self.assertIn(self.outcome1, self.wheel.get(7)) self.assertIn(self.outcome2, self.wheel.get(11)) self.assertIn(self.outcome2, self.wheel.get(14)) self.assertIn(self.outcome2, self.wheel.get(20)) self.assertIn(self.outcome3, self.wheel.get(24)) self.assertIn(self.outcome3, self.wheel.get(30)) self.assertIn(self.outcome3, self.wheel.get(36))
def _gen_even(self, wheel): """Generate all even bets and assign them to bins.""" # retrieve outcome odds for this bet outcome_odds = RoulettePayout.EvenBet outcome_low = Outcome("Low", outcome_odds) outcome_high = Outcome("High", outcome_odds) outcome_even = Outcome("Even", outcome_odds) outcome_odd = Outcome("Odd", outcome_odds) outcome_red = Outcome("Red", outcome_odds) outcome_black = Outcome("Black", outcome_odds) # iterate all numbers assining corresponding even bets for num in range(1, 37): # assign low-high bets if num < 19: wheel.add_outcome(num, outcome_low) else: wheel.add_outcome(num, outcome_high) # assign even-odd bets if num % 2 == 0: wheel.add_outcome(num, outcome_even) else: wheel.add_outcome(num, outcome_odd) # assign even-odd bets if num in self.RED_NUMBERS: wheel.add_outcome(num, outcome_red) else: wheel.add_outcome(num, outcome_black)
def runTest(self): # call method to be tested self.bin_builder._gen_five(self.wheel) # create some outcomes that should be there self.outcome1 = Outcome("00-0-1-2-3", RoulettePayout.FiveBet) # check outcomes were created ok self.assertIn(self.outcome1, self.wheel.get(0)) self.assertIn(self.outcome1, self.wheel.get(37)) self.assertIn(self.outcome1, self.wheel.get(1)) self.assertIn(self.outcome1, self.wheel.get(2)) self.assertIn(self.outcome1, self.wheel.get(3))
def _gen_dozen(self, wheel): """Generate all dozen bets and assign them to bins.""" # retrieve outcome odds for this bet outcome_odds = RoulettePayout.DozenBet # create and assign a dozen bet for each number for dozen in range(3): outcome_name = "Dozen " + str(dozen + 1) outcome = Outcome(outcome_name, outcome_odds) # assign outcome to bins for num in [i + (12 * dozen) for i in range(1, 13)]: wheel.add_outcome(num, outcome)
def runTest(self): # call method to be tested self.bin_builder._gen_corner(self.wheel) # create some outcomes that should be there self.outcome1 = Outcome("Corner 1-2-4-5", RoulettePayout.CornerBet) self.outcome2 = Outcome("Corner 2-3-5-6", RoulettePayout.CornerBet) self.outcome3 = Outcome("Corner 32-33-35-36", RoulettePayout.CornerBet) # check outcomes were created ok self.assertIn(self.outcome1, self.wheel.get(1)) self.assertIn(self.outcome1, self.wheel.get(2)) self.assertIn(self.outcome1, self.wheel.get(4)) self.assertIn(self.outcome1, self.wheel.get(5)) self.assertIn(self.outcome2, self.wheel.get(2)) self.assertIn(self.outcome2, self.wheel.get(3)) self.assertIn(self.outcome2, self.wheel.get(5)) self.assertIn(self.outcome2, self.wheel.get(6)) self.assertIn(self.outcome3, self.wheel.get(32)) self.assertIn(self.outcome3, self.wheel.get(33)) self.assertIn(self.outcome3, self.wheel.get(35)) self.assertIn(self.outcome3, self.wheel.get(36))
def _gen_column(self, wheel): """Generate all column bets and assign them to bins.""" # retrieve outcome odds for this bet outcome_odds = RoulettePayout.ColumnBet # create and assign a dozen bet for each number for col in range(1, 4): outcome_name = "Column " + str(col) outcome = Outcome(outcome_name, outcome_odds) # assign outcome to bins for num in [i * 3 + col for i in range(12)]: wheel.add_outcome(num, outcome)
def setUp(self): # create outcomes self.outcome_5 = Outcome("00-0-1-2-3", 6) self.outcome_0 = Outcome("0", 35) self.outcome_00 = Outcome("00", 35) # create wheel and bin builder self.wheel = Wheel() self.bin_builder = BinBuilder()
def setUp(self): randomNumberGenerator = randint self.wheel = Wheel(randomNumberGenerator) self.binBuilder = BinBuilder() self.redOutcome = Outcome("RED", 1) self.blackOutcome = Outcome("BLACK", 1) self.evenOutcome = Outcome("EVEN", 1) self.oddOutcome = Outcome("ODD", 1) self.highOutcome = Outcome("HIGH", 1) self.lowOutcome = Outcome("LOW", 1) self.redNums = [1, 3, 5, 7, 9, 12, 14, 16, 18, 19, 21, 23, 25, 27, 30, 32, 34, 36]
def test_winAmount(): outcome = Outcome("red", 1) amount = 500 winnings = outcome.winAmount(amount) assert_almost_equal(winnings, 500)