Skip to content

Add the Witch role - #10

Merged
JuneQQQ merged 1 commit into
mainfrom
feature/witch-role
May 18, 2026
Merged

Add the Witch role#10
JuneQQQ merged 1 commit into
mainfrom
feature/witch-role

Conversation

@JuneQQQ

@JuneQQQ JuneQQQ commented May 18, 2026

Copy link
Copy Markdown
Owner

Summary

Implements the Witch role, requested in #2.

The Witch is a villager with two one-time potions. Each night she is told who
the werewolves attacked and may:

  • spend a healing potion to save that victim, and/or
  • spend a poison potion to kill any one living player.

Closes #2

Changes

  • roles.py — new Role.WITCH; standard_setup() seats one once the village
    has five or more seats.
  • engine.py_witch_action() runs the Witch's turn right after the Doctor.
    The night phase is reworked: it now collects multiple simultaneous deaths
    (_announce_deaths) — the wolf kill and the Witch's poison — and each death
    can still trigger a Hunter shot. Potion use is tracked on GameState, so each
    potion is strictly once per game.
  • agents/base.py — new concrete Agent.witch_turn(). RandomAgent and
    LLMAgent override it; the CLI's HumanAgent prompts for it. Existing agents
    need no change.
  • prompts/templates.py — a dedicated witch_request() template; the offline
    mock recognises the witch decision kind and conservatively banks both
    potions.

Checklist

  • ruff check . passes
  • mypy deepwolf passes
  • pytest passes (43 tests; 3 new for the Witch)
  • Determinism preserved
  • CHANGELOG.md and README.md updated

Notes for reviewers

The night phase changed shape — from "one victim" to "a list of deaths". The
healing potion and the Doctor's protection both cancel the wolf kill
independently. The Witch is briefed via a private WITCH_NIGHT_INFO event, so
the LLM agent sees the victim naturally in its prompt log.

The Witch is a villager with two one-time potions. Each night she learns who
the werewolves attacked and may use a healing potion to save them and/or a
poison potion to kill any one player.

- roles.py: new Role.WITCH; standard_setup seats one once the village has five
  or more seats.
- engine.py: _witch_action runs the Witch's turn after the doctor; the night
  phase is reworked to resolve multiple simultaneous deaths (_announce_deaths),
  each of which can still trigger a Hunter shot. Potion use is tracked on
  GameState so each potion is strictly once-per-game.
- agents: new concrete Agent.witch_turn; RandomAgent and LLMAgent override it,
  CLI HumanAgent prompts for it. The offline mock banks both potions.
- prompts: a dedicated witch_request template.
- 3 new tests covering the heal and poison potions.

Closes #2

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@JuneQQQ

JuneQQQ commented May 18, 2026

Copy link
Copy Markdown
Owner Author

Code review (post-merge record).

  • The night-phase rework is the substantive change. _announce_deaths skips a target that an earlier death in the same night already removed (the if not s.player(pid).alive guard) — that correctly handles the case where a Hunter shot, fired by the first death, takes the Witch's poison target. ✅
  • Potion state lives on GameState (witch_heal_used / witch_poison_used), and _witch_action flips the flag only when a potion is actually spent — so a once-per-game potion is genuinely once per game. ✅
  • The Witch is briefed with a private WITCH_NIGHT_INFO event before her view is built, so the LLM agent sees the attacked player in its prompt log without any special-casing. Clean. ✅
  • victim is not None is re-checked inside the heal branch, so the type stays sound and a heal can't fire without a victim. ✅
  • CI green on 3.10–3.12.

Solid PR — the multi-death refactor was the right call rather than special-casing poison. Merged via squash.

@JuneQQQ
JuneQQQ merged commit 26c7ec6 into main May 18, 2026
4 checks passed
@JuneQQQ
JuneQQQ deleted the feature/witch-role branch May 18, 2026 11:09
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.

Add the Witch role

1 participant