Skip to content

Conversation

@mwydmuch
Copy link
Member

@mwydmuch mwydmuch commented Dec 2, 2025

Description

This PR improves CrossingEnv, so it's specs can now be stated in JSON-safe way, allowing to serialize them cleanly.
Added coverage to catch spec JSON issues across all MiniGrid environments.

Changes:

  • minigrid/__init__.py: register CrossingEnv variants with obstacle_type="wall"/"lava" so spec kwargs stay JSON-safe.
  • minigrid/envs/crossing.py: resolve string obstacle types to Wall/Lava, validate subclasses of WorldObj, and consistently use the resolved type for missions and grid generation.
  • tests/test_envs.py: new test_spec_json_serialization ensures every tested env’s spec.to_json() round-trips through json.loads.

Fixes #396 (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Screenshots

Please attach before and after screenshots of the change if applicable.

Checklist:

  • I have run the pre-commit checks with pre-commit run --all-files (see CONTRIBUTING.md instructions to set it up)
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug Report] Spec.to_json() of SimpleCrossing fails

2 participants