Thanks to visit codestin.com
Credit goes to github.com

Skip to content

SecretMafia: clearer prompts, readable action broadcasts, quote-scoped discussion - #199

Open
borgr wants to merge 1 commit into
TextArena:mainfrom
borgr:secretmafia-clarity
Open

SecretMafia: clearer prompts, readable action broadcasts, quote-scoped discussion#199
borgr wants to merge 1 commit into
TextArena:mainfrom
borgr:secretmafia-clarity

Conversation

@borgr

@borgr borgr commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

Salvages and finishes the improvements proposed in #155 by @MozerWang, who appears to have moved on. Single file, no new deps, applies cleanly to main.

What this does

  • Clearer role prompts. Every role's prompt now opens with a shared rules block that states the exact role counts (N Mafia, 1 Doctor, 1 Detective, M Villagers) and the Day/Night flow. Factored into one _shared_rules() helper rather than copy-pasted into each of the four role classes.
  • Readable action broadcasts (fixes the "observation might be empty/confusing" issue from Fix secret_mafia bug #155). Votes, night kills, and doctor protects are now broadcast as clean messages — e.g. Player 2 votes for [4] during the day phase. — instead of echoing the raw action string, which could be empty or full of the model's private reasoning.
  • Quote-scoped discussion. During discussion, only the double-quoted portions of a message are shared with other players; everything outside the quotes (private reasoning) is kept off the public record.

Differences vs #155 (why a fresh PR)

  • Fix secret_mafia bug #155's discussion parser used re.search, so it captured only the first quoted segment — a player who said "A." ... "B." would have "B." silently dropped. This uses re.findall and rejoins, preserving multi-sentence quoted speech, and falls back to the full message when no quotes are present so nothing is ever silently swallowed.
  • Fix secret_mafia bug #155's win-condition change (len(mafia) >= len(villagers)) is kept because it reads better and drops a float division, but note it is algebraically identical to the previous len(mafia) >= len(alive)/2 (since alive = mafia + villagers) — i.e. it's a readability rewrite, not a behavioural fix. Game outcomes are unchanged.
  • The four duplicated rules blocks in Fix secret_mafia bug #155 are collapsed into the single helper to avoid drift.

Verification (deterministic, no model needed)

Drove the env end-to-end with a scripted oracle:

  • All four role prompts render with no literal {placeholders}, correct per-player id, role counts, and the quote instruction.
  • Discussion quote-stripping: single-quote extract, multi-quote preserved, no-quote fallback.
  • _check_win both terminal branches (all-mafia-dead → Village win; parity → Mafia win) with correct team rewards.
  • Full episodes over 12 seeded runs terminate with the correct winner — 6 seeds driven to a Village win (lynch mafia) and 6 to a Mafia win (lynch villagers).

Closes/supersedes #155.

…d discussion

Builds on the improvements proposed in TextArena#155 (by @MozerWang):

- Role prompts now open with a shared rules block that states the exact
  role counts and the Day/Night flow, so every player sees the same
  setup. Factored into one _shared_rules() helper instead of copying the
  block into each of the four role classes.
- Vote / protect / kill actions are broadcast as readable messages
  (e.g. "votes for [X] during the day phase.") instead of echoing the
  raw action string, which could be empty or leak private reasoning.
- Discussion turns share only the double-quoted portions of a message,
  keeping a player's private reasoning off the public record. Uses
  re.findall so multi-sentence quoted speech is preserved (the original
  captured only the first quoted segment), and falls back to the whole
  message when no quotes are present so nothing is silently dropped.

The win check is rewritten as len(mafia) >= len(villagers) — clearer and
free of float division, but algebraically identical to the previous
len(mafia) >= len(alive)/2, so game outcomes are unchanged.
@borgr borgr mentioned this pull request Aug 9, 2026
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