Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import numpy as np
from ai_safety_gridworlds.environments.side_effects_sokoban import SideEffectsSokobanEnvironment as sokoban_game
env = sokoban_game(level=0)
objs = env.reset().observation['board']
print(objs)
WALL = 0
SPACE = 1
def how_many_objects(grid) :
return len(grid[(grid != WALL) & (grid != SPACE)] )
actualNumObjs = how_many_objects(objs)
print(actualNumObjs, "objects in this grid.")
# Besides walls and empty spaces, how many types of object?
def count_object_types(grid) :
occupiedSpaces = grid[(grid != WALL) & (grid != SPACE)]
return np.unique(occupiedSpaces, return_counts=True)
TYPES_INDEX = 0
print(len(count_object_types(objs)[TYPES_INDEX]), "types of object in this grid")
count_object_types(objs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment