Skip to content

Make simulator state transitions deterministic - #85

Open
Kamichanw wants to merge 1 commit into
allenai:mainfrom
Kamichanw:main
Open

Make simulator state transitions deterministic#85
Kamichanw wants to merge 1 commit into
allenai:mainfrom
Kamichanw:main

Conversation

@Kamichanw

Copy link
Copy Markdown

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.

@MarcCote

MarcCote commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the PR. We will have a look and determine how much impact this fix has.

@MarcCote MarcCote closed this Aug 4, 2026
@MarcCote MarcCote reopened this Aug 4, 2026
@MarcCote

MarcCote commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

@Kamichanw can you also explain why overriding the hashcode will solve the issue?

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 EnvObject hashing by basing hashCode on the stable uuid, aligning with existing equals semantics.
  • 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()
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.

Inconsistency of the action of open door to someplace.

3 participants