Exemple #1
0
    def startup(self, options: dict, game: Board, new_game=True):
        """Startup engine."""
        parser = configparser.ConfigParser()
        parser.optionxform = str

        if not options:
            if self.shell is None:
                success = parser.read(self.get_file() + '.uci')
            else:
                try:
                    with self.shell.open(self.get_file() + '.uci',
                                         'r') as file:
                        parser.read_file(file)
                    success = True
                except FileNotFoundError:
                    success = False
            if success:
                options = dict(parser[parser.sections().pop()])

        self.level_support = bool(options)
        self.options = options
        self.chess960_send(game.has_chess960_castling_rights())
        if new_game:
            self.newgame(game)
            logging.debug('Loaded engine [%s]', self.get_name())
            logging.debug('Supported options [%s]', self.get_options())