コード例 #1
0
ファイル: main.py プロジェクト: dickreuter/Poker
    def run(self):
        h = History()
        preflop_url, preflop_url_backup = u.get_preflop_sheet_url()
        try:
            h.preflop_sheet = pd.read_excel(preflop_url, sheetname=None)
        except:
            h.preflop_sheet = pd.read_excel(preflop_url_backup, sheetname=None)

        self.game_logger.clean_database()

        p = StrategyHandler()
        p.read_strategy()

        preflop_state = CurrentHandPreflopState()

        while True:
            if self.gui_signals.pause_thread:
                while self.gui_signals.pause_thread == True:
                    time.sleep(1)
                    if self.gui_signals.exit_thread == True: sys.exit()

            ready = False
            while (not ready):
                p.read_strategy()
                t = TableScreenBased(p, gui_signals, self.game_logger, version)
                mouse = MouseMoverTableBased(p.selected_strategy['pokerSite'])
                mouse.move_mouse_away_from_buttons_jump

                ready = t.take_screenshot(True, p) and \
                        t.get_top_left_corner(p) and \
                        t.check_for_captcha(mouse) and \
                        t.get_lost_everything(h, t, p, gui_signals) and \
                        t.check_for_imback(mouse) and \
                        t.get_my_cards(h) and \
                        t.get_new_hand(mouse, h, p) and \
                        t.get_table_cards(h) and \
                        t.upload_collusion_wrapper(p, h) and \
                        t.get_dealer_position() and \
                        t.get_snowie_advice(p, h) and \
                        t.check_fast_fold(h, p, mouse) and \
                        t.check_for_button() and \
                        t.get_round_number(h) and \
                        t.init_get_other_players_info() and \
                        t.get_other_player_names(p) and \
                        t.get_other_player_funds(p) and \
                        t.get_other_player_pots() and \
                        t.get_total_pot_value(h) and \
                        t.get_round_pot_value(h) and \
                        t.check_for_checkbutton() and \
                        t.get_other_player_status(p, h) and \
                        t.check_for_call() and \
                        t.check_for_betbutton() and \
                        t.check_for_allincall() and \
                        t.get_current_call_value(p) and \
                        t.get_current_bet_value(p)

            if not self.gui_signals.pause_thread:
                config = ConfigObj("config.ini")
                m = run_montecarlo_wrapper(p, self.gui_signals, config, ui, t, self.game_logger, preflop_state, h)
                d = Decision(t, h, p, self.game_logger)
                d.make_decision(t, h, p, self.logger, self.game_logger)
                if self.gui_signals.exit_thread: sys.exit()

                self.update_most_gui_items(preflop_state, p, m, t, d, h, self.gui_signals)

                self.logger.info(
                    "Equity: " + str(t.equity * 100) + "% -> " + str(int(t.assumedPlayers)) + " (" + str(
                        int(t.other_active_players)) + "-" + str(int(t.playersAhead)) + "+1) Plr")
                self.logger.info("Final Call Limit: " + str(d.finalCallLimit) + " --> " + str(t.minCall))
                self.logger.info("Final Bet Limit: " + str(d.finalBetLimit) + " --> " + str(t.minBet))
                self.logger.info(
                    "Pot size: " + str((t.totalPotValue)) + " -> Zero EV Call: " + str(round(d.maxCallEV, 2)))
                self.logger.info("+++++++++++++++++++++++ Decision: " + str(d.decision) + "+++++++++++++++++++++++")

                mouse_target = d.decision
                if mouse_target == 'Call' and t.allInCallButton:
                    mouse_target = 'Call2'
                mouse.mouse_action(mouse_target, t.tlc)

                t.time_action_completed = datetime.datetime.utcnow()

                filename = str(h.GameID) + "_" + str(t.gameStage) + "_" + str(h.round_number) + ".png"
                self.logger.debug("Saving screenshot: " + filename)
                pil_image = t.crop_image(t.entireScreenPIL, t.tlc[0], t.tlc[1], t.tlc[0] + 950, t.tlc[1] + 650)
                pil_image.save("log/screenshots/" + filename)

                self.gui_signals.signal_status.emit("Logging data")

                t_log_db = threading.Thread(name='t_log_db', target=self.game_logger.write_log_file, args=[p, h, t, d])
                t_log_db.daemon = True
                t_log_db.start()
                # self.game_logger.write_log_file(p, h, t, d)

                h.previousPot = t.totalPotValue
                h.histGameStage = t.gameStage
                h.histDecision = d.decision
                h.histEquity = t.equity
                h.histMinCall = t.minCall
                h.histMinBet = t.minBet
                h.hist_other_players = t.other_players
                h.first_raiser = t.first_raiser
                h.first_caller = t.first_caller
                h.previous_decision = d.decision
                h.lastRoundGameID = h.GameID
                h.previous_round_pot_value=t.round_pot_value
                h.last_round_bluff = False if t.currentBluff == 0 else True
                if t.gameStage == 'PreFlop':
                    preflop_state.update_values(t, d.decision, h, d)
                self.logger.info("=========== round end ===========")
コード例 #2
0
ファイル: main.py プロジェクト: xudaye2001/Poker-1
    def run(self):
        h = History()
        preflop_url, preflop_url_backup = u.get_preflop_sheet_url()
        try:
            h.preflop_sheet = pd.read_excel(preflop_url, sheetname=None)
        except:
            h.preflop_sheet = pd.read_excel(preflop_url_backup, sheetname=None)

        self.game_logger.clean_database()

        p = StrategyHandler()
        p.read_strategy()

        preflop_state = CurrentHandPreflopState()

        while True:
            if self.gui_signals.pause_thread:
                while self.gui_signals.pause_thread == True:
                    time.sleep(1)
                    if self.gui_signals.exit_thread == True: sys.exit()

            ready = False
            while (not ready):
                p.read_strategy()
                t = TableScreenBased(p, gui_signals, self.game_logger, version)
                mouse = MouseMoverTableBased(p.selected_strategy['pokerSite'])
                mouse.move_mouse_away_from_buttons_jump

                ready = t.take_screenshot(True, p) and \
                        t.get_top_left_corner(p) and \
                        t.check_for_captcha(mouse) and \
                        t.get_lost_everything(h, t, p, gui_signals) and \
                        t.check_for_imback(mouse) and \
                        t.get_my_cards(h) and \
                        t.get_new_hand(mouse, h, p) and \
                        t.get_table_cards(h) and \
                        t.upload_collusion_wrapper(p, h) and \
                        t.get_dealer_position() and \
                        t.get_snowie_advice(p, h) and \
                        t.check_fast_fold(h, p, mouse) and \
                        t.check_for_button() and \
                        t.get_round_number(h) and \
                        t.init_get_other_players_info() and \
                        t.get_other_player_names(p) and \
                        t.get_other_player_funds(p) and \
                        t.get_other_player_pots() and \
                        t.get_total_pot_value(h) and \
                        t.get_round_pot_value(h) and \
                        t.check_for_checkbutton() and \
                        t.get_other_player_status(p, h) and \
                        t.check_for_call() and \
                        t.check_for_betbutton() and \
                        t.check_for_allincall() and \
                        t.get_current_call_value(p) and \
                        t.get_current_bet_value(p)

            if not self.gui_signals.pause_thread:
                config = ConfigObj("config.ini")
                m = run_montecarlo_wrapper(p, self.gui_signals, config, ui, t,
                                           self.game_logger, preflop_state, h)
                d = Decision(t, h, p, self.game_logger)
                d.make_decision(t, h, p, self.logger, self.game_logger)
                if self.gui_signals.exit_thread: sys.exit()

                self.update_most_gui_items(preflop_state, p, m, t, d, h,
                                           self.gui_signals)

                self.logger.info("Equity: " + str(t.equity * 100) + "% -> " +
                                 str(int(t.assumedPlayers)) + " (" +
                                 str(int(t.other_active_players)) + "-" +
                                 str(int(t.playersAhead)) + "+1) Plr")
                self.logger.info("Final Call Limit: " + str(d.finalCallLimit) +
                                 " --> " + str(t.minCall))
                self.logger.info("Final Bet Limit: " + str(d.finalBetLimit) +
                                 " --> " + str(t.minBet))
                self.logger.info("Pot size: " + str((t.totalPotValue)) +
                                 " -> Zero EV Call: " +
                                 str(round(d.maxCallEV, 2)))
                self.logger.info("+++++++++++++++++++++++ Decision: " +
                                 str(d.decision) + "+++++++++++++++++++++++")

                mouse_target = d.decision
                if mouse_target == 'Call' and t.allInCallButton:
                    mouse_target = 'Call2'
                mouse.mouse_action(mouse_target, t.tlc)

                t.time_action_completed = datetime.datetime.utcnow()

                filename = str(h.GameID) + "_" + str(t.gameStage) + "_" + str(
                    h.round_number) + ".png"
                self.logger.debug("Saving screenshot: " + filename)
                pil_image = t.crop_image(t.entireScreenPIL, t.tlc[0], t.tlc[1],
                                         t.tlc[0] + 950, t.tlc[1] + 650)
                pil_image.save("log/screenshots/" + filename)

                self.gui_signals.signal_status.emit("Logging data")

                t_log_db = threading.Thread(
                    name='t_log_db',
                    target=self.game_logger.write_log_file,
                    args=[p, h, t, d])
                t_log_db.daemon = True
                t_log_db.start()
                # self.game_logger.write_log_file(p, h, t, d)

                h.previousPot = t.totalPotValue
                h.histGameStage = t.gameStage
                h.histDecision = d.decision
                h.histEquity = t.equity
                h.histMinCall = t.minCall
                h.histMinBet = t.minBet
                h.hist_other_players = t.other_players
                h.first_raiser = t.first_raiser
                h.first_caller = t.first_caller
                h.previous_decision = d.decision
                h.lastRoundGameID = h.GameID
                h.previous_round_pot_value = t.round_pot_value
                h.last_round_bluff = False if t.currentBluff == 0 else True
                if t.gameStage == 'PreFlop':
                    preflop_state.update_values(t, d.decision, h, d)
                self.logger.info("=========== round end ===========")
コード例 #3
0
    def run(self):
        log = logging.getLogger(__name__)
        h = History()
        # preflop_url, preflop_url_backup = self.updater.get_preflop_sheet_url()
        preflop_url = os.path.join('tools', 'preflop.xlsx')
        try:
            h.preflop_sheet = pd.read_excel(preflop_url, sheet_name=None)
        except:
            h.preflop_sheet = pd.read_excel(preflop_url_backup,
                                            sheet_name=None)

        self.game_logger.clean_database()

        p = StrategyHandler()
        p.read_strategy()

        preflop_state = CurrentHandPreflopState()
        preflop_state_Zenith = CurrentHandPreflopStateZenith()
        mongo = MongoManager()
        table_scraper_name = None

        while True:
            # reload table if changed
            config = ConfigObj("config.ini")
            if table_scraper_name != config['DEFAULT']['table_scraper_name']:
                table_scraper_name = config['DEFAULT']['table_scraper_name']
                log.info(
                    f"Loading table scraper info for {table_scraper_name}")
                table_dict = mongo.get_table(table_scraper_name)

            if self.gui_signals.pause_thread:
                while self.gui_signals.pause_thread == True:
                    time.sleep(0.5)
                    if self.gui_signals.exit_thread == True: sys.exit()

            ready = False
            while (not ready):
                p.read_strategy()
                t = TableScreenBased(p, table_dict, self.gui_signals,
                                     self.game_logger, version)
                try:
                    time_start = datetime.datetime.utcnow()
                    # mouse = MouseMoverTableBased(table_dict)
                    # mouse.move_mouse_away_from_buttons_jump()
                    log.info(
                        "___________________________________________________")
                    ready = t.take_screenshot(True, p) and \
                            t.get_top_left_corner(p, self.gui_signals) and \
                            t.get_my_cards(h, is_debug) and \
                            t.get_table_cards(h) and \
                            t.upload_collusion_wrapper(p, h) and \
                            t.get_dealer_position() and \
                            t.check_for_button(is_debug) and \
                            t.get_round_number(h) and \
                            t.check_for_checkbutton() and \
                            t.init_get_other_players_info() and \
                            t.get_other_player_status(p, h) and \
                            t.get_my_funds(h, p) and \
                            t.get_other_player_funds(p) and \
                            t.get_other_player_pots() and \
                            t.get_total_pot_value(h) and \
                            t.get_round_pot_value(h) and \
                            t.check_for_call() and \
                            t.check_for_betbutton() and \
                            t.get_current_call_value(p) and \
                            t.get_current_bet_value(p) and \
                            t.get_new_hand2(h, p) and \
                            t.check_for_allincall()
                    # t.get_other_player_names(p) and \
                    # t.get_lost_everything(h, t, p, self.gui_signals) and \
                    # t.check_for_captcha(mouse) and \
                    # t.check_for_imback(mouse) and \
                    # t.get_new_hand(mouse, h, p) and \
                    # t.check_fast_fold(h, p, mouse) and \
                    # t.check_for_allincall() and \
                finally:
                    time_end = datetime.datetime.utcnow()
                    log.info(
                        "___________________________________________________")
                    log.info(f"time to total record: {time_end - time_start}")

            if not self.gui_signals.pause_thread:
                config = ConfigObj("config.ini")
                if not is_debug:
                    m = run_montecarlo_wrapper(p, self.gui_signals, config, ui,
                                               t, self.game_logger,
                                               preflop_state, h)
                    self.gui_signals.signal_progressbar_increase.emit(20)
                    d = Decision(t, h, p, self.game_logger)
                    d.make_decision(t, h, p, self.game_logger)
                    self.gui_signals.signal_progressbar_increase.emit(10)
                    if self.gui_signals.exit_thread: sys.exit()

                    self.update_most_gui_items(preflop_state, p, m, t, d, h,
                                               self.gui_signals)

                    log.info("Equity: " + str(t.equity * 100) + "% -> " +
                             str(int(t.assumedPlayers)) + " (" +
                             str(int(t.other_active_players)) + "-" +
                             str(int(t.playersAhead)) + "+1) Plr")
                    log.info("Final Call Limit: " + str(d.finalCallLimit) +
                             " --> " + str(t.minCall))
                    log.info("Final Bet Limit: " + str(d.finalBetLimit) +
                             " --> " + str(t.minBet))
                    log.info("Pot size: " + str((t.totalPotValue)) +
                             " -> Zero EV Call: " + str(round(d.maxCallEV, 2)))
                    # log.info("+++++++++++++++++++++++ Decision: " + str(d.decision) + "+++++++++++++++++++++++")

                    # mouse_target = d.decision
                    # if mouse_target == 'Call' and t.allInCallButton:
                    #     mouse_target = 'Call2'
                    # mouse.mouse_action(mouse_target, t.tlc)

                    t.time_action_completed = datetime.datetime.utcnow()

                    filename = str(h.GameID) + "_" + str(
                        t.gameStage) + "_" + str(h.round_number) + ".png"
                    log.debug("Saving screenshot: " + filename)
                    pil_image = t.crop_image(t.entireScreenPIL, t.tlc[0],
                                             t.tlc[1], t.tlc[0] + 950,
                                             t.tlc[1] + 650)
                    # pil_image.save("log/screenshots/" + filename)

                    self.gui_signals.signal_status.emit("Logging data")

                    t_log_db = threading.Thread(
                        name='t_log_db',
                        target=self.game_logger.write_log_file,
                        args=[p, h, t, d])
                    t_log_db.daemon = True
                    t_log_db.start()
                    # self.game_logger.write_log_file(p, h, t, d)

                    h.previousPot = t.totalPotValue
                    h.histGameStage = t.gameStage
                    # h.histDecision = d.decision
                    h.histEquity = t.equity
                    h.histMinCall = t.minCall
                    h.histMinBet = t.minBet
                    h.hist_other_players = t.other_players
                    h.first_raiser = t.first_raiser
                    h.first_caller = t.first_caller
                    # h.previous_decision = d.decision
                    h.lastRoundGameID = h.GameID
                    h.previous_round_pot_value = t.round_pot_value
                    # h.last_round_bluff = False if t.currentBluff == 0 else True
                if t.gameStage == 'PreFlop':
                    if not is_debug:
                        preflop_state.update_values(t, d.decision, h, d)
                    preflop_state_Zenith.get_players_status(t)
                log.info("=========== round end ===========")
                log.info(f"{h.GameID}")
                self.gui_signals.signal_hand_history.emit(h)