Files
BT411/scratchpad/night15/eject_canary.sh
T

57 lines
2.5 KiB
Bash

#!/usr/bin/env bash
# #162 eject canary: the -(CalcKillScore)-500 suicide arithmetic, post-fix.
# Two passive nodes; A panic-ejects. Assert: exactly ONE death cycle, ONE
# -500 application, ONE negative type-2 (the suicide arm), ZERO positive
# type-2, no swallowed duplicates.
. /c/git/bt411/scratchpad/night6/bench_common.sh
cd /c/git/bt411/content || exit 1
taskkill //F //IM btl4.exe >/dev/null 2>&1; sleep 3
rm -f ej_a.log ej_b.log ej_r.log
mv matchlog_*.txt /c/git/bt411/scratchpad/night15/mlbak/ 2>/dev/null
bt_expert_egg MP.EGG EJ.EGG
sed -i "s/^map=.*/map=grass/; s/^time=.*/time=day/; s/^vehicle=.*/vehicle=madcat/" EJ.EGG
grep -q "advancedDamage=1" EJ.EGG || { echo "FAIL: egg lacks advancedDamage=1"; exit 1; }
( export BT_SCORE_LOG=1 BT_DEATH_LOG=1 BT_MATCHLOG=1
bt_launch ej_b.log EJ.EGG 0x0C -net 1601 )
sleep 2
( export BT_GOTO=enemy BT_GOTO_STOP=100 BT_AUTOFIRE=1 BT_AF_MISSILE=1 BT_AF_PERIOD=4
export BT_EJECT_AT=9000 BT_SCORE_LOG=1 BT_DEATH_LOG=1 BT_MATCHLOG=1
bt_launch ej_a.log EJ.EGG 0x03 -net 1501 )
sleep 5
python ../tools/btconsole.py EJ.EGG 127.0.0.1:1501 127.0.0.1:1601 > ej_r.log 2>&1 &
R=$!; sleep 380; kill $R 2>/dev/null; sleep 2
bt_kill_ours; sleep 2; taskkill //F //IM btl4.exe >/dev/null 2>&1
python - <<'PY'
import glob, io, re
pdead = applying = neg2 = pos2 = swall = 0
for path in glob.glob("matchlog_*.txt"):
for line in io.open(path, encoding="latin-1", errors="replace"):
if line.startswith("PLAYER_DEAD"):
pdead += 1
elif line.startswith("SCORE") and "type=2" in line:
m = re.search(r"award=([-\d.]+)", line)
if m and float(m.group(1)) < 0: neg2 += 1
else: pos2 += 1
for path in ("ej_a.log", "ej_b.log"):
txt = io.open(path, encoding="latin-1", errors="replace").read()
swall += txt.count("SWALLOWED")
applying += txt.count("-> APPLYING")
print("=== EJECT CANARY ===")
print("PLAYER_DEAD:", pdead, " deathcost APPLYING:", applying,
" suicide type-2 (neg):", neg2, " kill type-2 (pos):", pos2,
" SWALLOWED:", swall)
deaths = 0
for path in glob.glob("matchlog_*.txt"):
for line in io.open(path, encoding="latin-1", errors="replace"):
if line.startswith("DEATH ") and "inst=M" in line:
deaths += 1
print("real deaths:", deaths)
ok = (deaths > 0 and pdead == deaths and applying == deaths
and (pos2 + neg2) == deaths and neg2 >= 1 and swall == 0)
print("VERDICT:", "PASS -- every death exactly one type-2 (kill or suicide), "
"one tally, one -500; ejects present and charged once" if ok
else "FAIL -- inspect receipts")
PY