示例#1
0
文件: solve.py 项目: hjeni/Sudoku-AI
    def _beta_operator(self, board: Board):
        """
        ß-operator of the ß-climbing, introduces exploration to the algorithm
        :param board: Neighbouring state of the board
        :return: New state of the board
        """
        values = board.values()
        # scan the board
        for pos in board.unfilled_positions():
            # regenerate the value if it meets the probability of beta
            if self._with_probability(self._beta_prob):
                values[pos.y, pos.x] = self._generate_fill_number()
        # fill the board
        board.fill_board(values)

        return board
示例#2
0
文件: solve.py 项目: hjeni/Sudoku-AI
    def _neighbouring_operator(self, board: Board):
        """
        N-operator of the ß-climbing, introduces exploitation to the algorithm
        :param board: State of the board
        :return: Neighbouring state
        """
        values = board.values()

        # iterate modifiable tiles
        for pos in board.unfilled_positions():
            # modify the tile if it meets the probability of n
            if self._with_probability(self._n_prob):
                values[pos.y, pos.x] = self._neighbouring_val(values[pos.y,
                                                                     pos.x])
        # fill the board
        board.fill_board(values)

        return board
示例#3
0
文件: solve.py 项目: hjeni/Sudoku-AI
    def _neighbouring_operator(self, board: Board):
        """
        N-operator of the ß-climbing, introduces exploitation to the algorithm
        :param board: State of the board
        :return: Neighbouring state
        """
        values = board.values()

        # iterate rows
        unfilled = board.unfilled_by_row()
        for row in unfilled:
            # only modify the rows when they meet the probability of n
            if self._with_probability(self._n_prob):
                # swap 2 tiles
                self._swap_in_line(values[row], unfilled[row])
        # update original board
        board.fill_board(values)

        return board