Skip to content

Commit 8d5ba93

Browse files
feat: 한밤의 늑대인간 FSM 구현
- games/base_fsm.py: 게임 FSM 추상 베이스 클래스 추가 - games/werewolf/ontology.py: NIGHT_PHASES·PHASE_TO_ROLE 상수 추가 - games/werewolf/night_roles.py: 야간 행동 함수 (seer/robber/troublemaker/drunk/insomniac) - games/werewolf/judge.py: 투표 집계·처형·승리 판정 로직 - games/werewolf/fsm.py: WerewolfFSM 전체 구현
1 parent 1bcf2f5 commit 8d5ba93

7 files changed

Lines changed: 913 additions & 0 deletions

File tree

boardgame-ai/games/base_fsm.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""게임 FSM 추상 베이스 클래스."""
2+
3+
from __future__ import annotations
4+
5+
from abc import ABC, abstractmethod
6+
7+
from core.envelope import WSMessage
8+
from core.events import FusionContext, GameEvent
9+
10+
11+
class BaseFSM(ABC):
12+
"""모든 게임 FSM이 구현해야 하는 인터페이스."""
13+
14+
@abstractmethod
15+
def handle_event(self, event: GameEvent) -> list[WSMessage]:
16+
"""비전 파이프라인에서 GameEvent 수신 후 처리."""
17+
...
18+
19+
@abstractmethod
20+
def handle_input(
21+
self,
22+
input_type: str,
23+
data: dict,
24+
player_id: str | None = None,
25+
) -> list[WSMessage]:
26+
"""UI에서 입력 수신 후 처리."""
27+
...
28+
29+
@abstractmethod
30+
def get_fusion_context(self) -> FusionContext:
31+
"""현재 phase에 맞는 FusionContext 반환. FSM 전이마다 broadcast."""
32+
...
33+
34+
@abstractmethod
35+
def get_state_dict(self) -> dict:
36+
"""현재 게임 상태를 dict로 반환. state_update 페이로드에 사용."""
37+
...

0 commit comments

Comments
 (0)