33 lines
1.8 KiB
Bash
Executable file
33 lines
1.8 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# multi-difficulty-batch.sh — Run autoplay-batch across multiple AI difficulties.
|
|
# Usage: tools/multi-difficulty-batch.sh [count=3] [turn_limit=300] [difficulties="normal hard"]
|
|
# Env passthrough: AUTOPLAY_HOST, RENDER_MODE forwarded to autoplay-batch.sh.
|
|
# Output: .local/batches/multi_diff/<STAMP>_<diff>/ and ..._report.txt
|
|
set -euo pipefail
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_ROOT="$(dirname "$SCRIPT_DIR")"
|
|
COUNT="${1:-3}"; TURN_LIMIT="${2:-300}"; DIFFICULTIES="${3:-normal hard}"
|
|
STAMP="$(date +%Y%m%d_%H%M%S)"
|
|
OUT_ROOT="$REPO_ROOT/.local/batches/multi_diff"
|
|
mkdir -p "$OUT_ROOT"
|
|
REPORT="$OUT_ROOT/${STAMP}_report.txt"
|
|
echo "Multi-difficulty batch: count=$COUNT turns=$TURN_LIMIT diffs='$DIFFICULTIES' stamp=$STAMP" | tee "$REPORT"
|
|
for diff in $DIFFICULTIES; do
|
|
diff_dir="$OUT_ROOT/${STAMP}_${diff}"; mkdir -p "$diff_dir"
|
|
echo "" | tee -a "$REPORT"; echo "### DIFFICULTY: $diff → $diff_dir" | tee -a "$REPORT"
|
|
AI_DIFFICULTY="$diff" bash "$SCRIPT_DIR/autoplay-batch.sh" "$COUNT" "$TURN_LIMIT" "$diff_dir" \
|
|
2>&1 | tee -a "$REPORT" || echo "WARN: $diff batch non-zero" | tee -a "$REPORT"
|
|
total=0; victories=0; p0_wins=0; p1_wins=0
|
|
for g in "$diff_dir"/game_*_seed*; do
|
|
[ -s "$g/turn_stats.jsonl" ] || continue
|
|
total=$((total+1))
|
|
last="$(tail -n1 "$g/turn_stats.jsonl")"
|
|
if echo "$last" | grep -q '"victory_player"'; then
|
|
victories=$((victories+1))
|
|
w="$(echo "$last" | sed -n 's/.*"victory_player":\s*\([0-9]\+\).*/\1/p')"
|
|
[ "$w" = "0" ] && p0_wins=$((p0_wins+1)); [ "$w" = "1" ] && p1_wins=$((p1_wins+1))
|
|
fi
|
|
done
|
|
echo " → $diff: games=$total victories=$victories p0=$p0_wins p1=$p1_wins" | tee -a "$REPORT"
|
|
done
|
|
echo "" | tee -a "$REPORT"; echo "Report: $REPORT"
|