Files
SirRoboGarage/tools/robocode_shim/build.sh
T
SirStone 8e2be6a4c6 feat(tools): the real DrussGT now plays and wins Tank Royale battles
The unmodified DrussGT.jar connects, wave-surfs, fires and beats every
adversary we have. 5 rounds each, all rounds won:
  SpinBot 542-16, Corners 823-4, Crazy 604-0, RamFire 900-0,
  ModularBot 506-72.

It is genuinely surfing, not drifting or stalling. Movement statistics
against the classic captures, same metrics, same analyzer:

  opp        perp TR/classic   reversing TR/cl   median range TR/cl
  SpinBot    0.967 / 0.962     0.466 / 0.464     462 / 402
  Corners    0.894 / 0.920     0.462 / 0.419     520 / 504
  Crazy      0.841 / 0.829     0.527 / 0.439     370 / 378
  RamFire    0.762 / 0.651     0.533 / 0.417     326 / 283
  ModularBot 0.956 / -         0.466 / -         453 / -

Every round starts moving within 3-11 ticks and runs at 75-82% full speed.

Implemented: the classic remaining-quantity motion model (delegated to the
TR Bot's own Nat-Pavasant model - identical constants: accel 1, decel -2,
max 8, body turn 10-0.75|v|, gun 20, radar 45 - so getDistanceRemaining and
getTurnRemaining are exactly self-consistent with what is emulated); event
synthesis with classic ordering; bullet identity via object identity; gun
heat; rounds; radar cadence; firing translation; and the ThreadManager
landmine is killed by installing a no-op IThreadManagerBase in
ContainerBase.instance (verified: without it 'RobotException: ThreadManager
cannot be null!' kills the bot thread; with it the write succeeds).

Also adds TrBattleCapture, an observer that dumps per-tick state in the SAME
JSONL fixture format as the classic capture, so legacy bots can be captured
from Tank Royale battles too.

HONEST DIVERGENCES (README section 5.9): the TR server moves along the
PRE-turn heading and then turns, while classic aligns displacement with the
POST-turn heading, so the analyzer's conversion error is ~1.5 deg rather than
0.000 deg; distanceRemaining decrements by target speed rather than actual
distance; collision clamping differs; BulletMissedEvent can fire less often
because age-expiry has no TR event; bulletId is a local temp id;
StatusEvent/onPaint/SkippedTurnEvent are never delivered. Physics fidelity
diverges by construction - expect to retune.

EnergyDomeWorker (the bullet shield) is off by default: its precise
bullet-detection warm-up makes round 1 up to 79% stationary vs 35% in
classic. Rounds 2+ match classic closely with it on, but the pure surfer is
the consistent path. DRUSSGT_SHIELD=1 re-enables it.

Jars remain out of git.
2026-09-21 00:29:37 +02:00

48 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Build the Approach-(B) shim.
#
# Requires JAVA_HOME/javac on PATH, the genuine Robocode 1.9.5.5 jar (for the
# robocode.* API the peer implements) and the Tank Royale Java bot API jar (for
# DrussGTBridge / TrBattleCapture).
#
# ROBOCODE_JAR=/path/to/robocode.jar TR_BOT_API_JAR=/path/to/bot-api.jar ./build.sh
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROBOCODE_JAR="${ROBOCODE_JAR:-/tmp/robocode/install/libs/robocode.jar}"
TR_BOT_API_JAR="${TR_BOT_API_JAR:-$HOME/Downloads/sample-bots-java-1.0.2/lib/robocode-tankroyale-bot-api-1.0.2.jar}"
OUT="${OUT:-$HERE/out}"
RUNNER_JAR="${TR_RUNNER_JAR:-/home/davide/Projects/tank-royale/runner/examples/lib/robocode-tankroyale-runner.jar}"
if [[ ! -f "$ROBOCODE_JAR" ]]; then
echo "robocode.jar not found: $ROBOCODE_JAR" >&2
echo "Set ROBOCODE_JAR to a Robocode 1.9.5.5 install's libs/robocode.jar" >&2
exit 1
fi
if [[ ! -f "$TR_BOT_API_JAR" ]]; then
echo "Tank Royale bot API jar not found: $TR_BOT_API_JAR" >&2
echo "Set TR_BOT_API_JAR to robocode-tankroyale-bot-api-*.jar" >&2
exit 1
fi
mkdir -p "$OUT"
javac -nowarn -cp "$ROBOCODE_JAR:$TR_BOT_API_JAR" -d "$OUT" \
"$HERE/src/robocode_shim/ClassicPeer.java" \
"$HERE/src/robocode_shim/BotHost.java" \
"$HERE/src/robocode_shim/TankRoyaleBridge.java" \
"$HERE/src/robocode_shim/ThreadManagerFix.java" \
"$HERE/src/robocode_shim/ThreadManagerFixTest.java" \
"$HERE/src/robocode_shim/DrussGTBridge.java" \
"$HERE/src/robocode_shim/SmokeTest.java"
echo "shim built -> $OUT"
# The observer/capture program needs the battle-runner jar (which bundles the
# Tank Royale client model + embedded server) rather than the bot API.
if [[ -f "$RUNNER_JAR" ]]; then
javac -nowarn -cp "$RUNNER_JAR" -d "$OUT" \
"$HERE/src/robocode_shim/TrBattleCapture.java"
echo "capture built -> $OUT"
else
echo "runner jar not found ($RUNNER_JAR); skipped TrBattleCapture" >&2
fi