ai-agent-book 精选快照(<2MB 代码与文档,来自 github.com/bojieli/ai-agent-book)
Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s
Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import pytest
|
||||
from werewolf.game import Judge
|
||||
from werewolf.agent import PlayerAgent
|
||||
from werewolf.roles import Role, Faction
|
||||
|
||||
|
||||
def test_witch_killed_by_wolves_cannot_use_poison_in_same_night():
|
||||
"""Contract proved: Judge._witch_act prevents a Witch who was killed by wolves at night and not saved from using poison in the same night.
|
||||
Bug locked out: allowing a dead witch killed by wolves to poison another player on the night she dies."""
|
||||
players = [
|
||||
PlayerAgent("P1", Role.WEREWOLF, offline=True),
|
||||
PlayerAgent("P2", Role.WEREWOLF, offline=True),
|
||||
PlayerAgent("P3", Role.SEER, offline=True),
|
||||
PlayerAgent("P4", Role.WITCH, offline=True),
|
||||
PlayerAgent("P5", Role.VILLAGER, offline=True),
|
||||
]
|
||||
|
||||
judge = Judge(players, seed=42)
|
||||
witch = judge.by_name("P4")
|
||||
|
||||
# Override witch target selection to attempt poisoning P3 if asked
|
||||
witch._offline_choose_target = lambda candidates, allow_none: "P3"
|
||||
|
||||
# Wolves killed P4 (the witch)
|
||||
killed = "P4"
|
||||
poisoned, saved = judge._witch_act(killed)
|
||||
|
||||
assert saved is False
|
||||
assert poisoned is None, "A witch killed by wolves at night cannot use poison in the same night"
|
||||
Reference in New Issue
Block a user