Skip to content

Playground

Playground (issue #184): a 3x3 grid of rooms, each pair of orthogonally-adjacent rooms joined by exactly one randomly-coloured, randomly-positioned door - never locked. 12 objects, each independently Key/Ball/Box (matching MiniGrid's own per-object random type draw - see GoToObject's module docstring for the same DISCARD_PILE_COORDS fixed-slot-allocation trick this reuses), are scattered across the whole grid.

No Goal, no reward beyond a flat 0, no termination beyond the timeout - registers with rewards.free (see this PR's fix to that function's signature) and termination_fn=terminations.compose() (no functions -> jnp.any of an empty array -> always False, i.e. never terminates; check_truncation still truncates at max_steps regardless).

Leaving termination_fn at Environment.create's own default (DEFAULT_TERMINATION, composing on_goal_reached/on_lava_fall/ on_ball_hit) was tried first and is wrong: on_goal_reached/ on_lava_fall do stay permanently False (EventsManager.happened, see states.py, returns False rather than raising for an event slot whose entity type was never in entities at all - no Goal/Lava ever placed here) - but on_ball_hit does not. actions._can_walk_there (called from every forward attempt, regardless of transitions_fn) records a (Entities.BALL, EventType.HIT) event through the generic record_walk_into dispatch whenever the player merely bumps a Ball - not just when a moving ball collides with the player via transitions. update_balls (which this environment correctly never runs - see next paragraph). Confirmed directly: a DEFAULT_TERMINATION-registered version of this environment ended episodes within the first 20 random steps, well before max_steps=100, every time a random walk happened to bump one of the 12 objects' Ball share.

Registers with transitions_fn=transitions.deterministic_transition, matching GoToObject/PutNear/Fetch: without it, the default stochastic_transition would walk every Ball around the room turn by turn, unlike MiniGrid's actual static Ball/Key/Box placement here.

MiniGrid's own PlaygroundEnv hardcodes a fixed 19x19 grid regardless of any size argument (verified against source: self.size = 19 is set unconditionally before super().__init__, no size kwarg even accepted) and a flat max_steps=100 default (not the usual 4 * height * width-style formula) - both reproduced as-is here.

Bases: Environment

Navix-Playground-v0. A 3x3 grid of rooms joined by one random unlocked door per adjacent pair, with 12 randomly-typed Key/Ball/Box objects scattered throughout. There is no goal: reward is always 0 (rewards.free) and the episode only ever ends at max_steps. Intended as a sandbox for exploration / unsupervised objectives.

The wall segments splitting a heightxwidth grid into a 3x3 layout of rooms - (col, row_top, row_bottom) for each vertical segment, (row, col_left, col_right) for each horizontal one. A fixed function of height/width alone (only each segment's own door offset and colour are randomised per episode, in _reset) - verified against MiniGrid's actual PlaygroundEnv._gen_grid.