Make simulator state transitions deterministic - #85
Open
Kamichanw wants to merge 1 commit into
Open
Conversation
Collaborator
|
Thanks for the PR. We will have a look and determine how much impact this fix has. |
Collaborator
|
@Kamichanw can you also explain why overriding the hashcode will solve the issue? |
There was a problem hiding this comment.
Pull request overview
This PR aims to make ScienceWorld simulator behavior deterministic across resets/runs, addressing reported stochasticity in physics/state transitions (e.g., steam generation) and improving reproducibility.
Changes:
- Adds a regression test that replays a fixed action sequence across multiple resets and asserts identical traces.
- Fixes
EnvObjecthashing by basinghashCodeon the stableuuid, aligning with existingequalssemantics. - Updates the Scala toolchain (Scala 2.12.21) and pins an sbt version via
project/build.properties.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/test_scienceworld.py | Adds a determinism regression test that compares full reset+step traces across multiple runs. |
| simulator/src/main/scala/scienceworld/struct/EnvObject.scala | Makes hashCode consistent with equals by hashing on uuid to stabilize hashed collection behavior. |
| simulator/project/build.properties | Pins sbt version for consistent builds. |
| simulator/build.sbt | Updates Scala version used to compile the simulator. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+18
to
+37
| env = ScienceWorldEnv() | ||
| env.load("task-1-boil", 0, "teleportAction") | ||
| actions = [ | ||
| "teleport to kitchen", | ||
| "pour counter into sink", | ||
| "activate sink", | ||
| "use lighter on drawer", | ||
| "look around", | ||
| ] | ||
|
|
||
| traces = [] | ||
| try: | ||
| for _ in range(8): | ||
| observation, info = env.reset() | ||
| trace = [(observation, info)] | ||
| for action in actions: | ||
| trace.append(env.step(action)) | ||
| traces.append(trace) | ||
| finally: | ||
| env.close() |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I made simulator state transitions deterministic, which resolved #82 and #33 . Instead of replacing Set with Array, it can be done more elegantly. Any test is welcome.