Skip to content

Conversation

@KeHang-Zhu
Copy link
Contributor

@KeHang-Zhu KeHang-Zhu commented Nov 7, 2025

Description

demo4

Game Start
↓
[Initialization Stage] – both participants arrive at the bargain stage
├─ Randomly assign roles (buyer / seller)
├─ Randomly generate private valuations (ensure buyer ≥ seller)
├─ Randomly select who moves first (makeFirstMove)
├─ Randomly set maxTurns ∈ [6, 8, 10, 12]
├─ Randomly set chatAllowed = true / false
├─ Randomly set opponentInfo (independent for each participant, 50% probability)
↓
Write to ParticipantAnswer (one record per participant)
Write to PublicData (currentTurn = 1, currentOfferer = first mover)
↓
[Game In preparation]
├─  if both players accept to enter the game
↓
[Game In Progress]
↓
First mover makes an offer*(`processBargainOffer`)
├─ Create a BargainOffer
├─ Add a PENDING transaction to `publicData.transactions`
├─ `currentTurn` unchanged, `currentOfferer` unchanged
↓
Opponent responds (`processBargainResponse`)
├─ Create a BargainOfferResponse
├─ Update transaction status
↓
├─ If accept = true
│   ├─ `isGameOver = true`
│   ├─ `agreedPrice = offer.price`
│   └─ Game ends (agreement reached)
│
└─ If accept = false
├─ `currentTurn += 1`
├─ If `currentTurn > maxTurns`
│   ├─ `isGameOver = true`
│   └─ Game ends (no agreement)
└─ Else
├─ `currentOfferer = previous responder`
└─ Continue to next round

…safety improvements

- Problem 1 (Payout): Added bargain payout calculation based on role and agreed price
- Problem 2 (UI): Show deal summary inside dialogue panel instead of covering history
- Problem 3 (Validation): Added comprehensive valuation range validation [6-12]
- Added maximum turns display in action panel
- Removed 'as any' casts by adding BargainStageConfigData to StageConfigData union
{
collectionName: 'experiments',
experimentTemplate,
experimentTemplate: experimentTemplate,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since the field and the variable are the same name, you can just put experimentTemplate, (as was originally there) instead of experimentTemplate: experimentTemplate

"noImplicitAny": true,
"module": "es6",
"target": "es6",
"module": "es2020",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you revert this?

"version": "0.10.13",
"resolved": "https://registry.npmjs.org/@firebase/app/-/app-0.10.13.tgz",
"integrity": "sha512-OZiDAEK/lDB6xy/XzYAyJJkaDqmQ+BCtOEPLqFvxWKUz5JbBmej7IiiRHdtiIOD/twW7O5AxVsfaaGA/V1bNsA==",
"peer": true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it possible to revert all package-lock.json changes for now?


import CopyWebpackPlugin from 'copy-webpack-plugin';
import {Configuration} from 'webpack';
import type {Configuration} from 'webpack';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you revert all webpack.config.ts changes?

kind: StageKind.BARGAIN,
isGameOver: false,
currentTurn: null,
maxTurns: 8,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't maxTurns and other settings here be set based on the bargain stage config (rather than hardcoded)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These numbers are just placeholder and will be assigned with randomized values when entering the bargain stage

// Current turn number (1-indexed, max = maxTurns), null if game not started
currentTurn: number | null;
// Maximum number of turns for this game
maxTurns: number;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this different than what's set in the stage config? (Same question for other fields like chatEnabled).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The value is just a placeholder and will be re-assigned in bargain.utils.ts. I set them to Null here to avoid confusion

// Public ID of participant whose turn it is to make an offer
currentOfferer: string | null;
// Buyer's public ID
buyerId: string | null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

The fields buyerId and sellerId seem redundant with participantRoles?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right. I will remove them since participantRoles already have the information.

// For each payout item, only add result to list if item is active;
// if the payout item has a randomSelectionId,
// only add the item if it was randomly selected for that participant
console.log('[PAYOUT] Processing payout items', {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please don't add console logs like this in your final PR.

stageConfigMap: Record<string, StageConfig>,
publicDataMap: Record<string, StagePublicData>,
profile: ParticipantProfile, // current participant profile
participantAnswerMap?: Record<string, BaseStageParticipantAnswer>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't make this optional


# Packed shared utils package
*deliberation-lab-utils-*.tgz
*deliberation-lab-utils-*.tgz
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please don't add extra blank lines here

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.

2 participants