def straightBets(self) -> None: for i in range(37): outcome = Outcome(f"{i}", BetOdds.STRAIGHT) self.wheel.addOutcome(i, outcome) straightBetZeroZeroOutcome = Outcome("00", BetOdds.STRAIGHT) self.wheel.addOutcome(37, straightBetZeroZeroOutcome)
def testStreetBets(self): (binBuilder, wheel) = self.__init() binBuilder.streetBets() oneBin = wheel.getBinByIndex(1) thirtySixBin = wheel.getBinByIndex(36) self.assertIn(Outcome("street (1, 2, 3)", BetOdds.STREET), oneBin) self.assertIn(Outcome("street (34, 35, 36)", BetOdds.STREET), thirtySixBin)
def setUp(self): self.wheel = Wheel() self.outcome0 = Outcome("Number 0", 36) self.outcome00 = Outcome("Number 00", 36) self.bin0 = Bin([self.outcome0]) self.bin00 = Bin([self.outcome00])
def testStraightBets(self, ): (binBuilder, wheel) = self.__init() binBuilder.straightBets() zeroBin = wheel.getBinByIndex(0) zeroZeroBin = wheel.getBinByIndex(37) oneBin = wheel.getBinByIndex(1) self.assertIn(Outcome("0", BetOdds.STRAIGHT), zeroBin) self.assertIn(Outcome("00", BetOdds.STRAIGHT), zeroZeroBin) self.assertIn(Outcome("1", BetOdds.STRAIGHT), oneBin)
def testSplitBets(self): (binBuilder, wheel) = self.__init() binBuilder.splitBets() oneBin = wheel.getBinByIndex(1) thirtySixBin = wheel.getBinByIndex(36) self.assertIn(Outcome("split 1,2", BetOdds.SPLIT), oneBin) self.assertIn(Outcome("split 1,4", BetOdds.SPLIT), oneBin) self.assertIn(Outcome("split 35,36", BetOdds.SPLIT), thirtySixBin) self.assertIn(Outcome("split 33,36", BetOdds.SPLIT), thirtySixBin)
def testLineBets(self): (binBuilder, wheel) = self.__init() binBuilder.lineBets() oneBin = wheel.getBinByIndex(1) fourBin = wheel.getBinByIndex(4) self.assertIn(Outcome("line (1, 2, 3, 4, 5, 6)", BetOdds.LINE), oneBin) self.assertEqual(len(oneBin), 1) self.assertIn(Outcome("line (1, 2, 3, 4, 5, 6)", BetOdds.LINE), fourBin) self.assertIn(Outcome("line (4, 5, 6, 7, 8, 9)", BetOdds.LINE), fourBin) self.assertEqual(len(fourBin), 2)
def splitBets(self) -> None: middleCol = [i for i in range(2, 36, 3)] for n in middleCol: leftSplit = Outcome(f"split {n - 1},{n}", BetOdds.SPLIT) self.wheel.addOutcome(n - 1, leftSplit) self.wheel.addOutcome(n, leftSplit) rightSplit = Outcome(f"split {n},{n + 1}", BetOdds.SPLIT) self.wheel.addOutcome(n, rightSplit) self.wheel.addOutcome(n + 1, rightSplit) for n in range(4, 37): upDownSplit = Outcome(f"split {n - 3},{n}", BetOdds.SPLIT) self.wheel.addOutcome(n - 3, upDownSplit) self.wheel.addOutcome(n, upDownSplit)
def streetBets(self) -> None: for i in range(12): jump = 3 * i relevantNums = (1 + jump, 2 + jump, 3 + jump) street = Outcome(f"street {str(relevantNums)}", BetOdds.STREET) for num in relevantNums: self.wheel.addOutcome(num, street)
def cornerBets(self) -> None: for i in range(1, 32, 3): for j in range(2): cornerNums = self.__createCornerFromTopLeft(i + j) corner = Outcome(f"corner {str(cornerNums)}", BetOdds.CORNER) for num in cornerNums: self.wheel.addOutcome(num, corner)
def testColumnBets(self): (binBuilder, wheel) = self.__init() binBuilder.columnBets() oneBin = wheel.getBinByIndex(1) threeBin = wheel.getBinByIndex(3) thirtyFiveBin = wheel.getBinByIndex(35) self.assertIn( Outcome('column (1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34)', BetOdds.COLUMN), oneBin) self.assertIn( Outcome('column (2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35)', BetOdds.COLUMN), thirtyFiveBin) self.assertIn( Outcome('column (3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36)', BetOdds.COLUMN), threeBin)
def testDozenBets(self): (binBuilder, wheel) = self.__init() binBuilder.dozenBets() oneBin = wheel.getBinByIndex(1) thirteenBin = wheel.getBinByIndex(13) thirtySixBin = wheel.getBinByIndex(36) self.assertIn( Outcome('dozen (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)', BetOdds.DOZEN), oneBin) self.assertIn( Outcome('dozen (13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24)', BetOdds.DOZEN), thirteenBin) self.assertIn( Outcome('dozen (25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36)', BetOdds.DOZEN), thirtySixBin)
def testGetOutcomeByName(self): # arrange w = Wheel() o = Outcome('red', 1) # act w.addOutcome(5, o) # assert self.assertEqual(o, w.getOutcomeByName('red'))
def populateOutcomeDict(self): """ This function fills the allOutcomes dict with the outcomes and their odds. The reason is that the definition of odds is done in one place only. Note: The assignment of outcomes into bins is *not* done here, but in the addOutcome function (which is called from the BinBuilder class.) TODO: Maybe move to separate builder class. """ # Straight bets (single numbers) self.allOutcomes["Number 00"] = Outcome("Number 00", 35) for number in range(37): self.allOutcomes["Number " + str(number)] = Outcome("Number " + str(number), 35)
def evenMoneyBets(self) -> None: redNums = (1, 3, 5, 7, 9, 12, 14, 16, 18, 19, 21, 23, 25, 27, 30, 32, 34, 36) red = Outcome(f"red", BetOdds.EVEN_MONEY) for num in redNums: self.wheel.addOutcome(num, red) blackNums = tuple(i for i in range(1, 36) if i not in redNums) black = Outcome(f"black", BetOdds.EVEN_MONEY) for num in blackNums: self.wheel.addOutcome(num, black) oddNums = tuple(i for i in range(1, 36) if i % 2 == 1) odd = Outcome(f"odd", BetOdds.EVEN_MONEY) for num in oddNums: self.wheel.addOutcome(num, odd) evenNums = tuple(i for i in range(1, 36) if i % 2 == 0) even = Outcome(f"even", BetOdds.EVEN_MONEY) for num in evenNums: self.wheel.addOutcome(num, even) lowNums = tuple(i for i in range(1, 36) if i < 19) low = Outcome(f"low", BetOdds.EVEN_MONEY) for num in lowNums: self.wheel.addOutcome(num, low) highNums = tuple(i for i in range(1, 36) if i > 19) high = Outcome(f"high", BetOdds.EVEN_MONEY) for num in highNums: self.wheel.addOutcome(num, high)
def testFiveBet(self): (binBuilder, wheel) = self.__init() binBuilder.fiveBet() fiveBetBins = [ wheel.getBinByIndex(0), wheel.getBinByIndex(37), wheel.getBinByIndex(1), wheel.getBinByIndex(2), wheel.getBinByIndex(3) ] fiveBetOutcome = Outcome('fiveBet', BetOdds.FIVE_BET) for fBin in fiveBetBins: self.assertIn(fiveBetOutcome, fBin)
def test_randomness(self): # arrange pseudoRandom = random.Random() pseudoRandom.seed(1) randomIndices = [pseudoRandom.randint(0, 37) for _ in range(10)] outcomes = [Outcome(i, 1) for i in range(10)] zipped = zip(randomIndices, outcomes) w = Wheel() for z in zipped: w.addOutcome(z[0], z[1]) w.rng.seed(1) # act+assert for _ in zipped: self.assertEqual(w.next(), Bin({outcomes[i]}))
def testCornerBets(self): (binBuilder, wheel) = self.__init() binBuilder.cornerBets() oneBin = wheel.getBinByIndex(1) twoBin = wheel.getBinByIndex(2) fiveBin = wheel.getBinByIndex(5) self.assertIn(Outcome("corner (1, 2, 4, 5)", BetOdds.CORNER), oneBin) self.assertIn(Outcome("corner (1, 2, 4, 5)", BetOdds.CORNER), twoBin) self.assertIn(Outcome("corner (2, 3, 5, 6)", BetOdds.CORNER), twoBin) self.assertIn(Outcome("corner (1, 2, 4, 5)", BetOdds.CORNER), fiveBin) self.assertIn(Outcome("corner (2, 3, 5, 6)", BetOdds.CORNER), fiveBin) self.assertIn(Outcome("corner (4, 5, 7, 8)", BetOdds.CORNER), fiveBin) self.assertIn(Outcome("corner (5, 6, 8, 9)", BetOdds.CORNER), fiveBin)
def testEvenMoney(self): (binBuilder, wheel) = self.__init() binBuilder.evenMoneyBets() oneBin = wheel.getBinByIndex(1) twentyEightBin = wheel.getBinByIndex(28) oneBinEvenMoneyOutcomes = [ Outcome('red', BetOdds.EVEN_MONEY), Outcome('odd', BetOdds.EVEN_MONEY), Outcome('low', BetOdds.EVEN_MONEY) ] for outcome in oneBinEvenMoneyOutcomes: self.assertIn(outcome, oneBin) twentyEightBinEvenMoneyOutcomes = [ Outcome('black', BetOdds.EVEN_MONEY), Outcome('even', BetOdds.EVEN_MONEY), Outcome('high', BetOdds.EVEN_MONEY) ] for outcome in twentyEightBinEvenMoneyOutcomes: self.assertIn(outcome, twentyEightBin)
def testInEquality(self): o1 = Outcome('blue', 1) o2 = Outcome('red', 1) self.assertNotEqual(o1, o2)
def columnBets(self) -> None: for i in range(3): columnNums = tuple(j for j in range(i + 1, 35 + i, 3)) column = Outcome(f"column {str(columnNums)}", BetOdds.COLUMN) for num in columnNums: self.wheel.addOutcome(num, column)
def dozenBets(self) -> None: for i in range(3): dozenNums = tuple(k + 1 for k in range(i * 12, i * 12 + 12)) dozen = Outcome(f"dozen {str(dozenNums)}", BetOdds.DOZEN) for num in dozenNums: self.wheel.addOutcome(num, dozen)
def lineBets(self) -> None: for i in range(1, 32, 3): lineNums = tuple(i + j for j in range(6)) line = Outcome(f"line {str(lineNums)}", BetOdds.LINE) for num in lineNums: self.wheel.addOutcome(num, line)
def fiveBet(self) -> None: fiveBetNums = [0, 37, 1, 2, 3] fiveBet = Outcome('fiveBet', BetOdds.FIVE_BET) for num in fiveBetNums: self.wheel.addOutcome(num, fiveBet)
def testFields(self): o = Outcome('red', 1) self.assertEqual(o.name, 'red') self.assertEqual(o.odds, 1)
from unittest import TestCase from src.Bet import Bet, InvalidBet from src.BetOdds import BetOdds from src.Outcome import Outcome from src.Table import Table, TABLE_LIMIT, TABLE_MINIMUM outcome = Outcome('red', BetOdds.EVEN_MONEY) class testTable(TestCase): def testTableInit(self): betList = [Bet(30, outcome), Bet(10, outcome)] t = Table(betList) self.assertCountEqual(t.bets, betList) def testPlaceBet(self): ilegalBet = Bet(TABLE_LIMIT + 1, outcome) t = Table() with self.assertRaises(InvalidBet): t.placeBet(ilegalBet) def testIsValidOverLimit(self): betList = [Bet(TABLE_LIMIT + 1, outcome)] t = Table(betList) with self.assertRaises(InvalidBet): t.isValid() def testIsValidUnderMinimum(self): betList = [Bet(TABLE_MINIMUM - 0.1, outcome)] t = Table(betList)
def testLoseAmount(self): o = Outcome('red', 1) b = Bet(1, o) self.assertEqual(b.loseAmount(), 1)
def testWinAmount(self): o = Outcome('red', 1) b = Bet(1, o) self.assertEqual(b.winAmont(), 2)
def testHash(self): o1 = Outcome('red', 1) o2 = Outcome('red', 1) self.assertEqual(hash(o1), hash(o2))
def testInit(self): o = Outcome('red', 1) b = Bet(30, o) self.assertEqual(type(b), type(Bet(30, o)))
def testWinAmount(self): o1 = Outcome('red', 2) self.assertEqual(o1.winAmount(3), 6)