thousand-token-wood-sim / tests /test_player_move.py
AdmiralTaco's picture
Phase 0b: multi-model council wiring + Patron state + player-move hook
c4f21fa
Raw
History Blame Contribute Delete
1.28 kB
"""Tests for the queued player-move turn hook. No GPU/Gradio.
Run: python -m pytest tests/ -q
"""
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from ttw.dummy import make_random_policy
from ttw.game import Game
def _game():
return Game(make_random_policy(seed=3), deck_seed=1)
def _total_pebbles(world):
return sum(c.pebbles for c in world.alive())
def _player_moves(world):
return [e for e in world.log if e["type"] == "player_move"]
def test_queued_move_emits_event_and_clears_queue():
g = _game()
g.queue_player_move("noop")
assert g.world.pending_moves # queued, not yet stepped
g.step()
moves = _player_moves(g.world)
assert len(moves) == 1
assert moves[0]["move"] == "noop"
assert moves[0]["turn"] == 1
assert g.world.pending_moves == [] # drained
def test_step_without_queued_move_emits_no_player_move():
"""v1 regression guard: an empty queue must not produce a player_move event."""
g = _game()
g.step()
assert _player_moves(g.world) == []
def test_queued_noop_preserves_pebble_conservation():
g = _game()
before = _total_pebbles(g.world)
g.queue_player_move("noop")
g.step()
assert _total_pebbles(g.world) == before