feat(ai-arena): Add victory/draw result serialization and victory condition support for AI match tooling

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
Claude Code 2026-04-11 06:09:24 -07:00
parent f1d169e98d
commit 035a07b069

View file

@ -264,7 +264,18 @@ for ((i = 0; i < N; i++)); do
continue
fi
if [ "$HAS_JQ" -eq 1 ]; then
line=$(jq -r '[.match_id, .players[0].name, .players[1].name, .winner_name, .final_turn, .victory_type] | @tsv' "$RESULT")
# A draw serializes as winner_name="" + victory_type="draw" (or
# winner_index=-1). Any of those signals should render "DRAW" in
# the Winner column — checking `.winner_name == ""` is the cheapest
# invariant; the game enforces it in _build_result_dict.
line=$(jq -r '[
.match_id,
.players[0].name,
.players[1].name,
(if (.winner_name // "") == "" then "DRAW" else .winner_name end),
.final_turn,
.victory_type
] | @tsv' "$RESULT")
IFS=$'\t' read -r mid p1 p2 win turn type <<<"$line"
printf "%-12s %-14s %-14s %-14s %-6s %-12s\n" "$mid" "$p1" "$p2" "$win" "$turn" "$type"
else