class SevenRedsTest(unittest.TestCase): nrnd = NonRandom(1) # rolls 1, Odd, Red wh = wheel.Wheel(nrnd) bb = binbuilder.BinBuilder() bb.buildBins(wh) t = table.Table(1000) game = roulettegame.RouletteGame(wh, t) pl = players.SevenReds(t) pl.setStake(100) pl.setRounds(10) def test1_init(self): ''' Tests the initialization of the Martingale Player. Checks initial variables. ''' self.assertEqual(self.pl.stake, 100) self.assertEqual(self.pl.roundsToGo, 10) self.assertEqual(self.pl.lossCount, 0) self.assertEqual(self.pl.betMultiple, 1) self.assertEqual(self.pl.redCount, 0) def test2_roll6reds(self): for roll in range(6): self.game.cycle(self.pl) self.assertEqual(self.pl.redCount, 6) def test3_roll2reds(self): for roll in range(2): self.game.cycle(self.pl) self.assertEqual(self.pl.redCount, 1) self.assertEqual(self.pl.betMultiple, 2)
def test2_gather(self): ''' Tests the simulator.Simulatogather() method. ''' wh = wheel.Wheel() bb = binbuilder.BinBuilder() bb.buildBins(wh) t = table.Table(100) game = roulettegame.RouletteGame(wh, t) pl = players.Passenger57(t) sim = simulator.Simulator(pl, game)
def test4_nomorerounds(self): nrnd = NonRandom(2) wh = wheel.Wheel(nrnd) bb = binbuilder.BinBuilder() bb.buildBins(wh) t = table.Table(100) game = roulettegame.RouletteGame(wh, t) pl = players.Passenger57(t) pl.setStake(100) pl.setRounds(10) while pl.playing(): game.cycle(pl) self.assertEqual(pl.roundsToGo, 0)
def test1_session(self): ''' Tests if the simulator.Simulatosession() returns the required list of stakes in a controlled simulation. ''' nrnd = NonRandom(1) wh = wheel.Wheel(nrnd) bb = binbuilder.BinBuilder() bb.buildBins(wh) t = table.Table(100) game = roulettegame.RouletteGame(wh, t) pl = players.Passenger57(t) sim = simulator.Simulator(pl, game) self.assertEqual(sim.session(), [90,80,70,60,50,40,30,20,10,0])
def test1_win(self): ''' Tests winning process. ''' nrnd = NonRandom(2) wh = wheel.Wheel(nrnd) bb = binbuilder.BinBuilder() bb.buildBins(wh) t = table.Table(100) game = roulettegame.RouletteGame(wh, t) pl = players.Passenger57(t) pl.setStake(100) pl.setRounds(10) self.assertEqual(pl.stake, 100) game.cycle(pl) self.assertEqual(pl.stake, 110)
def test3_outofmoney(self): ''' Tests if the cycle breaks when the Player's stake is zero ''' nrnd = NonRandom(1) wh = wheel.Wheel(nrnd) bb = binbuilder.BinBuilder() bb.buildBins(wh) t = table.Table(100) game = roulettegame.RouletteGame(wh, t) pl = players.Passenger57(t) pl.setStake(100) pl.setRounds(10) while pl.playing(): game.cycle(pl) self.assertEqual(pl.stake, 0)