Files
SirRoboGarage/tools/robocode_shim/run_bridge_battle.sh
SirStone fe8b1eddff Add curated legacy Robocode roster (28 bots) and Tank Royale booter
Curated roster: 34 classic-Robocode archives were downloaded, measured in real
Tank Royale battles and curated to 28 usable bots, now in legacy_bots/<Name>/
(<Name>.jar + <Name>.json + <Name>.sh) with checksums in MANIFEST.sha256.
Six were dropped as NOT_USEFUL and deleted from tr_bots/_salvage/legacy_bots/
and tr_bots/_salvage/tr_wrappers/, with the rationale recorded in
legacy_bots/README.md and tools/robocode_shim/LEGACY_BOTS.md:

  - Nene, Seraphim  - Azuma-framework melee bots, completely inert (0 scans,
                      0 shots); getRobotRunnable() returns null so the shim has
                      no driver path for them.
  - Aurora          - fires 6 shots and crawls.
  - FloodMini, LightningBug, Aristocles - near-stationary turrets: they scan and
                      fire but land 0 hits and take 10+ hits every round.

DrussGT is the reference bot and is deliberately NOT in legacy_bots/: it lives in
tr_bots/DrussGT and is now vendored with its sources under
tools/robocode_shim/vendor/drussgt/.

Repo-relative paths replace /tmp: every <Name>.sh resolves the shim and the
vendor jars via $REPO (../..), and none hardcodes a server URL, a /tmp data
path, or anything under ~/Downloads. SERVER_URL/SERVER_SECRET come from the
environment, which the booter populates from its own -Dserver.url /
-Dsystem.secret system properties.

Booter: tools/booter/robocode-tankroyale-booter-0.35.5-all.jar, copied from a
local tank-royale build, plus a README covering the real CLI. Note the command
is `boot`; the upstream README's `run` is stale. Verified it discovers all 28
kept bots via both `dir` and `info`.

Licensing: every third-party jar here reads "not stated in jar", and DrussGT is
GPL. The repo owner has explicitly waived this - the repository is PRIVATE and
lives on their own LAN. Do not mirror or redistribute without revisiting that.

.gitignore flipped back to tracking legacy_bots/**/*.jar; an over-broad *.jar
rule already cost us the only copy of DrussGT.jar once.
2026-10-04 22:18:28 +02:00

60 lines
2.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# 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
set -euo pipefail
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_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}"
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:-$HERE/vendor/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
EVENTS_ARGS=(--events-out "$TR_EVENTS_OUT")
fi
java -cp "$HERE/out:$RUNNER" robocode_shim.TrBattleCapture \
--rounds "$ROUNDS" --out "$OUT_JSONL" \
--bot "$SUBJECT_BOTDIR" --bot "$ADVERSARY" \
--subject "$SUBJECT_NAME" --adversary "$(basename "$ADVERSARY")" \
"${EVENTS_ARGS[@]}"
echo
echo "=== movement statistics (TR, subject=$SUBJECT_NAME) ==="
python3 "$REPO/tools/robocode_fixture_capture/analyze.py" "$OUT_JSONL"