Beispiel #1
0
    def test_Wheel(self):
        """
        http://www.itmaybeahack.com/book/oodesign-python-2.1/html/roulette/wheel.html#the-random-bin-selection-responsibility

        Wheel Deliverables
        A class which performs a unit test of building the Wheel class. The unit test should create
        several instances of Outcome, two instances of Bin, and an instance of Wheel. The unit test
        should establish that Bins can be added to the Wheel. A Non-Random Random Number Generator
        class, to be used for testing. A class which tests the Wheel and NonRandom class by
        selecting values from a Wheel object.
        """

        outcome_one = Outcome("Red", 1)
        outcome_two = Outcome("Corner", 2)
        outcome_three = Outcome("Black", 3)
        outcome_four = Outcome("Street", 4)

        nonrandom = NonRandom()
        nonrandom.set_seed(1)

        wheel_one = Wheel(nonrandom)
        wheel_one.add_outcome(1, outcome_one)
        wheel_one.add_outcome(2, outcome_two)
        wheel_one.next()

        self.assertTrue(wheel_one.next(), outcome_one)

        # test get_outcome
        self.wheel_two = Wheel(nonrandom)
        BB = BinBuilder()
        BB.build_bins(self.wheel_two)
def test_split_bets():
    wheel = Wheel()
    bb = BinBuilder()

    bb.generate_split_bets(wheel)
    for r in range(12):
        # left-right splits
        n = 3 * r + 1
        out = Outcome(f'{n} {n + 1}', 17)
        assert out in wheel.get(n) and out in wheel.get(n + 1)

        n = 3 * r + 2
        out = Outcome(f'{n} {n + 1}', 17)
        assert out in wheel.get(n) and out in wheel.get(n + 1)

        # top-down splits
        if r == 11:
            break
        else:
            n = 3 * r + 1
            out = Outcome(f'{n} {n + 3}', 17)
            assert out in wheel.get(n) and out in wheel.get(n + 3)

            n += 1
            out = Outcome(f'{n} {n + 3}', 17)
            assert out in wheel.get(n) and out in wheel.get(n + 3)

            n += 1
            out = Outcome(f'{n} {n + 3}', 17)
            assert out in wheel.get(n) and out in wheel.get(n + 3)
Beispiel #3
0
    def test_Wheel(self):
        """
        http://www.itmaybeahack.com/book/oodesign-python-2.1/html/roulette/wheel.html#the-random-bin-selection-responsibility

        Wheel Deliverables
        A class which performs a unit test of building the Wheel class. The unit test should create
        several instances of Outcome, two instances of Bin, and an instance of Wheel. The unit test
        should establish that Bins can be added to the Wheel. A Non-Random Random Number Generator
        class, to be used for testing. A class which tests the Wheel and NonRandom class by
        selecting values from a Wheel object.
        """

        outcome_one = Outcome("Red", 1)
        outcome_two = Outcome("Corner", 2)
        outcome_three = Outcome("Black", 3)
        outcome_four = Outcome("Street", 4)

        nonrandom = NonRandom()
        nonrandom.set_seed(1)

        wheel_one = Wheel(nonrandom)
        wheel_one.add_outcome(1, outcome_one)
        wheel_one.add_outcome(2, outcome_two)
        wheel_one.next()

        self.assertTrue(wheel_one.next(), outcome_one )

        # test get_outcome
        self.wheel_two = Wheel(nonrandom)
        BB = BinBuilder()
        BB.build_bins(self.wheel_two)
Beispiel #4
0
 def setUp(self):
     self.nonrandom = NonRandom()
     self.nonrandom.set_seed(1)  # red
     wheel = Wheel(self.nonrandom)
     self.table = Table(limit=100)
     bin_builder = BinBuilder()
     bin_builder.build_bins(wheel)
     self.game = RouletteGame(wheel, self.table)
Beispiel #5
0
 def setUp(self ):
     self.nonrandom = NonRandom()
     self.nonrandom.set_seed(1) # red
     wheel = Wheel(self.nonrandom)
     self.table = Table(limit=100)
     bin_builder = BinBuilder()
     bin_builder.build_bins(wheel)
     self.game = RouletteGame(wheel, self.table)
Beispiel #6
0
 def setUp(self):
     # wheel -- returns bin 2
     self.nonrandom = NonRandom()
     self.nonrandom.set_seed(2)  # black
     wheel = Wheel(self.nonrandom)
     self.table = Table(limit=100)
     bin_builder = BinBuilder()
     bin_builder.build_bins(wheel)
     self.game = RouletteGame(wheel, self.table)
Beispiel #7
0
 def setUp(self):
     # wheel -- returns bin 2
     self.nonrandom = NonRandom()
     self.nonrandom.set_seed(2) # black
     wheel = Wheel(self.nonrandom)
     self.table = Table(limit=100)
     bin_builder = BinBuilder()
     bin_builder.build_bins(wheel)
     self.game = RouletteGame(wheel, self.table)
def test_bin_staight_bets():
    wheel = Wheel()
    bb = BinBuilder()

    bb.generate_straight_bets(wheel)

    for i, bin in enumerate(wheel.bins):
        assert 1 == len(bin)
        nm = f'{i}' if i < 37 else '00'
        assert Outcome(nm, 35) in bin
def test_generate_doze_bets():
    wheel = Wheel()
    bb = BinBuilder()
    bb.generate_dozen_bets(wheel)

    for i, bin in enumerate(wheel.bins):
        if i == 0 or i == 37:
            assert 0 == len(bin)
        else:
            out = Outcome(f'Dozen {math.ceil(i/12)}', 2)
            assert out in bin
def test_wheel_next():
    wheel = Wheel(seed=1)
    bb = BinBuilder()

    # bb.generate_straight_bets(wheel)
    bb.build_bins(wheel)
    # wheel.add_outcome(0, Outcome(f'0', 35))
    ct = 10
    expected_seq = [8, 36, 4, 16, 7, 31, 28, 30, 24, 13]
    for num in expected_seq:
        i, bin = wheel.next()
        assert num == i
def test_line_bets():
    wheel = Wheel()
    bb = BinBuilder()
    bb.generate_line_bets(wheel)
    for r in range(0, 11):
        n = 3 * r + 1
        line_out = Outcome(f'{n} {n + 1} {n + 2} {n + 3} {n + 4} {n + 5}', 5)
        assert line_out in wheel.get(n)
        assert line_out in wheel.get(n + 1)
        assert line_out in wheel.get(n + 2)
        assert line_out in wheel.get(n + 3)
        assert line_out in wheel.get(n + 4)
        assert line_out in wheel.get(n + 5)
def test_column_bets():
    wheel = Wheel()
    bb = BinBuilder()
    bb.generate_column_bets(wheel)

    col_one = Outcome(f'Column 1', 2)
    col_two = Outcome(f'Column 2', 2)
    col_thr = Outcome(f'Column 3', 2)
    outcomes = {1: col_one, 2: col_two, 0: col_thr}

    for i, bin in enumerate(wheel.bins):
        if i == 0 or i == 37:
            assert 0 == len(bin)
        else:
            out = outcomes[i % 3]
            assert out in bin
def test_street_bets():
    wheel = Wheel()
    bb = BinBuilder()

    bb.generate_street_bets(wheel)
    for i, bin in enumerate(wheel.bins):
        if i == 0 or i == 37:
            assert 0 == len(bin)
        else:
            assert 1 == len(bin)

    for i in range(1, 36, 3):
        out = Outcome(f'{i} {i + 1} {i + 2}', 11)
        assert out in wheel.get(i)
        assert out in wheel.get(i + 1)
        assert out in wheel.get(i + 2)
def test_corner_bets():
    wheel = Wheel()
    bb = BinBuilder()
    bb.generate_corner_bets(wheel)

    for r in range(0, 11):
        n = 3 * r + 1
        outcome = Outcome(f'{n} {n+1} {n+3} {n+4}', 8)
        assert outcome in wheel.get(n)
        assert outcome in wheel.get(n + 1)
        assert outcome in wheel.get(n + 3)
        assert outcome in wheel.get(n + 4)

        n += 1
        outcome = Outcome(f'{n} {n + 1} {n + 3} {n + 4}', 8)
        assert outcome in wheel.get(n)
        assert outcome in wheel.get(n + 1)
        assert outcome in wheel.get(n + 3)
        assert outcome in wheel.get(n + 4)
def test_even_money_bets():
    wheel = Wheel()
    bb = BinBuilder()
    bb.generate_even_money_bets(wheel)
    # Red-Black
    reds = {1, 3, 5, 7, 9, 12, 14, 16, 18, 19, 21, 23, 25, 27, 30, 32, 34, 36}
    blacks = set(range(1, 37)) - reds
    red_out = Outcome('Red', 1)
    black_out = Outcome('Black', 1)

    # Even-Odd
    even_out = Outcome('Even', 1)
    odd_out = Outcome('Odd', 1)

    # Hi - Lo
    hi_out = Outcome('High', 1)
    lo_out = Outcome('Low', 1)

    for i, bin in enumerate(wheel.bins):
        if i == 0 or i == 37:
            assert 0 == len(bin)
        elif i < 19:
            assert lo_out in bin
        else:
            assert hi_out in bin

        if i == 0 or i == 37:
            assert 0 == len(bin)
        elif i % 2 == 0:
            assert even_out in bin
        else:
            assert odd_out in bin

        if i == 0 or i == 37:
            assert 0 == len(bin)
        elif i in reds:
            assert red_out in bin
        else:
            assert black_out in bin
Beispiel #16
0
    def test_game(self):
        log = logging.getLogger( "GameTestCase.test_game" )

        # make wheel
        self.nonrandom = NonRandom()
        self.nonrandom.set_seed(2)
        self.wheel = Wheel(self.nonrandom)
        # make BinBuilder and build bins for wheel
        bin_builder = BinBuilder()
        bin_builder.build_bins(self.wheel)
        # make table
        table = Table(limit=100)
        # make player
        _p57 = Passenger57(table=table, stake=100, rounds_to_go=100)
        # make game
        self.game = RouletteGame(self.wheel, table)

        # Test NonRandom
        self.assertEqual(id(self.wheel.next()), id(self.wheel.next()))

        # test game cycle with Passenger57
        for i in range(4):
            self.game.cycle(_p57)
Beispiel #17
0
    def test_game(self):
        log = logging.getLogger("GameTestCase.test_game")

        # make wheel
        self.nonrandom = NonRandom()
        self.nonrandom.set_seed(2)
        self.wheel = Wheel(self.nonrandom)
        # make BinBuilder and build bins for wheel
        bin_builder = BinBuilder()
        bin_builder.build_bins(self.wheel)
        # make table
        table = Table(limit=100)
        # make player
        _p57 = Passenger57(table=table, stake=100, rounds_to_go=100)
        # make game
        self.game = RouletteGame(self.wheel, table)

        # Test NonRandom
        self.assertEqual(id(self.wheel.next()), id(self.wheel.next()))

        # test game cycle with Passenger57
        for i in range(4):
            self.game.cycle(_p57)
def test_get_outcome():
    wheel = Wheel()
    bb = BinBuilder()
    bb.generate_even_money_bets(wheel)
    bb.generate_column_bets(wheel)

    assert Outcome('High', 1) == wheel.get_outcome('High')
    assert Outcome('Low', 1) == wheel.get_outcome('Low')
    assert Outcome('Red', 1) == wheel.get_outcome('Red')
    assert Outcome('Black', 1) == wheel.get_outcome('Black')

    assert Outcome('Column 1', 1) == wheel.get_outcome('Column 1')
    assert Outcome('Column 2', 1) == wheel.get_outcome('Column 2')
    assert Outcome('Column 3', 1) == wheel.get_outcome('Column 3')
def test_bet():
    wheel = Wheel()
    bin_builder = BinBuilder()
    bin_builder.build_even_money_bets(wheel, Outcome)
    b = Bet(588, wheel.get_outcome('Red'))
    assert 588 == b.win_amount()
Beispiel #20
0
    def test_BinBuilder(self):

        nonrandom = NonRandom()
        nonrandom.set_seed(1)

        wheel_one = Wheel(nonrandom)

        BB = BinBuilder()
        BB.build_bins(wheel_one)

        # maybe delete since it isn't asked for
        strait = BB.strait_bets()
        split = BB.split_bets()
        street = BB.street_bet()
        corner = BB.corner_bet()
        five = BB.five_bet()
        line = BB.line_bet()
        dozen = BB.dozen_bet()
        column = BB.column_bet()
        even = BB.even_money_bet()

        all_bin_methods_results = [strait, split, street, corner, five, line, dozen, column, even]
        len_all_outcomes = sum(list(len(i) for i in all_bin_methods_results))
Beispiel #21
0
    def test_BinBuilder(self):

        nonrandom = NonRandom()
        nonrandom.set_seed(1)

        wheel_one = Wheel(nonrandom)

        BB = BinBuilder()
        BB.build_bins(wheel_one)

        # maybe delete since it isn't asked for
        strait = BB.strait_bets()
        split = BB.split_bets()
        street = BB.street_bet()
        corner = BB.corner_bet()
        five = BB.five_bet()
        line = BB.line_bet()
        dozen = BB.dozen_bet()
        column = BB.column_bet()
        even = BB.even_money_bet()

        all_bin_methods_results = [
            strait, split, street, corner, five, line, dozen, column, even
        ]
        len_all_outcomes = sum(list(len(i) for i in all_bin_methods_results))
def test_bin_builder():
    wheel = Wheel()
    bin_builder = BinBuilder()
    #straightbet test
    bin_builder.build_straight_bet(wheel, Outcome)
    assert Outcome('0', 35) in wheel.get_bin(0)
    assert Outcome('00', 35) in wheel.get_bin(37)
    assert Outcome('1', 35) in wheel.get_bin(1)
    assert Outcome('36', 35) in wheel.get_bin(36)

    #splitbet test
    wheel = Wheel()
    bin_builder.build_split_bet(wheel, Outcome)
    assert Outcome('1-2', 17) in wheel.get_bin(1)
    assert Outcome('1-4', 17) in wheel.get_bin(1)
    assert Outcome('33-36', 17) in wheel.get_bin(36)
    assert Outcome('35-36', 17) in wheel.get_bin(36)

    #streetbet
    wheel = Wheel()
    bin_builder.build_street_bet(wheel, Outcome)
    assert Outcome('1-2-3', 11) in wheel.get_bin(1)
    assert Outcome('34-35-36', 11) in wheel.get_bin(36)

    #Cornerbet
    wheel = Wheel()
    bin_builder.build_corner_bets(wheel, Outcome)
    assert Outcome('1-2-4-5', 8) in wheel.get_bin(1)
    assert Outcome('4-5-7-8', 8) in wheel.get_bin(4)
    assert Outcome('5-6-8-9', 8) in wheel.get_bin(5)

    #linebet
    wheel = Wheel()
    bin_builder.build_line_bets(wheel, Outcome)
    assert Outcome('1-2-3-4-5-6', 5) in wheel.get_bin(1)
    assert 1 == len(wheel.get_bin(1))
    assert Outcome('1-2-3-4-5-6', 5) in wheel.get_bin(4)
    assert Outcome('4-5-6-7-8-9', 5) in wheel.get_bin(4)

    # dozen bet
    wheel = Wheel()
    bin_builder.build_dozen_bets(wheel, Outcome)
    assert Outcome('1-dozen', 2) in wheel.get_bin(1)
    assert Outcome('2-dozen', 2) in wheel.get_bin(17)
    assert Outcome('3-dozen', 2) in wheel.get_bin(36)

    #column bet
    wheel = Wheel()
    bin_builder.build_column_bets(wheel, Outcome)
    assert Outcome('1-column', 2) in wheel.get_bin(1)
    assert Outcome('2-column', 2) in wheel.get_bin(17)
    assert Outcome('3-column', 2) in wheel.get_bin(36)

    #evenbet
    wheel = Wheel()
    bin_builder.build_even_money_bets(wheel, Outcome)
    assert Outcome('Red', 1) in wheel.get_bin(1)
    assert Outcome('Low', 1) in wheel.get_bin(1)
    assert Outcome('Odd', 1) in wheel.get_bin(1)
    assert Outcome('Black', 1) in wheel.get_bin(17)
    assert Outcome('Low', 1) in wheel.get_bin(17)
    assert Outcome('Odd', 1) in wheel.get_bin(17)
    assert Outcome('Black', 1) in wheel.get_bin(17)
    assert Outcome('Red', 1) in wheel.get_bin(18)
    assert Outcome('Even', 1) in wheel.get_bin(18)
    assert Outcome('Low', 1) in wheel.get_bin(18)
    assert Outcome('Red', 1) in wheel.get_bin(36)
    assert Outcome('Even', 1) in wheel.get_bin(36)
    assert Outcome('High', 1) in wheel.get_bin(36)

    #fivebet
    wheel = Wheel()
    bin_builder.build_five_bet(wheel, Outcome)
    assert Outcome('00-0-1-2-3', 6) in wheel.get_bin(0)
    assert Outcome('00-0-1-2-3', 6) in wheel.get_bin(37)
Beispiel #23
0
 def setUp(self):
     self.wheel = Wheel()
     bb = BinBuilder()
     bb.build_bins(self.wheel)
Beispiel #24
0
from roulette import Game, Passenger57, PlayerEven, Table, Wheel, BinBuilder

if __name__ == '__main__':
    TABLE_MIN = 10
    table = Table(500, TABLE_MIN)
    wheel = Wheel()
    BinBuilder().build_bins(wheel)
    game = Game(wheel, table)
    playr = PlayerEven()
    playr.wallet = 10000
    round = 1

    while playr.is_playing() and playr.get_wallet() > TABLE_MIN:
        print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
        print(f'Round {round}: player wallet is {playr.get_wallet()}')
        game.cycle(playr)
        round += 1
        table.clear_bets()


    if playr.is_playing() is False:
        print(f"Thanks for playing: player final wallet is {playr.get_wallet()} {playr.is_playing()}")
    else:
        print(f"GAME OVER: player final wallet is {playr.get_wallet()} {playr.is_playing()}")