Beispiel #1
0
def check_is_action_buttons(screen_area, stack_collection, db):
    current_stack.get_actual_game_data(screen_area, stack_collection, db)
    row = session_log.get_last_row_from_log_session(screen_area, db)
    try:
        reaction_to_opponent = get_reaction_to_opponent(row, db)
        if not isinstance(reaction_to_opponent, str):
            reaction_to_opponent = 'fold'
    except:
        reaction_to_opponent = 'fold'
    last_opponnet_action = image_processing.search_last_opponent_action(screen_area, db)
    if not isinstance(last_opponnet_action, str):
        hand = row[0]['hand']
        hand = hand_converting(hand)
        bb_count = last_opponnet_action['alias']
        if reaction_to_opponent == 'fold' and bb_count in ('1', '2') and \
                int(row[0]['current_stack']) >= 17 and hand in available_hand_to_call_min3bet():
            reaction_to_opponent = 'call'
    if reaction_to_opponent == 'push':
        keyboard.press('q')
    elif reaction_to_opponent == 'call':
        keyboard.press('c')
    else:
        keyboard.press('f')
    session_log.update_action_log_session(reaction_to_opponent, str(screen_area), db)
    return True
Beispiel #2
0
def raise_cbet_action(screen_area, hand_value, combination_value,
                      opponent_reaction, stack, stack_collection, db):
    if combination_value == 'premium' or hand_value == 'weak_top_pair':
        keyboard.press('q')
        session_log.update_action_log_session('push', str(screen_area), db)
    elif int(
            stack
    ) <= 10 and hand_value != 'trash' and current_stack.search_current_stack(
            screen_area, stack_collection, db) <= 10:
        keyboard.press('q')
        session_log.update_action_log_session('push', str(screen_area), db)
    elif combination_value == 'draw' and pot_odds.check_is_call_valid(
            screen_area, hand_value, 'turn', stack_collection, db):
        keyboard.press('c')
        session_log.update_action_log_session('cc_postflop', str(screen_area),
                                              db)
    elif combination_value in ('other',
                               'composite') and opponent_reaction in ('1', '2',
                                                                      '3'):
        keyboard.press('c')
        session_log.update_action_log_session('cc_postflop', str(screen_area),
                                              db)
    else:
        keyboard.press('f')
        session_log.update_action_log_session('fold', str(screen_area), db)
    return True
Beispiel #3
0
def get_opponent_flop_reaction(screen_area, stack_collection, db):
    hand_value = session_log.get_hand_value(screen_area, db)
    combination_value = db_query.get_combination_value('flop', hand_value, db)
    stack = session_log.get_last_row_from_log_session(screen_area, db)[0][1]
    if hand_value is None:
        return False
    opponent_reaction = image_processing.search_last_opponent_action(
        screen_area, db)
    if not isinstance(opponent_reaction, str):
        opponent_reaction = opponent_reaction['alias']
    if opponent_reaction in ('1', '2', '3') and combination_value in ('draw', 'other', 'composite') \
            and int(stack) <= 13 and current_stack.search_current_stack(screen_area, stack_collection, db) <= 13:
        keyboard.press('q')
        session_log.update_action_log_session('push', str(screen_area), db)
    elif combination_value == 'draw' and pot_odds.check_is_call_valid(
            screen_area, hand_value, 'turn', stack_collection, db):
        keyboard.press('c')
        session_log.update_action_log_session('cc_postflop', str(screen_area),
                                              db)
    elif opponent_reaction in ('1', '2') and hand_value not in (
            'trash', 'gutshot', 'bottom_pair',
            'over_cards') and combination_value != 'draw':
        keyboard.press('c')
        session_log.update_action_log_session('cc_postflop', str(screen_area),
                                              db)
    elif opponent_reaction == 'check':
        keyboard.press('h')
        session_log.update_action_log_session('cc_postflop', str(screen_area),
                                              db)
    else:
        keyboard.press('f')
        session_log.update_action_log_session('fold', str(screen_area), db)
    return True
Beispiel #4
0
def check_is_raise_river_value_bet(screen_area, db):
    opponent_reaction = image_processing.search_last_opponent_action(screen_area, db)
    if opponent_reaction in ('1', '2'):
        keyboard.press('c')
        session_log.update_action_log_session('end', str(screen_area), db)
    else:
        keyboard.press('f')
        session_log.update_action_log_session('fold', str(screen_area), db)
    return True
Beispiel #5
0
def check_is_fold(screen_area, x_coordinate, y_coordinate, width, height, image_path, db):
    last_hand = session_log.get_last_row_from_log_session(screen_area, db)[0]['hand']
    last_hand = last_hand[:4]
    image_processing.imaging(x_coordinate, y_coordinate, width, height, image_path, screen_area, db)
    cur_hand = image_processing.search_cards(screen_area, db_query.get_cards(db), 4, db)
    if last_hand != cur_hand:
        folder_name = IMAGES_FOLDER + '/' + str(datetime.datetime.now().date())
        image_name = str(math.floor(time.time())) + ".png"
        session_log.update_action_log_session('end', str(screen_area), db)
        current_stack.save_stack_image(screen_area, image_name, folder_name, db)
        check_conditions_before_insert(cur_hand, int(screen_area), db_query.get_stack_images(db), image_name, folder_name, db)
        get_decision(screen_area, db)
        return True
Beispiel #6
0
def check_is_flop(screen_area, image_name, folder_name, flop_deck, stack_collection, db):
    element_area = save_element(screen_area, 'green_board_area', db)
    if image_processing.search_element(element_area, ['green_board'], 'green_board/', db) is False:
        last_row = session_log.get_last_row_from_log_session(screen_area, db)
        hand = last_row[0][0]
        stack = last_row[0][1]
        action = last_row[0][3]
        is_headsup = last_row[0][4]
        if is_headsup == 0 and headsup.search_opponent_card(screen_area, db, is_postflop=True)[0] == 1:
            is_headsup = 1
            session_log.update_is_headsup_postflop(str(screen_area), is_headsup, db)
        if len(hand) == 4:
            if action == 'open':
                stack = current_stack.get_actual_game_data(screen_area, stack_collection, db)
            flop.make_flop_decision(screen_area, hand, image_name, folder_name, stack, action, is_headsup,
                                    flop_deck, stack_collection, db)
        else:
            session_log.update_action_log_session('end', str(screen_area), db)
        return True
Beispiel #7
0
def get_decision(screen_area, db):
    try:
        row = get_action_from_preflop_chart(screen_area, db)
        action = row[0]
        stack = row[1]
        if action == 'push':
            keyboard.press('q')
        elif action == 'fold':
            keyboard.press('f')
        elif action == 'open':
            if int(stack) > 17:
                keyboard.press('r')
            else:
                keyboard.press('o')
        elif action == 'call':
            keyboard.press('c')
        elif action == 'check':
            keyboard.press('h')
        session_log.update_action_log_session(action, str(screen_area), db)
    except Exception as e:
        error_log.error_log('getDecision', str(e))
        print(e)
Beispiel #8
0
def start():
    global APP_STATE
    if not APP_STATE:
        APP_STATE = remote_control.get_app_state()
    for item in SCREEN_DATA:
        mouse.move_mouse(item['x_mouse'], item['y_mouse'])
        if metka.search_bar(item['screen_area'], DB):
            image_name = str(math.floor(time.time())) + ".png"
            image_path = os.path.join(IMAGES_FOLDER,
                                      str(datetime.datetime.now().date()),
                                      str(item['screen_area']), image_name)
            last_row_action = session_log.get_last_row_action_from_log_session(
                item['screen_area'], DB)
            if last_row_action in ('push', 'fold', 'end'):
                image_processing.imaging(item['x_coordinate'],
                                         item['y_coordinate'], item['width'],
                                         item['height'], image_path,
                                         item['screen_area'], DB)
                hand = image_processing.search_cards(item['screen_area'], DECK,
                                                     4, DB)
                introduction.check_conditions_before_insert(
                    hand, item['screen_area'], STACK_COLLECTION, image_name,
                    FOLDER_NAME, DB)
                introduction.get_decision(item['screen_area'], DB)
            elif last_row_action in ('open', 'call', 'check'):
                introduction.action_after_open(
                    item['x_coordinate'], item['y_coordinate'], item['width'],
                    item['height'], image_path, item['screen_area'],
                    last_row_action, image_name, FOLDER_NAME, DECK,
                    STACK_COLLECTION, DB)
            elif last_row_action == 'cbet':
                postflop.action_after_cbet(item['x_coordinate'],
                                           item['y_coordinate'], item['width'],
                                           item['height'], image_path,
                                           item['screen_area'], DECK,
                                           STACK_COLLECTION, DB)
            elif last_row_action in ('turn_cbet', 'river_cbet'):
                postflop.action_after_turn_cbet(item['x_coordinate'],
                                                item['y_coordinate'],
                                                item['width'], item['height'],
                                                image_path,
                                                item['screen_area'], DECK,
                                                STACK_COLLECTION, DB)
            elif last_row_action == 'cc_postflop':
                postflop.action_after_cc_postflop(item['screen_area'], DECK,
                                                  item['x_coordinate'],
                                                  item['y_coordinate'],
                                                  item['width'],
                                                  item['height'], image_path,
                                                  STACK_COLLECTION, DB)
            elif last_row_action == 'value_bet':
                postflop.action_after_value_bet(item['screen_area'],
                                                item['x_coordinate'],
                                                item['y_coordinate'],
                                                item['width'], item['height'],
                                                image_path, DB)
            else:
                hand = session_log.get_last_row_from_log_session(
                    item['screen_area'], DB)
                if image_processing.check_current_hand(item['screen_area'],
                                                       hand[0]['hand'], DB):
                    introduction.get_decision(str(item['screen_area']), DB)
                else:
                    session_log.update_action_log_session(
                        'end', str(item['screen_area']), DB)
Beispiel #9
0
def river_action(screen_area, hand_value, combination_value, stack, action,
                 opponent_reaction, hand, stack_collection, db):
    if action in ('turn_cbet', 'river_cbet'):
        is_call_river_agression = pot_odds.check_is_call_after_opponent_river_agression(
            screen_area, hand_value, stack_collection, action, db)
        if combination_value != 'premium' and int(stack) >= 13:
            keyboard.press('h')
            session_log.update_action_log_session('cc_postflop',
                                                  str(screen_area), db)
        elif combination_value != 'premium' and int(stack) < 13:
            keyboard.press('v')
            session_log.update_action_log_session('river_cbet',
                                                  str(screen_area), db)
        elif action == 'river_cbet' and is_call_river_agression is True:
            keyboard.press('c')
            session_log.update_action_log_session('cc_postflop',
                                                  str(screen_area), db)
        elif action == 'river_cbet' and is_call_river_agression is False:
            keyboard.press('f')
            session_log.update_action_log_session('fold', str(screen_area), db)
        elif check_is_board_danger(hand) is False or hand_value == 'flush':
            keyboard.press('v')
            session_log.update_action_log_session('river_cbet',
                                                  str(screen_area), db)
        elif hand_value == 'straight' and check_is_four_flush_board(
                hand) is False:
            keyboard.press('v')
            session_log.update_action_log_session('river_cbet',
                                                  str(screen_area), db)
        elif image_processing.check_is_cbet_available(screen_area, db):
            keyboard.press('h')
            session_log.update_action_log_session('cc_postflop',
                                                  str(screen_area), db)
        else:
            if opponent_reaction in ('1', '2', '3'):
                keyboard.press('c')
                session_log.update_action_log_session('cc_postflop',
                                                      str(screen_area), db)
            else:
                keyboard.press('f')
                session_log.update_action_log_session('fold', str(screen_area),
                                                      db)
        return True
    if check_is_board_danger(hand) and hand_value in \
            ('top_pair', 'two_pairs', 'set', 'weak_top_pair', 'weak_flush'):
        if image_processing.check_is_cbet_available(screen_area, db):
            keyboard.press('h')
            session_log.update_action_log_session('cc_postflop',
                                                  str(screen_area), db)
        elif opponent_reaction in ('1', '2', '3'):
            keyboard.press('c')
            session_log.update_action_log_session('cc_postflop',
                                                  str(screen_area), db)
        else:
            keyboard.press('f')
            session_log.update_action_log_session('fold', str(screen_area), db)
    elif hand_value == 'straight' and check_is_four_flush_board(hand):
        if image_processing.check_is_cbet_available(screen_area, db):
            keyboard.press('h')
            session_log.update_action_log_session('cc_postflop',
                                                  str(screen_area), db)
        elif opponent_reaction in ('1', '2'):
            keyboard.press('c')
            session_log.update_action_log_session('cc_postflop',
                                                  str(screen_area), db)
        else:
            keyboard.press('f')
            session_log.update_action_log_session('fold', str(screen_area), db)
    elif image_processing.check_is_cbet_available(screen_area, db):
        if combination_value == 'premium' or hand_value == 'weak_top_pair':
            keyboard.press('v')
            session_log.update_action_log_session('river_cbet',
                                                  str(screen_area), db)
        elif combination_value == 'value' and check_is_board_danger(
                hand) is False:
            if current_stack.search_bank_stack(screen_area, db) <= 3:
                keyboard.press('j')
            else:
                keyboard.press('k')
            session_log.update_action_log_session('value_bet',
                                                  str(screen_area), db)
        elif int(stack) <= 10 and hand_value in ('middle_pair', 'low_two_pairs', 'second_pair') \
                and current_stack.search_current_stack(screen_area, stack_collection, db) <= 10:
            keyboard.press('q')
            session_log.update_action_log_session('push', str(screen_area), db)
        elif hand_value == 'weak_flush' and opponent_reaction in ('1', '2',
                                                                  '3'):
            keyboard.press('c')
            session_log.update_action_log_session('cc_postflop',
                                                  str(screen_area), db)
        elif combination_value == 'middle_pair':
            keyboard.press('h')
            session_log.update_action_log_session('cc_postflop',
                                                  str(screen_area), db)
        else:
            keyboard.press('f')
            session_log.update_action_log_session('fold', str(screen_area), db)
    else:
        if combination_value == 'premium' or hand_value == 'weak_top_pair':
            keyboard.press('v')
            session_log.update_action_log_session('river_cbet',
                                                  str(screen_area), db)
        elif (combination_value == 'value'
              or hand_value == 'weak_flush') and check_is_board_danger(
                  hand) is False and opponent_reaction in ('1', '2', '3'):
            keyboard.press('c')
            session_log.update_action_log_session('cc_postflop',
                                                  str(screen_area), db)
        elif int(stack) <= 10 and hand_value in ('middle_pair', 'low_two_pairs', 'second_pair') \
                and current_stack.search_current_stack(screen_area, stack_collection, db) <= 10:
            keyboard.press('q')
            session_log.update_action_log_session('push', str(screen_area), db)
        elif opponent_reaction in (
                '1',
                '2',
        ) and (hand_value == 'middle_pair'
               or hand_value.find('middle_pair') != -1):
            keyboard.press('c')
            session_log.update_action_log_session('cc_postflop',
                                                  str(screen_area), db)
        else:
            keyboard.press('f')
            session_log.update_action_log_session('fold', str(screen_area), db)
    return True
Beispiel #10
0
def turn_action(screen_area, hand_value, combination_value, stack,
                opponent_reaction, hand, stack_collection, db):
    if hand_value in ('top_pair', 'two_pairs', 'set',
                      'weak_top_pair') and check_is_board_danger(hand):
        if image_processing.check_is_cbet_available(screen_area, db):
            keyboard.press('h')
            session_log.update_action_log_session('cc_postflop',
                                                  str(screen_area), db)
        elif opponent_reaction in ('1', '2', '3'):
            keyboard.press('c')
            session_log.update_action_log_session('cc_postflop',
                                                  str(screen_area), db)
        else:
            keyboard.press('f')
            session_log.update_action_log_session('fold', str(screen_area), db)
    elif hand_value == 'straight' and check_is_four_flush_board(hand):
        if image_processing.check_is_cbet_available(screen_area, db):
            keyboard.press('h')
            session_log.update_action_log_session('cc_postflop',
                                                  str(screen_area), db)
        elif opponent_reaction in ('1', '2'):
            keyboard.press('c')
            session_log.update_action_log_session('cc_postflop',
                                                  str(screen_area), db)
        else:
            keyboard.press('f')
            session_log.update_action_log_session('fold', str(screen_area), db)
    elif image_processing.check_is_cbet_available(screen_area, db):
        if combination_value == 'premium':
            keyboard.press('v')
            session_log.update_action_log_session('turn_cbet',
                                                  str(screen_area), db)
        elif int(stack) <= 10 and combination_value in ('draw', 'other', 'composite') \
                and current_stack.search_current_stack(screen_area, stack_collection, db) <= 10:
            keyboard.press('q')
            session_log.update_action_log_session('push', str(screen_area), db)
        elif hand_value == 'weak_top_pair':
            keyboard.press('q')
            session_log.update_action_log_session('push', str(screen_area), db)
        else:
            keyboard.press('h')
            session_log.update_action_log_session('cc_postflop',
                                                  str(screen_area), db)
    else:
        if combination_value == 'premium':
            keyboard.press('v')
            session_log.update_action_log_session('turn_cbet',
                                                  str(screen_area), db)
        elif int(stack) <= 10 and (combination_value in ('draw', 'other', 'composite') or hand_value == 'weak_flush')\
                and current_stack.search_current_stack(screen_area, stack_collection, db) <= 10:
            keyboard.press('q')
            session_log.update_action_log_session('push', str(screen_area), db)
        elif combination_value == 'draw' and pot_odds.check_is_call_valid(
                screen_area, hand_value, 'turn', stack_collection, db):
            keyboard.press('c')
            session_log.update_action_log_session('cc_postflop',
                                                  str(screen_area), db)
        elif hand_value == 'weak_top_pair':
            keyboard.press('q')
            session_log.update_action_log_session('push', str(screen_area), db)
        elif opponent_reaction in ('1', '2', '3') and (combination_value in (
                'other', 'composite') or hand_value == 'weak_flush'):
            keyboard.press('c')
            session_log.update_action_log_session('cc_postflop',
                                                  str(screen_area), db)
        else:
            keyboard.press('f')
            session_log.update_action_log_session('fold', str(screen_area), db)
    return True
Beispiel #11
0
def flop_action(screen_area, action, hand_value, combination_value, stack,
                is_headsup, opponent_reaction, stack_collection, db):
    # if top_pair <= T
    if hand_value == 'weak_top_pair':
        keyboard.press('q')
        session_log.update_action_log_session('push', str(screen_area), db)
    elif action == 'open' and int(stack) > 12:
        if image_processing.check_is_cbet_available(screen_area, db):
            if combination_value == 'premium':
                keyboard.press('v')
                session_log.update_action_log_session('cbet', str(screen_area),
                                                      db)
            elif combination_value in ('other', 'draw', 'composite'):
                keyboard.press('b')
                session_log.update_action_log_session('cbet', str(screen_area),
                                                      db)
            elif hand_value == 'trash':
                if is_headsup == 1:
                    keyboard.press('k')
                    session_log.update_action_log_session(
                        'cbet', str(screen_area), db)
                else:
                    keyboard.press('h')
                    session_log.update_action_log_session(
                        'cc_postflop', str(screen_area), db)
        # if cbet unavailable
        else:
            if combination_value == 'premium':
                keyboard.press('v')
                session_log.update_action_log_session('cbet', str(screen_area),
                                                      db)
            elif combination_value == 'draw' and pot_odds.check_is_call_valid(
                    screen_area, hand_value, 'turn', stack_collection, db):
                keyboard.press('c')
                session_log.update_action_log_session('cc_postflop',
                                                      str(screen_area), db)
            elif combination_value in ('other', 'draw', 'composite'):
                if int(stack) <= 13 and opponent_reaction in ('1', '2', '3') \
                        and current_stack.search_current_stack(screen_area, stack_collection, db) <= 13:
                    keyboard.press('q')
                    session_log.update_action_log_session(
                        'push', str(screen_area), db)
                elif (hand_value in ('second_pair', 'middle_pair', 'low_two_pairs') or hand_value.find(
                        'second_pair') != -1) \
                        and opponent_reaction in ('1', '2'):
                    keyboard.press('c')
                    session_log.update_action_log_session(
                        'cc_postflop', str(screen_area), db)
                else:
                    keyboard.press('f')
                    session_log.update_action_log_session(
                        'fold', str(screen_area), db)
            elif combination_value == 'composite' and opponent_reaction in (
                    '1', '2', '3'):
                keyboard.press('q')
                session_log.update_action_log_session('push', str(screen_area),
                                                      db)
            else:
                keyboard.press('f')
                session_log.update_action_log_session('fold', str(screen_area),
                                                      db)
    # if action <> open
    else:
        if image_processing.check_is_cbet_available(screen_area, db):
            if combination_value == 'premium':
                keyboard.press('v')
                session_log.update_action_log_session('cbet', str(screen_area),
                                                      db)
            else:
                keyboard.press('h')
                session_log.update_action_log_session('cc_postflop',
                                                      str(screen_area), db)
        # if action <> open and cbet unavailable
        else:
            if hand_value == 'trash':
                keyboard.press('f')
                session_log.update_action_log_session('fold', str(screen_area),
                                                      db)
            elif combination_value == 'premium' and opponent_reaction in ('1',
                                                                          '2',
                                                                          '3'):
                keyboard.press('v')
                session_log.update_action_log_session('cbet', str(screen_area),
                                                      db)
            elif combination_value == 'premium':
                keyboard.press('q')
                session_log.update_action_log_session('push', str(screen_area),
                                                      db)
            elif int(stack) <= 13 and opponent_reaction in ('1', '2') and hand_value != 'trash' \
                    and current_stack.search_current_stack(screen_area, stack_collection, db) <= 13:
                keyboard.press('q')
                session_log.update_action_log_session('push', str(screen_area),
                                                      db)
            elif combination_value == 'draw' and pot_odds.check_is_call_valid(
                    screen_area, hand_value, 'turn', stack_collection, db):
                keyboard.press('c')
                session_log.update_action_log_session('cc_postflop',
                                                      str(screen_area), db)
            elif hand_value in ('second_pair', 'middle_pair', 'low_two_pairs'
                                ) and opponent_reaction in ('1', '2'):
                keyboard.press('c')
                session_log.update_action_log_session('cc_postflop',
                                                      str(screen_area), db)
            elif combination_value == 'composite' and opponent_reaction in (
                    '1', '2', '3'):
                keyboard.press('c')
                session_log.update_action_log_session('cc_postflop',
                                                      str(screen_area), db)
            else:
                keyboard.press('f')
                session_log.update_action_log_session('fold', str(screen_area),
                                                      db)