Created
April 14, 2018 12:54
-
-
Save g-leech/ef99cc559a2f18ec401d1f2207508d40 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
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