• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python discoverer.getEngineByName函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pychess.Players.engineNest.discoverer.getEngineByName函数的典型用法代码示例。如果您正苦于以下问题:Python getEngineByName函数的具体用法?Python getEngineByName怎么用?Python getEngineByName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了getEngineByName函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: args_changed

 def args_changed(widget):
     if self.cur_engine is not None and not self.selection:
         new_args = self.widgets["engine_args_entry"].get_text().strip()
         engine = discoverer.getEngineByName(self.cur_engine)
         old_args = engine.get("args")
         if new_args != old_args:
             engine["args"] = new_args.split()
开发者ID:leogregianin,项目名称:pychess,代码行数:7,代码来源:enginesDialog.py


示例2: start_endgame_from

def start_endgame_from(pieces):
        fen = create_fen(pieces)

        timemodel = TimeModel(0, 0)
        gamemodel = LearnModel(timemodel)
        gamemodel.set_learn_data(ENDGAME, pieces)

        player_name = conf.get("firstName", _("You"))
        p0 = (LOCAL, Human, (WHITE, player_name), player_name)

        engine = discoverer.getEngineByName(discoverer.getEngineLearn())
        ponder_off = True
        engine_name = discoverer.getName(engine)
        p1 = (ARTIFICIAL, discoverer.initPlayerEngine,
              (engine, BLACK, 20, variants[NORMALCHESS], 60, 0, 0, ponder_off), engine_name)

        def restart_analyzer(gamemodel):
            asyncio.async(gamemodel.restart_analyzer(HINT))
        gamemodel.connect("learn_success", restart_analyzer)

        def start_analyzer(gamemodel):
            asyncio.async(gamemodel.start_analyzer(HINT, force_engine=discoverer.getEngineLearn()))
        gamemodel.connect("game_started", start_analyzer)

        perspective = perspective_manager.get_perspective("games")
        asyncio.async(perspective.generalStart(gamemodel, p0, p1, loaddata=(StringIO(fen), fen_loader, 0, -1)))
开发者ID:teacoffee2017,项目名称:pychess,代码行数:26,代码来源:EndgamesPanel.py


示例3: on_all_engine_discovered

 def on_all_engine_discovered(discoverer):
     engine = discoverer.getEngineByName(discoverer.getEngineLearn())
     if engine is None:
         engine = discoverer.getEngineN(-1)
     default_engine = engine.get("md5")
     conf.set("ana_combobox", default_engine)
     conf.set("inv_ana_combobox", default_engine)
开发者ID:leogregianin,项目名称:pychess,代码行数:7,代码来源:Main.py


示例4: update_options

    def update_options(self, *args):
        if self.cur_engine is not None:
            # Initial reset
            self.options_store.clear()

            # Detection of the name of the engine to reload
            engines = discoverer.getEngines()
            names = [engine["name"] for engine in engines]
            if self.cur_engine not in names:
                self.cur_engine = engines[0]["name"]
            engine = discoverer.getEngineByName(self.cur_engine)
            if engine:
                options = engine.get("options")
                if options:
                    options.sort(key=lambda obj: obj['name'].lower() if 'name' in obj else '')
                    for option in options:
                        key = option["name"]
                        val = option
                        if option["type"] != "button":
                            val["default"] = option.get("default")
                            val["value"] = option.get("value", val["default"])
                            modified = val["value"] != val["default"]
                        else:
                            modified = False
                        self.options_store.append(["*" if modified else "", key, val])
开发者ID:leogregianin,项目名称:pychess,代码行数:25,代码来源:enginesDialog.py


示例5: comment_changed

 def comment_changed(widget):
     if self.cur_engine is not None and not self.selection:
         new_comment = self.widgets["engine_comment_entry"].get_text().strip()
         engine = discoverer.getEngineByName(self.cur_engine)
         old_comment = engine.get("comment")
         if new_comment != old_comment:
             engine["comment"] = new_comment
开发者ID:leogregianin,项目名称:pychess,代码行数:7,代码来源:enginesDialog.py


示例6: selection_changed

 def selection_changed(treeselection):
     store, iter = self.tv.get_selection().get_selected()
     if iter:
         self.selection = True
         path = store.get_path(iter)
         indices = path.get_indices()
         row = indices[0]
         name = store[row][1]
         self.cur_engine = name
         engine = discoverer.getEngineByName(name)
         self.widgets['copy_engine_button'].set_sensitive(True)
         if "PyChess.py" in engine["command"]:
             self.widgets['remove_engine_button'].set_sensitive(False)
         else:
             self.widgets['remove_engine_button'].set_sensitive(True)
         self.widgets["engine_command_entry"].set_text(engine["command"])
         engine_chooser_dialog.set_filename(engine["command"])
         args = [] if engine.get("args") is None else engine.get("args")
         self.widgets["engine_args_entry"].set_text(' '.join(args))
         directory = engine.get("workingDirectory")
         d = directory if directory is not None else self.default_workdir
         dir_chooser_dialog.set_current_folder(d)
         self.widgets["engine_protocol_combo"].set_active(0 if engine["protocol"]=="uci" else 1)
         update_options()
         self.selection = False
开发者ID:sally0813,项目名称:pychess,代码行数:25,代码来源:enginesDialog.py


示例7: startClicked

    def startClicked(self, button):
        color = self.widgets["colorDock"].get_child().get_active()
        if color == 2:
            color = random.choice([WHITE, BLACK])

        opp = self.widgets["opponentDock"].get_child()
        tree_iter = opp.get_active_iter()
        if tree_iter is not None:
            model = opp.get_model()
            engine = model[tree_iter][1]

        opponent = self.widgets["opponentDock"].get_child().get_active()
        difficulty = int(self.widgets["skillSlider"].get_value())

        gamemodel = GameModel(TimeModel(5 * 60, 0))

        name = conf.get("firstName")
        player0tup = (LOCAL, Human, (color, name), name)
        if opponent == 0:
            name = conf.get("secondName")
            player1tup = (LOCAL, Human, (1 - color, name), name)
        else:
            engine = discoverer.getEngineByName(engine)
            name = discoverer.getName(engine)
            player1tup = (ARTIFICIAL, discoverer.initPlayerEngine,
                          (engine, 1 - color, difficulty,
                           variants[NORMALCHESS], 5 * 60, 0), name)

        perspective = perspective_manager.get_perspective("games")
        if color == WHITE:
            create_task(perspective.generalStart(gamemodel, player0tup, player1tup))
        else:
            create_task(perspective.generalStart(gamemodel, player1tup, player0tup))
开发者ID:leogregianin,项目名称:pychess,代码行数:33,代码来源:TaskerManager.py


示例8: level_changed

 def level_changed(widget):
     if self.cur_engine is not None and not self.selection:
         new_level = widget.get_value()
         engine = discoverer.getEngineByName(self.cur_engine)
         old_level = engine.get("level")
         if new_level != old_level:
             engine["level"] = int(new_level)
开发者ID:leogregianin,项目名称:pychess,代码行数:7,代码来源:enginesDialog.py


示例9: protocol_changed

        def protocol_changed(widget):
            if self.cur_engine is not None and not self.add and not self.selection:
                active = self.widgets["engine_protocol_combo"].get_active()
                new_protocol = "uci" if active == 0 else "xboard"
                engine = discoverer.getEngineByName(self.cur_engine)
                old_protocol = engine["protocol"]
                if new_protocol != old_protocol:
                    command = engine.get("command")
                    engine_command = []
                    vm_command = engine.get("vm_command")
                    if vm_command is not None:
                        engine_command.append(vm_command)
                        vm_args = engine.get("vm_args")
                        if vm_args is not None:
                            engine_command.append(", ".join(vm_args))
                    engine_command.append(command)

                    # is the new protocol supported by the engine?
                    if new_protocol == "uci":
                        check_ok = is_uci(engine_command)
                    else:
                        check_ok = is_cecp(engine_command)

                    if check_ok:
                        # discover engine options for new protocol
                        engine["protocol"] = new_protocol
                        engine["recheck"] = True
                        discoverer.discover()
                    else:
                        # restore the original protocol
                        widgets["engine_protocol_combo"].set_active(
                            0 if old_protocol == "uci" else 1)
开发者ID:teacoffee2017,项目名称:pychess,代码行数:32,代码来源:enginesDialog.py


示例10: select_dir

 def select_dir(button):
     new_directory = dir_chooser_dialog.get_filename()
     engine = discoverer.getEngineByName(self.cur_engine)
     old_directory = engine.get("workingDirectory")
     if new_directory != old_directory and new_directory != self.default_workdir:
         engine["workingDirectory"] = new_directory
         discoverer.save()
开发者ID:sally0813,项目名称:pychess,代码行数:7,代码来源:enginesDialog.py


示例11: vm_args_changed

 def vm_args_changed(widget):
     if self.cur_engine is not None:
         new_args = self.widgets["vm_args_entry"].get_text().strip()
         engine = discoverer.getEngineByName(self.cur_engine)
         old_args = engine.get("vm_args")
         if new_args != old_args:
             engine["vm_args"] = new_args.split()
             discoverer.save()
开发者ID:teacoffee2017,项目名称:pychess,代码行数:8,代码来源:enginesDialog.py


示例12: start_puzzle_game

def start_puzzle_game(gamemodel, filename, records, index, rec, from_lesson=False):
    gamemodel.set_learn_data(PUZZLE, filename, index, len(records), from_lesson=from_lesson)

    engine = discoverer.getEngineByName(discoverer.getEngineLearn())
    ponder_off = True

    color = gamemodel.boards[0].color

    w_name = "" if rec["White"] is None else rec["White"]
    b_name = "" if rec["Black"] is None else rec["Black"]

    player_name = conf.get("firstName")
    engine_name = discoverer.getName(engine)

    if rec["Event"].startswith("Lichess Practice"):
        w_name = player_name if color == WHITE else engine_name
        b_name = engine_name if color == WHITE else player_name

    opp_name = engine_name if rec["Event"].startswith("Lichess Practice") else b_name

    if color == WHITE:
        p0 = (LOCAL, Human, (WHITE, w_name), w_name)
        p1 = (ARTIFICIAL, discoverer.initPlayerEngine,
              (engine, BLACK, 20, variants[NORMALCHESS], 20, 0, 0, ponder_off), b_name)
    else:
        p0 = (ARTIFICIAL, discoverer.initPlayerEngine,
              (engine, WHITE, 20, variants[NORMALCHESS], 20, 0, 0, ponder_off), w_name)
        p1 = (LOCAL, Human, (BLACK, b_name), b_name)

    def on_game_started(gamemodel, name, color):
        perspective.activate_panel("annotationPanel")
        create_task(gamemodel.start_analyzer(HINT, force_engine=discoverer.getEngineLearn()))
        gamemodel.players[1 - color].name = name
        gamemodel.emit("players_changed")
    gamemodel.connect("game_started", on_game_started, opp_name, color)

    def goal_checked(gamemodle):
        if gamemodel.reason == PRACTICE_GOAL_REACHED:
            if from_lesson:
                progress = lessons_solving_progress[gamemodel.source]
            else:
                progress = puzzles_solving_progress[gamemodel.source]

            progress[gamemodel.current_index] = 1

            if from_lesson:
                lessons_solving_progress[gamemodel.source] = progress
            else:
                puzzles_solving_progress[gamemodel.source] = progress
    gamemodel.connect("goal_checked", goal_checked)

    gamemodel.variant.need_initial_board = True
    gamemodel.status = WAITING_TO_START

    perspective = perspective_manager.get_perspective("games")
    create_task(perspective.generalStart(gamemodel, p0, p1))
开发者ID:leogregianin,项目名称:pychess,代码行数:56,代码来源:PuzzlesPanel.py


示例13: add

        def add(button):
            self.add = True
            response = engine_chooser_dialog.run()

            if response == gtk.RESPONSE_OK:
                new_engine = engine_chooser_dialog.get_filename()
                if new_engine:
                    try:
                        uci = is_uci(new_engine)
                        if not uci:
                            if not is_cecp(new_engine):
                                # restore the original
                                engine = discoverer.getEngineByName(self.cur_engine)
                                engine_chooser_dialog.set_filename(engine["command"])
                                print "Maybe not a chess engine"
                                return
                        path, binname = os.path.split(new_engine)
                        for e in discoverer.getEngines():
                            if e["name"] == binname:
                                binname = e["name"] + "(1)"
                                break
                        self.widgets["engine_name_entry"].set_text(binname)
                        self.widgets["engine_command_entry"].set_text(new_engine)
                        self.widgets["engine_protocol_combo"].set_active(0 if uci else 1)
                        self.widgets["engine_args_entry"].set_text("")
                        
                        name = self.widgets["engine_name_entry"].get_text().strip()
                        active = self.widgets["engine_protocol_combo"].get_active()
                        protocol = "uci" if active==0 else "xboard"
                        
                        discoverer.addEngine(name, new_engine, protocol)
                        self.cur_engine = name
                        glock_connect_after(discoverer, "engine_discovered", update_store)
                        self.add = False
                        discoverer.start()
                    except:
                        print "There is something wrong with this executable"
                else:
                    # restore the original
                    engine = discoverer.getEngineByName(self.cur_engine)
                    engine_chooser_dialog.set_filename(engine["command"])
            engine_chooser_dialog.hide()
开发者ID:btrent,项目名称:knave,代码行数:42,代码来源:enginesDialog.py


示例14: remove

 def remove(button):
     if self.cur_engine is not None:
         self.widgets['remove_engine_button'].set_sensitive(False)
         engine = discoverer.getEngineByName(self.cur_engine)
         discoverer.removeEngine(self.cur_engine)
         discoverer.save()
         update_store(discoverer)
         # Notify playerCombos in NewGameTasker
         discoverer.emit("all_engines_discovered")
         ts = self.tv.get_selection()
         ts.select_path((0,))
开发者ID:btrent,项目名称:knave,代码行数:11,代码来源:enginesDialog.py


示例15: on_playerCombobox_changed

 def on_playerCombobox_changed(widget, skill_hbox, skill_level):
     position = widget.get_active()
     skill_hbox.props.visible = position > 0
     if position > 0:
         tree_iter = widget.get_active_iter()
         if tree_iter is not None:
             engine_name = widget.get_model()[tree_iter][1]
             engine = discoverer.getEngineByName(engine_name)
             if engine:
                 pref_level = engine.get("level")
                 if pref_level:
                     skill_level.set_value(pref_level)
开发者ID:leogregianin,项目名称:pychess,代码行数:12,代码来源:newGameDialog.py


示例16: name_edited

 def name_edited(renderer, path, new_name):
     if self.cur_engine is not None:
         old_name = self.cur_engine
         if new_name and new_name != old_name:
             names = [engine["name"] for engine in discoverer.getEngines()]
             if new_name not in names:
                 engine = discoverer.getEngineByName(self.cur_engine)
                 engine["name"] = new_name
                 discoverer.save()
                 self.cur_engine = new_name
                 update_store()                        
                 # Notify playerCombos in NewGameTasker
                 discoverer.emit("all_engines_discovered")
开发者ID:sally0813,项目名称:pychess,代码行数:13,代码来源:enginesDialog.py


示例17: selection_changed

        def selection_changed(treeselection):
            store, tv_iter = self.tv.get_selection().get_selected()
            if tv_iter:
                self.selection = True
                path = store.get_path(tv_iter)
                indices = path.get_indices()
                row = indices[0]
                name = store[row][1]
                self.cur_engine = name
                engine = discoverer.getEngineByName(name)
                if "PyChess.py" in engine["command"]:
                    self.widgets['remove_engine_button'].set_sensitive(False)
                else:
                    self.widgets['remove_engine_button'].set_sensitive(True)
                self.widgets["engine_command_entry"].set_text(engine["command"])
                engine_chooser_dialog.set_filename(engine["command"])
                args = [] if engine.get("args") is None else engine.get("args")
                self.widgets["engine_args_entry"].set_text(' '.join(args))

                vm = engine.get("vm_command")
                self.widgets["vm_command_entry"].set_text(vm if vm is not None else "")
                args = [] if engine.get("vm_args") is None else engine.get("vm_args")
                self.widgets["vm_args_entry"].set_text(' '.join(args))

                directory = engine.get("workingDirectory")
                dir_choice = directory if directory is not None else self.default_workdir
                dir_chooser_dialog.set_current_folder(dir_choice)
                self.widgets["engine_protocol_combo"].set_active(0 if engine["protocol"] == "uci" else 1)

                self.widgets["engine_country_combo"].set_active(0)
                country = discoverer.getCountry(engine)
                idx = 0
                for iso in ISO3166_LIST:
                    if iso.iso2 == country:
                        self.widgets["engine_country_combo"].set_active(idx)
                        break
                    idx += 1

                comment = engine.get("comment")
                self.widgets["engine_comment_entry"].set_text(comment if comment is not None else "")

                level = engine.get("level")
                try:
                    level = int(level) if level else defaultEngineLevel
                except Exception:
                    level = defaultEngineLevel
                self.widgets["engine_level_scale"].set_value(level)

                self.update_options()
                self.selection = False
开发者ID:leogregianin,项目名称:pychess,代码行数:50,代码来源:enginesDialog.py


示例18: engine_default_options

 def engine_default_options(button):
     if self.cur_engine is not None and not self.selection:
         engine = discoverer.getEngineByName(self.cur_engine)
         options = engine.get("options")
         if options:
             dialog = Gtk.MessageDialog(mainwindow(), type=Gtk.MessageType.QUESTION, buttons=Gtk.ButtonsType.YES_NO)
             dialog.set_markup(_("Do you really want to restore the default options of the engine ?"))
             response = dialog.run()
             dialog.destroy()
             if response == Gtk.ResponseType.YES:
                 for option in options:
                     if "default" in option:
                         option["value"] = option["default"]
                 self.update_options()
开发者ID:leogregianin,项目名称:pychess,代码行数:14,代码来源:enginesDialog.py


示例19: remove

        def remove(button):
            if self.cur_engine is not None:
                self.widgets['remove_engine_button'].set_sensitive(False)
                engine = discoverer.getEngineByName(self.cur_engine)
                discoverer.removeEngine(self.cur_engine)
                discoverer.save()

                selection = self.tv.get_selection()
                result = selection.get_selected()
                if result is not None:
                    model, iter = result
                    model.remove(iter)

                # Notify playerCombos in NewGameTasker
                discoverer.emit("all_engines_discovered")
开发者ID:sally0813,项目名称:pychess,代码行数:15,代码来源:enginesDialog.py


示例20: update_options

 def update_options(*args):
     if self.cur_engine is not None:
         engines = discoverer.getEngines()
         names = [engine["name"] for engine in engines]
         # After deleting an engine we will select first
         if self.cur_engine not in names:
             self.cur_engine = engines[0]["name"]
         engine = discoverer.getEngineByName(self.cur_engine)
         options = engine.get("options")
         if options:
             self.options_store.clear()
             for option in options:
                 key = option["name"]
                 val = option
                 if option["type"] != "button":
                     val["default"] = option.get("default")
                     val["value"] = option.get("value", val["default"])
                 self.options_store.append([key, val])
开发者ID:sally0813,项目名称:pychess,代码行数:18,代码来源:enginesDialog.py



注:本文中的pychess.Players.engineNest.discoverer.getEngineByName函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python discoverer.save函数代码示例发布时间:2022-05-25
下一篇:
Python discoverer.connect_after函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap