Skip to content

Instantly share code, notes, and snippets.

@addy1997
Created May 22, 2020 07:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save addy1997/3dcde0f3a62a7025985f142309fd9a3d to your computer and use it in GitHub Desktop.
Save addy1997/3dcde0f3a62a7025985f142309fd9a3d to your computer and use it in GitHub Desktop.
#constructing grid and fetching observations
#reading the data from the grid
def read_grid_map(self, insert_grid_map):
with open(insert_grid_map, 'r') as f:
grid_map = f.readlines()
grids = np.array(list(map(lambda x:
list(map(lambda y: int(y),
x.split(''))), grid_map)))
return grids
#fetching observations from grid map
def grid_map_to_observation(self, grid_map, obs_shape=None):
if obs_shape is None:
obs_shape = self.obs_shape
observation = np.zeros(obs_shape, dtype=np.float)
gs0 = int(observation.shape[0]/ grid_map.shape[0])
gs1 = int(observation.shape[1]/ grid_map.shape[1])
for i in range(grid_map.shape[0]):
for j in range(grid_map.shape[1]):
observation[i*gs0:(i+1)*gs1, j*gs0:(j+1)*gs1]
return observation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment