docs(@projects/@magic-civilization): ✨ update player api docs to reflect generalised naming
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
91ef4bc21f
commit
82c464e31e
6 changed files with 28 additions and 13 deletions
|
|
@ -1,17 +1,32 @@
|
|||
# Claude Player API
|
||||
# Player API
|
||||
|
||||
**Status:** Phase 0 design draft, p2-67.
|
||||
**Status:** Production (originally landed as "Claude Player API" in p2-67;
|
||||
generalised 2026-05-17 — naming dropped the Claude-specific framing once
|
||||
the protocol turned out to be useful for OpenSpiel / RL adapters and
|
||||
shell smoke tests).
|
||||
**Owner:** simulator-infra.
|
||||
**Wire:** JSON-Lines over stdin/stdout (one JSON value per line, `\n` terminator).
|
||||
**Encoding:** UTF-8 strict, no BOM, no trailing whitespace.
|
||||
|
||||
## Purpose
|
||||
|
||||
Let a Claude Agent SDK process play one slot of a Magic Civilization game while
|
||||
the production AI plays the others. Every action Claude takes maps 1-to-1 to a
|
||||
button or interaction the human UI exposes — no privileged shortcuts, no
|
||||
direct `GameState` mutation. Game state is read via a **fog-aware
|
||||
projection** so Claude only sees what the player it's bound to could see.
|
||||
Let *any external client* play one slot of a Magic Civilization game while
|
||||
the production AI plays the others. Every action the client takes maps
|
||||
1-to-1 to a button or interaction the human UI exposes — no privileged
|
||||
shortcuts, no direct `GameState` mutation. Game state is read via a
|
||||
**fog-aware projection** so the client only sees what the player it's
|
||||
bound to could see.
|
||||
|
||||
Known consumers today:
|
||||
|
||||
- `tooling/claude-player-mcp/` — Claude-Code MCP transport.
|
||||
- `scripts/player-api-example.py` — plain Python reference client.
|
||||
- `scripts/claude-smoke-5endturn.sh`, `scripts/claude-demo-25turn.sh` —
|
||||
shell smoke / demo drivers (raw JSON-Lines).
|
||||
|
||||
A future OpenSpiel / RL trainer adapter (cf. `p2-67-followup-rl-self-play`)
|
||||
would `subprocess.Popen` the same harness and treat each `view` →
|
||||
`legal_actions` → `act` cycle as one step in its training loop.
|
||||
|
||||
## Wire protocol
|
||||
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ pub enum BuildingActionPayload {
|
|||
}
|
||||
|
||||
/// Every UI-equivalent action the player can take. Wire format is
|
||||
/// `{"type":"<variant>", ...}` — see `CLAUDE_PLAYER_API.md` for the
|
||||
/// `{"type":"<variant>", ...}` — see `PLAYER_API.md` for the
|
||||
/// complete schema.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(tag = "type", rename_all = "snake_case")]
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ pub fn apply_action(
|
|||
// bench-cheat: every Offer immediately signs the agreement
|
||||
// (instant-sign), and Accept/Reject are no-op acknowledgements.
|
||||
// The honest contract is documented in
|
||||
// `docs/CLAUDE_PLAYER_API.md` once Phase 8 doc updates land.
|
||||
// `docs/PLAYER_API.md` once Phase 8 doc updates land.
|
||||
PlayerAction::OfferOpenBorders { to } => apply_offer_open_borders(state, player, *to),
|
||||
PlayerAction::AcceptOpenBorders { from: _ }
|
||||
| PlayerAction::RejectOpenBorders { from: _ }
|
||||
|
|
@ -1242,7 +1242,7 @@ fn apply_offer_open_borders(
|
|||
});
|
||||
}
|
||||
let pair = if from < to { (from, to) } else { (to, from) };
|
||||
// Bench-cheat (documented in CLAUDE_PLAYER_API.md): the
|
||||
// Bench-cheat (documented in PLAYER_API.md): the
|
||||
// counterparty AI doesn't yet model offer acceptance, so Offer
|
||||
// signs immediately. Real protocol with pending-offer staging
|
||||
// is a Phase 11+ follow-up.
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
//! follow-up tasks of p2-67 Phase 1; both are tracked there. Until those
|
||||
//! modules land this crate is a pure types crate — no behaviour, no I/O.
|
||||
//!
|
||||
//! See `src/game/engine/docs/CLAUDE_PLAYER_API.md` for the full spec.
|
||||
//! See `src/game/engine/docs/PLAYER_API.md` for the full spec.
|
||||
|
||||
#![warn(missing_docs)]
|
||||
#![allow(clippy::module_name_repetitions)]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
//! Wire envelopes for the JSON-Lines protocol described in
|
||||
//! `src/game/engine/docs/CLAUDE_PLAYER_API.md`.
|
||||
//! `src/game/engine/docs/PLAYER_API.md`.
|
||||
//!
|
||||
//! - [`Request`] — adapter → harness (`view`, `act`, `shutdown`).
|
||||
//! - [`Response`] — harness → adapter (success: events + view; failure: error).
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ pub fn build_building_catalog() -> Vec<TacticalBuildingSpec> {
|
|||
}
|
||||
|
||||
/// Runtime `UnitsCatalog` literal — id → `UnitStats`. Mirrors what
|
||||
/// `claude_player_main.gd::_apply_runtime_units_catalog` harvests from
|
||||
/// `player_api_main.gd::_apply_runtime_units_catalog` harvests from
|
||||
/// `public/resources/units/*.json` (the `movement` field maps to
|
||||
/// `UnitStats::base_moves`).
|
||||
pub fn build_runtime_units_catalog() -> UnitsCatalog {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue