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
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
def check_is_raise_cbet(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) opponent_reaction = image_processing.search_last_opponent_action(screen_area, db) stack = session_log.get_last_row_from_log_session(screen_area, db)[0]['current_stack'] if not isinstance(opponent_reaction, str): opponent_reaction = opponent_reaction['alias'] if raise_cbet_action(screen_area, hand_value, combination_value, opponent_reaction, stack, stack_collection, db): return True
def check_is_turn(screen_area, deck, stack_collection, db): element_area = introduction.save_element(screen_area, 'turn_area', db) if image_processing.search_element(element_area, ['turn'], 'green_board/', db) is False: if len(session_log.get_actual_hand(screen_area, db)) == 10: turn = image_processing.search_cards(element_area, deck, 2, db) session_log.update_hand_after_turn(str(screen_area), turn, db) last_row = session_log.get_last_row_from_log_session(screen_area, db) hand = last_row[0][0] stack = current_stack.get_actual_game_data(screen_area, stack_collection, db) if make_turn_decision(screen_area, hand, stack, stack_collection, db): return True return False
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
def check_is_river(screen_area, deck, stack_collection, db): element_area = introduction.save_element(screen_area, 'river_area', db) if image_processing.search_element(element_area, ['river'], 'green_board/', db) is False: if len(session_log.get_actual_hand(screen_area, db)) == 12: river = image_processing.search_cards(element_area, deck, 2, db) session_log.update_hand_after_turn(str(screen_area), river, db) 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] if make_river_decision(screen_area, hand, stack, action, stack_collection, db): return True return False
def get_actual_game_data(screen_area, stack_collection, db): row = session_log.get_last_row_from_log_session(screen_area, db) position = row[0]['current_position'] hand = row[0]['hand'] opponent_data = processing_opponent_data(screen_area, stack_collection, db) is_headsup = opponent_data[0] if position == 'button': is_headsup = 0 stack = opponent_data[1] stack = convert_stack(stack) if len(hand) > 4: session_log.update_is_headsup_postflop(str(screen_area), is_headsup, db) session_log.update_current_stack_log_session(str(screen_area), str(stack), db) return stack
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
def get_action_from_preflop_chart(screen_area, db): row = session_log.get_last_row_from_log_session(screen_area, db) last_opponent_action = row[0]['last_opponent_action'] hand = hand_converting(row[0]['hand']) stack = int(row[0]['current_stack']) position = row[0]['current_position'] is_headsup = row[0]['is_headsup'] if 0 < stack <= 7: return sklansky_chubukov.get_action(hand, stack, last_opponent_action, position, db) elif stack == 0: data = ['push'] data.append(stack) return data if last_opponent_action is None: last_opponent_action = ' is null' else: last_opponent_action = " = '" + last_opponent_action + '\'' data = db_query.get_action_from_preflop_chart(hand, position, is_headsup, last_opponent_action, stack, db) if len(data) == 0: return sklansky_chubukov.get_action(hand, stack, last_opponent_action, position, db) data = [data[0]['action']] data.append(stack) return data
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)