Skip to content

Commit

Permalink
Add option for rendering pacman with fog of war
Browse files Browse the repository at this point in the history
  • Loading branch information
camall3n committed Aug 4, 2024
1 parent 783b661 commit 9eedb9e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions scripts/pacman_viz/viz_pocman_probes.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ def create_grid_image(observation: State, fog=False) -> np.ndarray:
idx = observation.pellet_locations
n = 3

if fog:
# hide distant walls
print(observation.grid.shape)
for row, grid_row in enumerate(observation.grid):
for col, grid_cell in enumerate(grid_row):
if not grid_cell: # found wall
if distance(player_loc, (col, row)) > 1:
layer_3[row, col] = 0

# Power pellet are pink
for i in range(len(pellets_loc)):
p = pellets_loc[i]
Expand Down Expand Up @@ -320,6 +329,9 @@ def set_ghost_colours_scared_details(
layer_2[player_loc.x * n + 1, player_loc.y * n + 1] = 1
layer_3[player_loc.x * n + 1, player_loc.y * n + 1] = 0

if fog:
layer_3[0:n, 0:n] = 0

obs = [layer_1, layer_2, layer_3]
rgb = np.stack(obs, axis=-1)
expand_rgb
Expand Down

0 comments on commit 9eedb9e

Please sign in to comment.