Add microservices, web UI, and replay tooling
Some checks failed
ci / tests (push) Has been cancelled

This commit is contained in:
dan
2025-12-25 03:28:40 +03:00
commit 46a07f548b
72 changed files with 9142 additions and 0 deletions

34
tests/test_cli_bot.py Normal file
View File

@@ -0,0 +1,34 @@
from __future__ import annotations
from catan.cli import CLIController
from catan.game import Game, GameConfig, Phase
from catan.ml.agents import RandomAgent
from tests.utils import find_initial_spot
def test_human_vs_random_bot_session() -> None:
controller = CLIController(
Game(GameConfig(player_names=["Human", "Bot"], seed=9)),
bots={"Bot": RandomAgent(seed=3)},
)
# Complete setup: human manually places, bot uses random agent.
while controller.game.phase != Phase.MAIN:
current = controller.game.current_player.name
if current == "Human":
corner, road = find_initial_spot(controller.game)
controller.handle_command(f"place {corner} {road}")
else:
controller._run_bot_turn(current) # noqa: SLF001 - exercising CLI internals
# Play a few turns: human rolls and ends, bot plays automatically.
for _ in range(3):
assert controller.game.current_player.name == "Human"
controller.handle_command("roll")
controller.handle_command("end")
assert controller.game.current_player.name == "Bot"
controller._run_bot_turn("Bot") # noqa: SLF001
# Ensure bot activity is recorded in history.
assert any(log.player == "Bot" for log in controller.game.history)