Adds analyze-replay.sh script to parse replay files and report: - combat_death events per match - zone_death events (type=zone_death, currently unused) - bot_died events with reason=zone - Deaths per turn metrics Used for verifying zone forcing function per plan §3.7.1. Test results (30 matches): - 2-player: 90% matches with combat_deaths (exceeds 65-80% target) - 4-player: 100% matches with combat_deaths - 6-player: 100% matches with combat_deaths (meets target) Note: zone_death events are never emitted; zone kills use bot_died with reason=zone instead. This is a gap between plan and implementation. Closes: bf-5y8b
48 lines
1.4 KiB
Bash
Executable file
48 lines
1.4 KiB
Bash
Executable file
#!/bin/bash
|
|
# analyze-replay.sh - Check a replay file for combat_death and zone_death events
|
|
|
|
REPLAY_FILE="$1"
|
|
|
|
if [[ ! -f "$REPLAY_FILE" ]]; then
|
|
echo "Usage: $0 <replay-file>"
|
|
exit 1
|
|
fi
|
|
|
|
# Detect if gzipped
|
|
if [[ "$REPLAY_FILE" == *.gz ]]; then
|
|
CAT="zcat"
|
|
else
|
|
CAT="cat"
|
|
fi
|
|
|
|
echo "=== Replay: $REPLAY_FILE ==="
|
|
|
|
# Get basic info
|
|
MATCH_ID=$($CAT "$REPLAY_FILE" | jq -r '.match_id // "unknown"')
|
|
NUM_PLAYERS=$($CAT "$REPLAY_FILE" | jq '.players | length')
|
|
TURNS=$($CAT "$REPLAY_FILE" | jq '.turns | length')
|
|
|
|
echo "Match ID: $MATCH_ID"
|
|
echo "Players: $NUM_PLAYERS"
|
|
echo "Turns: $TURNS"
|
|
|
|
# Count combat_death events
|
|
COMBAT_DEATHS=$($CAT "$REPLAY_FILE" | jq '[.turns[].events[]? | select(.type == "combat_death")] | length')
|
|
|
|
# Count zone_death events
|
|
ZONE_DEATHS=$($CAT "$REPLAY_FILE" | jq '[.turns[].events[]? | select(.type == "zone_death")] | length')
|
|
|
|
# Count bot_died events with reason="zone" (current implementation)
|
|
BOT_DIED_ZONE=$($CAT "$REPLAY_FILE" | jq '[.turns[].events[]? | select(.type == "bot_died" and .details.reason == "zone")] | length')
|
|
|
|
echo "combat_death events: $COMBAT_DEATHS"
|
|
echo "zone_death events: $ZONE_DEATHS"
|
|
echo "bot_died (reason=zone): $BOT_DIED_ZONE"
|
|
|
|
# Calculate deaths per turn
|
|
if [[ "$TURNS" -gt 0 ]]; then
|
|
DEATHS_PER_TURN=$(awk "BEGIN {printf \"%.3f\", $COMBAT_DEATHS / $TURNS}")
|
|
echo "Deaths per turn: $DEATHS_PER_TURN"
|
|
fi
|
|
|
|
echo ""
|