robocode_shim: generalize bridge to any legacy bot; validate 28 champions as sparring partners
Generalize the classic-Robocode shim so the hosted bot's main class, jar, extra classpath and data directory are configurable (SHIM_BOT_CLASS / SHIM_BOT_JAR / SHIM_EXTRA_CP / SHIM_DATA), with DrussGT kept as the default so every existing script, fixture and generated bot dir behaves identically. - LegacyBotBridge: generalized bridge (DrussGTBridge kept as an alias). - BotHost: (mainClass, jar, extraJars, dataDir); disableShield -> generic disableStaticBoolean. - ClassicPeer: implement ITeamRobotPeer; synthesize StatusEvent each turn; make move/turnBody/turnGun/turnRadar the immediate (turn-ending) variants; guard re-entrant execute() from event handlers; record delivered events. - make_botdir.sh / run_bridge_battle.sh / run_smoke.sh generalized, legacy invocations unchanged; generated launcher uses a per-process mktemp data dir so concurrent bots/battles cannot clobber one classic data directory. Validated 35 legacy bots against a real Tank Royale battle (2 rounds vs sample SpinBot): 28 usable (27 effective + DrussGT), 5 weak-but-playing, 2 failing. Adds robots.json (manifest) and LEGACY_BOTS.md (how-to, status, missing-API costs). No third-party jar is committed.
This commit is contained in:
@@ -1,9 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
# Run a real Tank Royale battle with the DrussGT bridge against an adversary and
|
||||
# dump the movement fixture + statistics.
|
||||
# Run a real Tank Royale battle with a classic-Robocode-shim bot (the "subject")
|
||||
# against an adversary and dump the movement fixture + statistics.
|
||||
#
|
||||
# tools/robocode_shim/run_bridge_battle.sh <adversaryBotDir> [rounds] [outJsonl]
|
||||
#
|
||||
# The subject is the DrussGT bridge bot dir by default (legacy behaviour). Point
|
||||
# it at any other generated legacy bot directory with SHIM_BOTDIR:
|
||||
#
|
||||
# SHIM_BOTDIR=/tmp/tr_bots/Diamond \
|
||||
# tools/robocode_shim/run_bridge_battle.sh <adversaryBotDir> 2 /tmp/diamond.jsonl
|
||||
#
|
||||
# Environment:
|
||||
# SHIM_BOTDIR subject bot dir; if set it is used as-is (not regenerated)
|
||||
# DRUSSGT_BOTDIR legacy alias for the DrussGT subject dir (regenerated)
|
||||
# SHIM_BOT_NAME subject name as reported in the battle (default: dir basename)
|
||||
# SHIM_DATA classic data dir for the subject; unset => fresh dir per battle
|
||||
# TR_EVENTS_OUT optional raw bullet-event sidecar
|
||||
#
|
||||
# Example:
|
||||
# tools/robocode_shim/run_bridge_battle.sh \
|
||||
# /home/davide/Projects/tank-royale/sample-bots/java/build/archive/SpinBot 5
|
||||
@@ -13,14 +26,22 @@ HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO="$(cd "$HERE/../.." && pwd)"
|
||||
ADVERSARY="${1:?usage: run_bridge_battle.sh <adversaryBotDir> [rounds] [outJsonl]}"
|
||||
ROUNDS="${2:-5}"
|
||||
OUT_JSONL="${3:-/tmp/tr_drussgt_$(basename "$ADVERSARY" | tr 'A-Z' 'a-z').jsonl}"
|
||||
OUT_JSONL="${3:-/tmp/tr_shim_$(basename "$ADVERSARY" | tr 'A-Z' 'a-z').jsonl}"
|
||||
|
||||
RUNNER="${TR_RUNNER_JAR:-/home/davide/Projects/tank-royale/runner/examples/lib/robocode-tankroyale-runner.jar}"
|
||||
export DRUSSGT_JAR="${DRUSSGT_JAR:-/tmp/drussgt/DrussGT.jar}"
|
||||
export DRUSSGT_DATA="${DRUSSGT_DATA:-/tmp/drussgt_bridge_data}"
|
||||
|
||||
BOTDIR="${DRUSSGT_BOTDIR:-/tmp/tr_bots/DrussGT}"
|
||||
"$HERE/make_botdir.sh" "$BOTDIR" >/dev/null
|
||||
if [[ -n "${SHIM_BOTDIR:-}" ]]; then
|
||||
SUBJECT_BOTDIR="$SHIM_BOTDIR"
|
||||
[[ -d "$SUBJECT_BOTDIR" ]] || { echo "subject bot dir not found: $SUBJECT_BOTDIR" >&2; exit 1; }
|
||||
else
|
||||
# Legacy DrussGT path: regenerate the shared/overridden DrussGT bot dir.
|
||||
SUBJECT_BOTDIR="${DRUSSGT_BOTDIR:-/tmp/tr_bots/DrussGT}"
|
||||
export DRUSSGT_JAR="${DRUSSGT_JAR:-/tmp/drussgt/DrussGT.jar}"
|
||||
export DRUSSGT_DATA="${DRUSSGT_DATA:-/tmp/drussgt_bridge_data}"
|
||||
"$HERE/make_botdir.sh" "$SUBJECT_BOTDIR" >/dev/null
|
||||
fi
|
||||
|
||||
SUBJECT_NAME="${SHIM_BOT_NAME:-$(basename "$SUBJECT_BOTDIR")}"
|
||||
|
||||
EVENTS_ARGS=()
|
||||
if [[ -n "${TR_EVENTS_OUT:-}" ]]; then
|
||||
@@ -29,10 +50,10 @@ fi
|
||||
|
||||
java -cp "$HERE/out:$RUNNER" robocode_shim.TrBattleCapture \
|
||||
--rounds "$ROUNDS" --out "$OUT_JSONL" \
|
||||
--bot "$BOTDIR" --bot "$ADVERSARY" \
|
||||
--subject DrussGT --adversary "$(basename "$ADVERSARY")" \
|
||||
--bot "$SUBJECT_BOTDIR" --bot "$ADVERSARY" \
|
||||
--subject "$SUBJECT_NAME" --adversary "$(basename "$ADVERSARY")" \
|
||||
"${EVENTS_ARGS[@]}"
|
||||
|
||||
echo
|
||||
echo "=== movement statistics (TR) ==="
|
||||
echo "=== movement statistics (TR, subject=$SUBJECT_NAME) ==="
|
||||
python3 "$REPO/tools/robocode_fixture_capture/analyze.py" "$OUT_JSONL"
|
||||
|
||||
Reference in New Issue
Block a user