Skip to content

Fix deterministic reset on all reset paths and broken density FAB actions#1

Open
Sidem wants to merge 1 commit into
mainfrom
claude/distracted-tu-f5e04c
Open

Fix deterministic reset on all reset paths and broken density FAB actions#1
Sidem wants to merge 1 commit into
mainfrom
claude/distracted-tu-f5e04c

Conversation

@Sidem

@Sidem Sidem commented May 19, 2026

Copy link
Copy Markdown
Owner

Summary

  • Deterministic reset bug (reported): Clone & Mutate, plain Clone, and several other ruleset operations reseeded each world with Date.now() + idx, ignoring the deterministic flag - so the reset that follows those ops was never deterministic, even though plain world resets were. Added a _getResetSeed(baseSeed, worldIndex) helper on WorldManager (shared base seed in deterministic mode, baseSeed + idx otherwise) and routed all six reset paths through it.
  • Dead event constants: The "Default Densities" and "Apply Density" actions (mobile FABs + WorldsController) dispatched COMMAND_RESET_DENSITIES_TO_DEFAULT / COMMAND_APPLY_SELECTED_DENSITY_TO_ALL, which are not defined in EventBus.js - so the dispatches resolved to undefined and silently no-op'd. Repointed to the real constants COMMAND_RESET_INITIAL_STATES_TO_DEFAULT / COMMAND_APPLY_SELECTED_INITIAL_STATE_TO_ALL.
  • Console spam: Disabled EVENT_BUS_LOGGING in committed config.js so production builds don't log every UI event.

Why

The deterministic toggle is meant to make resets reproducible across worlds; clone/mutate skipped it entirely. The density actions were fully dead due to a constant-name mismatch - the kind of bug an untyped event bus hides.

Reviewer notes

  • LOAD_STATE and clear paths were intentionally left alone - they don't reseed from RNG, so determinism does not apply.
  • All six reset paths now go through _getResetSeed; verified via grep.

Test plan

  • npm run lint - 0 errors
  • npm run build - succeeds
  • Deterministic mode on: Clone & Mutate yields identical grids across worlds with the same density config
  • Mobile "Default Densities" / "Apply Density" FAB buttons now work

Clone & mutate (and other ruleset ops) reseeded each world with
Date.now()+idx, ignoring the deterministic flag, so the post-op reset
was never deterministic. Added a _getResetSeed helper and routed all
six reset paths through it.

Also fixed two FAB density actions that dispatched undefined event
constants (no-op), and disabled EVENT_BUS_LOGGING in committed config.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sidem added a commit that referenced this pull request Jun 10, 2026
The Deterministic Reset toggle only affected the bulk Reset All path.
Clone & Mutate, Clone, and _modifyRulesetForScope reseeded with
Date.now()+idx (never reproducible), while RESET_WORLDS_WITH_CURRENT_RULESET
and #applyRulesetToWorlds passed no seed at all (the worker falls back to
Math.random on a falsy seed). Re-applies the fix from PR #1.

- Add WorldManager._getResetSeed(baseSeed, worldIndex); route all six reset
  paths through it, each capturing baseSeed once before its loop.
- Fix dead mobile density FAB constants (COMMAND_RESET_DENSITIES_TO_DEFAULT /
  COMMAND_APPLY_SELECTED_DENSITY_TO_ALL were undefined no-ops) to the real
  COMMAND_RESET_INITIAL_STATES_TO_DEFAULT / *_APPLY_SELECTED_INITIAL_STATE_TO_ALL.
- Add window.__headless / window.__hexlife debug handle under the ?headless=1
  shim for in-browser verification.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant