Skip to content

Add optional replay game flow#22

Open
Spbd1 wants to merge 1 commit into
codex/add-cost-visibility-gradient-conditionfrom
codex/add-replay-game-feature-to-study-flow
Open

Add optional replay game flow#22
Spbd1 wants to merge 1 commit into
codex/add-cost-visibility-gradient-conditionfrom
codex/add-replay-game-feature-to-study-flow

Conversation

@Spbd1

@Spbd1 Spbd1 commented May 11, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Provide an optional second decision-only playthrough after the full study flow so behavioral replay data can be collected without repeating surveys.
  • Ensure replay choices are stored separately from the original run and include assignment logic that either preserves or flips the hidden profile for analysis.
  • Expose replay results in the local export, validation schema, and admin CSV so replay behavior-change metrics are available for downstream analysis.

Description

  • Added a new route /replay-game and reused the existing HiddenCostGame component in mode="replay" to run a replay-only game (UI copy clarifies that no surveys will be repeated).
  • Implemented replay state creation and assignment with createReplayGameState that randomly picks assignmentCondition of "same-hidden-profile" or "switched-hidden-profile" while preserving displayedProfile and setting hiddenProfile and treatmentCostMultiplier accordingly.
  • Persisted replay state under replayGame (type ReplayGameState) in ResearchSession and updated buildResearchExport to include replayGame, added replayGameSchema to Zod validation, and extended ComputedResearchMetrics with replay/behavior-change fields such as replayAvailable, replayCompleted, replayAssignmentCondition, behaviorChangeFullTreatment, and behaviorChangeCostBurden.
  • Added an export-side prompt with the button text "Play one more round sequence" and guidance about submission behavior, updated the participant-facing ResultsTable to surface replay metrics, and extended admin CSV columns to include replay and change metrics for downstream analysis.

Testing

  • Ran type checking with npm run typecheck and it completed successfully.
  • Ran lint with npm run lint which passed aside from an existing ParticipantBackgroundForm.tsx react-hooks/exhaustive-deps warning.
  • Built the project with npm run build which completed successfully and produced the site routes including /replay-game.
  • Validated export schema with npm run validate:sample which succeeded after updating the sample fixture and schema to include the new replay fields.

Codex Task

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant