Created
May 22, 2020 07:33
-
-
Save addy1997/3dcde0f3a62a7025985f142309fd9a3d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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