예제 #1
0
    def no_test_ranges(self):
        # preflop
        t, p, _, h, _ = init_table('tests/screenshots/709250829_PreFlop_0.png')
        d = reverse_init(t, h, p)
        d.preflop_table_analyser(t, h, p)

        self.assertEqual('3R1', t.preflop_sheet_name)

        preflop_state = CurrentHandPreflopState()
        bot_preflop_decision = 'Call'
        d = MagicMock()
        preflop_state.update_values(t, bot_preflop_decision, h, d)

        # river round 2
        t, p, _, h, _ = init_table('tests/screenshots/709250829_Flop_0.png')
        sheet_name = ''
        ranges = ''
        for abs_pos in range(5):
            if t.other_players[abs_pos]['status'] == 1:
                sheet_name = preflop_state.get_reverse_sheetname(abs_pos, t, h)
                ranges = preflop_state.get_rangecards_from_sheetname(
                    abs_pos, sheet_name, t, h, p)

        self.assertEqual('1', sheet_name)
        self.assertEqual(38, len(ranges))
예제 #2
0
    def test_preflop_state1(self):
        strategy = 'snowie1'

        # preflop
        t, p, gui_signals, h, logger = init_table('tests/screenshots/76s.png', strategy=strategy)
        p = StrategyHandler()
        p.read_strategy(strategy)
        l = MagicMock()
        t.totalPotValue = 0.5
        t.equity = 0.5
        t.checkButton = False
        d = Decision(t, h, p, l)
        t.isHeadsUp = True
        t.gameStage = "PreFlop"
        d.__init__(t, h, p, l)
        d.preflop_table_analyser(t, logger, h, p)
        preflop_state = CurrentHandPreflopState()
        bot_preflop_decision = 'Call'
        d = MagicMock()
        preflop_state.update_values(t, bot_preflop_decision, h, d)

        self.assertEqual(t.preflop_sheet_name, '6R4')

        # flop
        t, p, gui_signals, h, logger = init_table('tests/screenshots/76ss.png', strategy=strategy)
        for abs_pos in range(5):
            if t.other_players[abs_pos]['status'] == 1:
                sheet_name = preflop_state.get_reverse_sheetname(abs_pos, t, h)

        self.assertEqual('4', sheet_name)
예제 #3
0
    def no_test_preflop_state1(self):
        strategy = 'snowie1'

        # preflop
        t, p, _, h, _ = init_table('tests/screenshots/76s.png',
                                   strategy=strategy)
        p = StrategyHandler()
        p.read_strategy(strategy)
        lst = MagicMock()
        t.totalPotValue = 0.5
        t.equity = 0.5
        t.checkButton = False
        d = Decision(t, h, p, lst)
        t.isHeadsUp = True
        t.gameStage = "PreFlop"
        d.__init__(t, h, p, lst)
        d.preflop_table_analyser(t, h, p)
        preflop_state = CurrentHandPreflopState()
        bot_preflop_decision = 'Call'
        d = MagicMock()
        preflop_state.update_values(t, bot_preflop_decision, h, d)

        self.assertEqual(t.preflop_sheet_name, '6R4')

        # flop
        t, p, _, h, _ = init_table('tests/screenshots/76ss.png',
                                   strategy=strategy)
        sheet_name = ''
        for abs_pos in range(5):
            if t.other_players[abs_pos]['status'] == 1:
                sheet_name = preflop_state.get_reverse_sheetname(abs_pos, t, h)

        self.assertEqual('4', sheet_name)
예제 #4
0
    def test_ranges_call_column(self):
        # preflop
        t, p, gui_signals, h, logger = init_table('tests/screenshots/KQ2.png')
        reverse_init(t,h,p,logger)
        preflop_state = CurrentHandPreflopState()
        bot_preflop_decision = 'Bet'
        d = MagicMock()
        preflop_state.update_values(t, bot_preflop_decision, h, d)
        t, p, gui_signals, h, logger = init_table('tests/screenshots/KQ.png')
        for abs_pos in range(5):
            if t.other_players[abs_pos]['status'] == 1:
                sheet_name = preflop_state.get_reverse_sheetname(abs_pos, t, h)
                ranges = preflop_state.get_rangecards_from_sheetname(abs_pos, sheet_name, t, h, p)

        self.assertEqual('42R5', sheet_name)
        self.assertEqual("Call", preflop_state.range_column_name)
예제 #5
0
    def test_reversetable_88(self):
        strategy = 'Snowie3'
        # preflop
        t, p, gui_signals, h, logger = init_table('tests/screenshots/88.png', strategy=strategy)
        d = reverse_init(t, h, p, logger)
        preflop_state = CurrentHandPreflopState()
        bot_preflop_decision = 'Bet'
        d = MagicMock()
        preflop_state.update_values(t, bot_preflop_decision, h, d)

        # river round 2
        t, p, gui_signals, h, logger = init_table('tests/screenshots/88F.png', strategy=strategy)
        for abs_pos in range(5):
            if t.other_players[abs_pos]['status'] == 1:
                sheet_name = preflop_state.get_reverse_sheetname(abs_pos, t, h)

        self.assertEqual('6R1', sheet_name)
예제 #6
0
    def test_ranges_call_column(self):
        # preflop
        t, p, gui_signals, h, logger = init_table('tests/screenshots/KQ2.png')
        reverse_init(t, h, p, logger)
        preflop_state = CurrentHandPreflopState()
        bot_preflop_decision = 'Bet'
        d = MagicMock()
        preflop_state.update_values(t, bot_preflop_decision, h, d)
        t, p, gui_signals, h, logger = init_table('tests/screenshots/KQ.png')
        for abs_pos in range(5):
            if t.other_players[abs_pos]['status'] == 1:
                sheet_name = preflop_state.get_reverse_sheetname(abs_pos, t, h)
                ranges = preflop_state.get_rangecards_from_sheetname(
                    abs_pos, sheet_name, t, h, p)

        self.assertEqual('42R5', sheet_name)
        self.assertEqual("Call", preflop_state.range_column_name)
예제 #7
0
    def test_preflop_state2(self):
        strategy = 'snowie1'

        # preflop
        t, p, gui_signals, h, logger = init_table('tests/screenshots/458770525_PreFlop_0.png', strategy=strategy)
        d = reverse_init(t, h, p, logger)
        preflop_state = CurrentHandPreflopState()
        bot_preflop_decision = 'Call'
        d = MagicMock()
        preflop_state.update_values(t, bot_preflop_decision, h, d)

        # flop
        t, p, gui_signals, h, logger = init_table('tests/screenshots/458770525_Flop_0.png', strategy=strategy)
        for abs_pos in range(5):
            if t.other_players[abs_pos]['status'] == 1:
                sheet_name = preflop_state.get_reverse_sheetname(abs_pos, t, h)

        self.assertEqual('3', sheet_name)
예제 #8
0
    def test_reversetable_88(self):
        strategy = 'Snowie3'
        # preflop
        t, p, gui_signals, h, logger = init_table('tests/screenshots/88.png',
                                                  strategy=strategy)
        d = reverse_init(t, h, p, logger)
        preflop_state = CurrentHandPreflopState()
        bot_preflop_decision = 'Bet'
        d = MagicMock()
        preflop_state.update_values(t, bot_preflop_decision, h, d)

        # river round 2
        t, p, gui_signals, h, logger = init_table('tests/screenshots/88F.png',
                                                  strategy=strategy)
        for abs_pos in range(5):
            if t.other_players[abs_pos]['status'] == 1:
                sheet_name = preflop_state.get_reverse_sheetname(abs_pos, t, h)

        self.assertEqual('6R1', sheet_name)
예제 #9
0
def test_reverse_sheetname():
    log = logging.getLogger(__name__)
    # Get table_dict
    table_scraper_name = 'GG_6TABLE'
    table_dict = mongo.get_table(table_scraper_name)
    # Mock signal
    gui_signals = MagicMock()
    # Game logger
    game_logger = GameLogger()

    preflop_state = CurrentHandPreflopState()
    h = History()

    preflop_url = get_dir(os.path.join('tools', 'preflop.xlsx'))
    # mongoclient = MongoClient(f'mongodb://*****:*****@dickreuter.com/neuron_poker')
    # mongodb = mongoclient.neuron_poker
    # cursor = mongodb.internal.find()
    # c = cursor.next()
    # preflop_url = c['preflop_url']
    # log.info(f'preflop_url: {preflop_url}')
    h.preflop_sheet = pd.read_excel(preflop_url, sheet_name=None)
    p = StrategyHandler()
    p.read_strategy()  # Read default strategy.
    t = TableScreenBased(p, table_dict, gui_signals, game_logger, 0.0)
    t.dealer_position = 4
    t.position_utg_plus = t.get_utg_from_abs_pos(0, t.dealer_position)  # 5

    preflop_state.reset()
    # preflop_state.other_players = deepcopy(t.other_players)
    preflop_state.bot_preflop_position_utg = t.position_utg_plus  # 5
    preflop_state.bot_preflop_decision = 'Bet'
    preflop_state.preflop_raiser_positions.append(5)
    # preflop_state.preflop_raiser_positions.append(4)
    # preflop_state.preflop_caller_positions.append(5)
    preflop_state.rounds = 0

    for abs_pos in [5]:
        sheet_name = preflop_state.get_reverse_sheetname(abs_pos, t, h)
        log.info(f'abs_pos:{abs_pos}, sheet_name: {sheet_name}')
        ranges = preflop_state.get_rangecards_from_sheetname(
            abs_pos, sheet_name, t, h, p)
        log.info(f'{ranges}')
예제 #10
0
    def test_incorrect_second_round(self):
        # preflop
        t, p, gui_signals, h, logger = init_table('tests/screenshots/3R12.png')
        reverse_init(t,h,p,logger)
        preflop_state = CurrentHandPreflopState()
        bot_preflop_decision = 'Bet'
        d = MagicMock()
        d = MagicMock()
        preflop_state.update_values(t, bot_preflop_decision, h, d)
        t, p, gui_signals, h, logger = init_table('tests/screenshots/3R1.png')
        reverse_sheet_names=[]
        for abs_pos in range(5):
            if t.other_players[abs_pos]['status'] == 1:
                sheet_name = preflop_state.get_reverse_sheetname(abs_pos, t, h)
                ranges = preflop_state.get_rangecards_from_sheetname(abs_pos, sheet_name, t, h, p)
                reverse_sheet_names.append(sheet_name)

        self.assertEqual('3R1', reverse_sheet_names[0])
        self.assertEqual('6R1', reverse_sheet_names[1])
        self.assertEqual("Call", preflop_state.range_column_name)
예제 #11
0
    def test_ranges_2nd_round(self):
        # preflop
        t, p, gui_signals, h, logger = init_table('tests/screenshots/709250829_PreFlop_0.png')
        d = reverse_init(t, h, p, logger)

        self.assertEqual('3R1', t.preflop_sheet_name)

        preflop_state = CurrentHandPreflopState()
        bot_preflop_decision = 'Bet'
        d = MagicMock()
        preflop_state.update_values(t, bot_preflop_decision, h, d)

        # flop after 2nd round preflop
        t, p, gui_signals, h, logger = init_table('tests/screenshots/709250829_Flop_0.png')
        for abs_pos in range(5):
            if t.other_players[abs_pos]['status'] == 1:
                sheet_name = preflop_state.get_reverse_sheetname(abs_pos, t, h)
                ranges = preflop_state.get_rangecards_from_sheetname(abs_pos, sheet_name, t, h, p)

        self.assertEqual('12R3', sheet_name)
예제 #12
0
    def no_test_incorrect_second_round(self):
        # preflop
        t, p, _, h, _ = init_table('tests/screenshots/3R12.png')
        reverse_init(t, h, p)
        preflop_state = CurrentHandPreflopState()
        bot_preflop_decision = 'Bet'
        d = MagicMock()
        preflop_state.update_values(t, bot_preflop_decision, h, d)
        t, p, _, h, _ = init_table('tests/screenshots/3R1.png')
        reverse_sheet_names = []
        for abs_pos in range(5):
            if t.other_players[abs_pos]['status'] == 1:
                sheet_name = preflop_state.get_reverse_sheetname(abs_pos, t, h)
                preflop_state.get_rangecards_from_sheetname(
                    abs_pos, sheet_name, t, h, p)
                reverse_sheet_names.append(sheet_name)

        self.assertEqual('3R1', reverse_sheet_names[0])
        self.assertEqual('6R1', reverse_sheet_names[1])
        self.assertEqual("Call", preflop_state.range_column_name)
예제 #13
0
    def test_preflop_state2(self):
        strategy = 'snowie1'

        # preflop
        t, p, gui_signals, h, logger = init_table(
            'tests/screenshots/458770525_PreFlop_0.png', strategy=strategy)
        d = reverse_init(t, h, p, logger)
        preflop_state = CurrentHandPreflopState()
        bot_preflop_decision = 'Call'
        d = MagicMock()
        preflop_state.update_values(t, bot_preflop_decision, h, d)

        # flop
        t, p, gui_signals, h, logger = init_table(
            'tests/screenshots/458770525_Flop_0.png', strategy=strategy)
        for abs_pos in range(5):
            if t.other_players[abs_pos]['status'] == 1:
                sheet_name = preflop_state.get_reverse_sheetname(abs_pos, t, h)

        self.assertEqual('3', sheet_name)
예제 #14
0
    def no_test_ranges_2nd_round(self):
        # preflop
        t, p, _, h, _ = init_table('tests/screenshots/709250829_PreFlop_0.png')
        reverse_init(t, h, p)

        self.assertEqual('3R1', t.preflop_sheet_name)

        preflop_state = CurrentHandPreflopState()
        bot_preflop_decision = 'Bet'
        d = MagicMock()
        preflop_state.update_values(t, bot_preflop_decision, h, d)

        # flop after 2nd round preflop
        t, p, _, h, _ = init_table('tests/screenshots/709250829_Flop_0.png')
        sheet_name = ''
        for abs_pos in range(5):
            if t.other_players[abs_pos]['status'] == 1:
                sheet_name = preflop_state.get_reverse_sheetname(abs_pos, t, h)
                preflop_state.get_rangecards_from_sheetname(
                    abs_pos, sheet_name, t, h, p)

        self.assertEqual('12R3', sheet_name)
예제 #15
0
    def no_test_reversetable_76(self):
        strategy = 'Snowie3'
        # preflop
        t, p, _, h, _ = init_table('tests/screenshots/76ss.png',
                                   strategy=strategy)
        d = reverse_init(t, h, p)
        d.preflop_table_analyser(t, h, p)

        self.assertEqual('6R4', t.preflop_sheet_name)

        preflop_state = CurrentHandPreflopState()
        bot_preflop_decision = 'Call'
        d = MagicMock()
        preflop_state.update_values(t, bot_preflop_decision, h, d)

        # river round 2
        t, p, _, h, _ = init_table('tests/screenshots/76s.png',
                                   strategy=strategy)
        sheet_name = ''
        for abs_pos in range(5):
            if t.other_players[abs_pos]['status'] == 1:
                sheet_name = preflop_state.get_reverse_sheetname(abs_pos, t, h)

        self.assertEqual('4', sheet_name)