Files
ai-chess/public/games.html
T
ai-chess 37bac9b0f6 feat: prompt presets, setup dialog, /games + leaderboard, one-game gate
Backend:
- prompts.py: 5 personality presets (уличный_гопник default, профессор,
  поэт, молчун, шут). Each provides voice + label + description.
  build_system_prompt accepts `preset` parameter; the MCP-tools section
  + must-call-move rule is shared common tail.
- coordinator: `start_new_game` now accepts `overrides` ({white: {agent,
  model, prompt}, black: {...}}) — missing fields filled randomly.
  MODEL_OPTIONS published per agent.
- AppState.prompts tracks the preset id per side; persisted into game's
  agents dict and PGN.
- AppState.eval_cache cleared on new_game (was per-life-of-process before).
- persistence.save_game now stores full history (with comments) and the
  per-position eval cache in the game JSON.
- ChessGame.abort() — manual game termination with result='*' and
  Termination='aborted'.
- New endpoints:
  • GET  /api/options   — agents, models per agent, prompt presets.
  • GET  /api/stats     — leaderboard aggregated from games/*.json:
        per (agent, model) and per persona, with score = wins + 0.5*draws.
  • POST /api/abort-game — force-end current game.
- POST /api/new-game now returns 409 when a game is in progress.
- GET  /api/games[/{id}[/pgn]] also 409 while in progress — gallery is
  hidden behind the one-game-at-a-time rule.

Frontend:
- New setup dialog: per-side agent / model / persona selects, swap +
  random shortcuts, persona description preview, abort button inline
  when current game blocks the start.
- 'games & stats' link in the board footer; greyed out while a game is
  active.
- /games page reworked: leaderboard (player × model + by persona),
  games table with persona labels, replay panel showing eval per ply
  with prev/next/first/last + arrow-key nav.
- chess.js loadPgn → load_pgn fix consolidated; replay prefers saved
  history (comments + side) over PGN parse when available.
2026-05-15 00:40:35 +03:00

93 lines
2.9 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!doctype html>
<html lang="ru">
<head>
<meta charset="utf-8" />
<title>ai-chess — games & stats</title>
<link rel="stylesheet" href="/static/vendor/chessground.base.css" />
<link rel="stylesheet" href="/static/vendor/chessground.brown.css" />
<link rel="stylesheet" href="/static/vendor/chessground.cburnett.css" />
<link rel="stylesheet" href="/static/style.css" />
</head>
<body>
<main id="games-page">
<header id="games-page-header">
<a id="back-link" href="/">← back to live</a>
<h1>games & stats</h1>
<span id="games-count"></span>
</header>
<div id="blocked-banner" hidden>
<strong>Game in progress.</strong> Finish or abort it on the
<a href="/">main page</a> before browsing past games.
</div>
<div id="page-grid">
<section id="stats-pane">
<header class="col-header"><span>leaderboard (player × model)</span></header>
<table id="leaderboard">
<thead>
<tr>
<th>agent / model</th>
<th>games</th>
<th>wins</th>
<th>draws</th>
<th>losses</th>
<th>score</th>
<th>winrate</th>
</tr>
</thead>
<tbody></tbody>
</table>
<header class="col-header"><span>by persona</span></header>
<table id="leaderboard-prompts">
<thead>
<tr><th>persona</th><th>games</th><th>wins</th><th>draws</th><th>losses</th><th>score</th></tr>
</thead>
<tbody></tbody>
</table>
</section>
<section id="games-pane">
<header class="col-header"><span>games</span></header>
<table id="games-table">
<thead>
<tr>
<th>id</th>
<th>white</th>
<th>black</th>
<th>result</th>
<th>termination</th>
<th>moves</th>
<th>pgn</th>
</tr>
</thead>
<tbody></tbody>
</table>
<div id="replay-wrap" hidden>
<header class="col-header"><span id="replay-title">replay</span>
<button id="replay-close" type="button">close</button>
</header>
<div id="replay-layout">
<div id="replay-board"></div>
<aside id="replay-side">
<div id="replay-controls">
<button id="replay-first">⏮</button>
<button id="replay-prev">←</button>
<button id="replay-next">→</button>
<button id="replay-last">⏭</button>
<span id="replay-ply">ply 0/0</span>
<span id="replay-eval"></span>
</div>
<ol id="replay-history"></ol>
</aside>
</div>
</div>
</section>
</div>
</main>
<script src="/static/games.js" type="module"></script>
</body>
</html>