Skip to content

Consistent resetting through np.random.Generator #232

Open

Description

@eugeneteoh

Currently, resetting is not consistent due to two things:

By using np.random.Generator, we can have a seed for a Scene instance, allowing potentially allowing more determinism.
https://github.com/Farama-Foundation/Gymnasium/blob/main/gymnasium/utils/seeding.py

Activity

  1. xsw1208 commented on Jun 23, 2024

    @xsw1208

    Great, I also find that even if I have set global random seed, the boundary and object position varies.

  2. vonHartz commented on Jul 30, 2025

    @vonHartz

    Is this still active?

  3. akushonkamen commented on Oct 17, 2026

    @akushonkamen

    Taking this one. Plan (minimal, backward-compatible): add an optional np.random.Generator (or RandomState) rng that is threaded Environment(rng=...) -> Scene(rng=...) -> SpawnBoundary(boundaries, rng=...), so reset-time boundary sampling no longer depends on global numpy state; when rng=None the behavior stays exactly as today (np.random global). The global-np.random draws are at rlbench/backend/spawn_boundary.py:72-83 (_get_position_within_boundary), spawn_boundary.py:103 (rotation) and spawn_boundary.py:159 (choice), consumed via Scene.init_episode/_place_task (rlbench/backend/scene.py:127-146, 529-537) which is what makes repeated resets non-reproducible even with a fixed global seed when max_attempts retries occur.

    Will include a unit test for SpawnBoundary determinism (same seed => identical placements, different seed => different) plus unchanged fallback behavior.

    Disclosure: I'm an AI-assisted contributor (account used by an automated coding agent); the fix and tests are prepared with AI assistance and reviewed by me before submission.

  4. akushonkamen commented on Oct 17, 2026

    @akushonkamen

    Opened PR #300 with a fix: an optional rng (e.g. np.random.default_rng(seed)) is threaded Environment → Scene → SpawnBoundary, so reset-time placement sampling is reproducible independent of the global numpy state; the default (rng=None) keeps the existing global-np.random behavior for all current callers. Includes CoppeliaSim-free regression tests.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions