示例#1
0
    def get_move(self, move):
        if move.row == -1 and move.col == -1:
            move = Move(self.col // 2, self.row // 2)
            self.board = self.board.make_move(move, AI)
            return move

        self.board = self.board.make_move(move, OP)

        if self.g: move, _ = self.max_val(self.board.board, MIN, MAX, 6)
        else: move, _ = self.max_val(self.board.board, MIN, MAX, 4)

        while self.board.board[move.row][move.col] != 0:
            move.col = randint(0, self.col - 1)
            move.row = randint(0, self.row - 1)

        self.board = self.board.make_move(move, AI)
        return move
示例#2
0
    def make_internal_move(self, move: Move, player: Player) -> None:
        for i in range(self.row - 1, -1, -1):
            if self.board[i][move.col] == Player.no:
                self.board[i][move.col] = player
                move.row = i
                self.move.append(move)
                self.move_player.append(player)
                break
            try:
                i > 0
            except InvalidMoveError:
                print("Invalid Move!")

        for i in range(8):
            tmp = move + all_dir[i]
            if self.is_inside(tmp):
                self.has_neighbor[i][tmp.row][tmp.col] = True
                tmp += all_dir[i]
                if self.is_inside(tmp):
                    self.has_indirect_neighbor[i][tmp.row][tmp.col] = True

        super().make_internal_move(move, player)