def _make_maze(self, complexity=0.75, density=0.75):
        """
            ty wikipedia?
        """
        dim = np.floor( self.map_size / 2 )*2+1
        shape = (dim, dim)

        complexity = int(complexity*(5*(shape[0]+shape[1])))
        density = int(density*(shape[0]//2*shape[1]//2))

        # Build actual maze
        Z = np.zeros(shape, dtype=bool)
        # Fill borders
        Z[0,:] = Z[-1,:] = 1
        Z[:,0] = Z[:,-1] = 1
        # Make isles
        for i in range(density):
            x = self.rng.random_integers(0,shape[1]//2)*2
            y = self.rng.random_integers(0,shape[0]//2)*2

            Z[y,x] = 1
            for j in range(complexity):
                neighbours = []
                if x > 1:           neighbours.append( (y,x-2) )
                if x < shape[1]-2:  neighbours.append( (y,x+2) )
                if y > 1:           neighbours.append( (y-2,x) )
                if y < shape[0]-2:  neighbours.append( (y+2,x) )
                if len(neighbours):
                    y_,x_ = neighbours[self.rng.random_integers(0,len(neighbours)-1)]
                    if Z[y_,x_] == 0:
                        Z[y_,x_] = 1
                        Z[y_+(y-y_)//2, x_+(x-x_)//2] = 1
                        x, y = x_, y_

        return Z.astype(int)
dataset/ETHPy150Open ntasfi/PyGame-Learning-Environment/ple/games/raycastmaze.py/RaycastMaze._make_maze/original