diff --git a/.gitignore b/.gitignore index 0a87a52..57efe18 100644 --- a/.gitignore +++ b/.gitignore @@ -56,7 +56,7 @@ common_libs/tests/test_tsetlin_live common_libs/tests/test_tm_pattern_learning # measurement tool binaries (no extension); sources are measure_*.nim -tr_bots/ +tr_bots/* # Measurement-tool binaries (extensionless; their .nim/.py/.txt sources stay tracked) common_libs/tests/measure_tm_readapt @@ -72,3 +72,30 @@ common_libs/tests/diag_tm_pattern_offline # Primary source archive kept locally, NOT tracked (12 MB) docs/BitBrain_C_code.zip + +# raw_recorder build output +tools/raw_recorder/out/ +tools/raw_recorder/shadow-classes/ + +# _salvage (rescued from /tmp): re-include, but keep the multi-MB legacy bot jars off git. +# tr_bots/ is otherwise ignored (generated wrappers / build output). +!tr_bots/_salvage/ +tr_bots/_salvage/* +!tr_bots/_salvage/README.md +!tr_bots/_salvage/legacy_bots/ +tr_bots/_salvage/legacy_bots/* +!tr_bots/_salvage/legacy_bots/MANIFEST.sha256 +!tr_bots/_salvage/tr_wrappers/ +!tr_bots/_salvage/portaudit/ +!tr_bots/_salvage/shim/ + +# Legacy champion bot jars ARE committed: their license reads "not stated in +# jar" for every bot (see tools/robocode_shim/robots.json), but the repo owner +# has explicitly waived that concern — it is a PRIVATE repo on their own LAN. +# The jars are not reproducible from here, and an over-broad *.jar rule already +# cost us the only copy of DrussGT.jar once. +!legacy_bots/**/*.jar +legacy_bots/**/*.jar.* + +# DrussGT raw recorded corpora (large, regenerable via tools/raw_recorder) +data/drussgt_raw/ diff --git a/legacy_bots/Ascendant/Ascendant.jar b/legacy_bots/Ascendant/Ascendant.jar new file mode 100644 index 0000000..fd08817 Binary files /dev/null and b/legacy_bots/Ascendant/Ascendant.jar differ diff --git a/legacy_bots/Ascendant/Ascendant.json b/legacy_bots/Ascendant/Ascendant.json new file mode 100644 index 0000000..ecb05fa --- /dev/null +++ b/legacy_bots/Ascendant/Ascendant.json @@ -0,0 +1,11 @@ +{ + "name": "Ascendant", + "version": "1.2.27", + "authors": ["unknown"], + "description": "Classic Robocode robot mue.Ascendant running on Tank Royale via the robocode_shim bridge", + "homepage": "", + "countryCodes": ["se"], + "gameTypes": ["classic", "1v1"], + "platform": "JVM", + "programmingLang": "Java 8" +} diff --git a/legacy_bots/Ascendant/Ascendant.sh b/legacy_bots/Ascendant/Ascendant.sh new file mode 100755 index 0000000..db1a96d --- /dev/null +++ b/legacy_bots/Ascendant/Ascendant.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Legacy classic-Robocode robot hosted on Tank Royale by our own shim. +# Bootable by the official tankroyale booter (SERVER_URL/SERVER_SECRET come from +# the environment - this script never hardcodes a server address). +cd "$(dirname "$0")" +HERE="$(pwd)" +REPO="$(cd "$HERE/../.." && pwd)" + +export SHIM_BOT_CLASS="mue.Ascendant" +export SHIM_BOT_JAR="$HERE/Ascendant.jar" + +: "${SHIM_DATA:=${DRUSSGT_DATA:-$(mktemp -d "${TMPDIR:-/tmp}/tr_shim_data.XXXXXX")}}" +export SHIM_DATA + +: "${BOT_NAME:=Ascendant}" +export BOT_NAME +: "${BOT_VERSION:=1.2.27}" +export BOT_VERSION +: "${BOT_AUTHORS:=unknown}" +export BOT_AUTHORS +: "${BOT_DESCRIPTION:=Classic Robocode robot mue.Ascendant running on Tank Royale via the robocode_shim bridge}" +export BOT_DESCRIPTION +: "${BOT_HOMEPAGE:=}" +export BOT_HOMEPAGE +: "${BOT_COUNTRY_CODES:=se}" +export BOT_COUNTRY_CODES +: "${BOT_GAME_TYPES:=classic,1v1}" +export BOT_GAME_TYPES +: "${BOT_PLATFORM:=JVM}" +export BOT_PLATFORM +: "${BOT_PROG_LANG:=Java 8}" +export BOT_PROG_LANG + +exec java -cp "$REPO/tools/robocode_shim/out:$REPO/tools/robocode_shim/vendor/robocode.jar:$REPO/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar" robocode_shim.LegacyBotBridge diff --git a/legacy_bots/BlitzBat/BlitzBat.jar b/legacy_bots/BlitzBat/BlitzBat.jar new file mode 100644 index 0000000..35a9b52 Binary files /dev/null and b/legacy_bots/BlitzBat/BlitzBat.jar differ diff --git a/legacy_bots/BlitzBat/BlitzBat.json b/legacy_bots/BlitzBat/BlitzBat.json new file mode 100644 index 0000000..24a8e45 --- /dev/null +++ b/legacy_bots/BlitzBat/BlitzBat.json @@ -0,0 +1,11 @@ +{ + "name": "BlitzBat", + "version": "1.05", + "authors": ["unknown"], + "description": "Classic Robocode robot voidious.micro.BlitzBat running on Tank Royale via the robocode_shim bridge", + "homepage": "", + "countryCodes": ["se"], + "gameTypes": ["classic", "1v1"], + "platform": "JVM", + "programmingLang": "Java 8" +} diff --git a/legacy_bots/BlitzBat/BlitzBat.sh b/legacy_bots/BlitzBat/BlitzBat.sh new file mode 100755 index 0000000..5e904b9 --- /dev/null +++ b/legacy_bots/BlitzBat/BlitzBat.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Legacy classic-Robocode robot hosted on Tank Royale by our own shim. +# Bootable by the official tankroyale booter (SERVER_URL/SERVER_SECRET come from +# the environment - this script never hardcodes a server address). +cd "$(dirname "$0")" +HERE="$(pwd)" +REPO="$(cd "$HERE/../.." && pwd)" + +export SHIM_BOT_CLASS="voidious.micro.BlitzBat" +export SHIM_BOT_JAR="$HERE/BlitzBat.jar" + +: "${SHIM_DATA:=${DRUSSGT_DATA:-$(mktemp -d "${TMPDIR:-/tmp}/tr_shim_data.XXXXXX")}}" +export SHIM_DATA + +: "${BOT_NAME:=BlitzBat}" +export BOT_NAME +: "${BOT_VERSION:=1.05}" +export BOT_VERSION +: "${BOT_AUTHORS:=unknown}" +export BOT_AUTHORS +: "${BOT_DESCRIPTION:=Classic Robocode robot voidious.micro.BlitzBat running on Tank Royale via the robocode_shim bridge}" +export BOT_DESCRIPTION +: "${BOT_HOMEPAGE:=}" +export BOT_HOMEPAGE +: "${BOT_COUNTRY_CODES:=se}" +export BOT_COUNTRY_CODES +: "${BOT_GAME_TYPES:=classic,1v1}" +export BOT_GAME_TYPES +: "${BOT_PLATFORM:=JVM}" +export BOT_PLATFORM +: "${BOT_PROG_LANG:=Java 8}" +export BOT_PROG_LANG + +exec java -cp "$REPO/tools/robocode_shim/out:$REPO/tools/robocode_shim/vendor/robocode.jar:$REPO/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar" robocode_shim.LegacyBotBridge diff --git a/legacy_bots/BrokenSword/BrokenSword.jar b/legacy_bots/BrokenSword/BrokenSword.jar new file mode 100644 index 0000000..7992a1b Binary files /dev/null and b/legacy_bots/BrokenSword/BrokenSword.jar differ diff --git a/legacy_bots/BrokenSword/BrokenSword.json b/legacy_bots/BrokenSword/BrokenSword.json new file mode 100644 index 0000000..addc43e --- /dev/null +++ b/legacy_bots/BrokenSword/BrokenSword.json @@ -0,0 +1,11 @@ +{ + "name": "BrokenSword", + "version": "2.0.3", + "authors": ["unknown"], + "description": "Classic Robocode robot voidious.mini.BrokenSword running on Tank Royale via the robocode_shim bridge", + "homepage": "", + "countryCodes": ["se"], + "gameTypes": ["classic", "1v1"], + "platform": "JVM", + "programmingLang": "Java 8" +} diff --git a/legacy_bots/BrokenSword/BrokenSword.sh b/legacy_bots/BrokenSword/BrokenSword.sh new file mode 100755 index 0000000..1bf3a7f --- /dev/null +++ b/legacy_bots/BrokenSword/BrokenSword.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Legacy classic-Robocode robot hosted on Tank Royale by our own shim. +# Bootable by the official tankroyale booter (SERVER_URL/SERVER_SECRET come from +# the environment - this script never hardcodes a server address). +cd "$(dirname "$0")" +HERE="$(pwd)" +REPO="$(cd "$HERE/../.." && pwd)" + +export SHIM_BOT_CLASS="voidious.mini.BrokenSword" +export SHIM_BOT_JAR="$HERE/BrokenSword.jar" + +: "${SHIM_DATA:=${DRUSSGT_DATA:-$(mktemp -d "${TMPDIR:-/tmp}/tr_shim_data.XXXXXX")}}" +export SHIM_DATA + +: "${BOT_NAME:=BrokenSword}" +export BOT_NAME +: "${BOT_VERSION:=2.0.3}" +export BOT_VERSION +: "${BOT_AUTHORS:=unknown}" +export BOT_AUTHORS +: "${BOT_DESCRIPTION:=Classic Robocode robot voidious.mini.BrokenSword running on Tank Royale via the robocode_shim bridge}" +export BOT_DESCRIPTION +: "${BOT_HOMEPAGE:=}" +export BOT_HOMEPAGE +: "${BOT_COUNTRY_CODES:=se}" +export BOT_COUNTRY_CODES +: "${BOT_GAME_TYPES:=classic,1v1}" +export BOT_GAME_TYPES +: "${BOT_PLATFORM:=JVM}" +export BOT_PLATFORM +: "${BOT_PROG_LANG:=Java 8}" +export BOT_PROG_LANG + +exec java -cp "$REPO/tools/robocode_shim/out:$REPO/tools/robocode_shim/vendor/robocode.jar:$REPO/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar" robocode_shim.LegacyBotBridge diff --git a/legacy_bots/CassiusClay/CassiusClay.jar b/legacy_bots/CassiusClay/CassiusClay.jar new file mode 100644 index 0000000..11c5c55 Binary files /dev/null and b/legacy_bots/CassiusClay/CassiusClay.jar differ diff --git a/legacy_bots/CassiusClay/CassiusClay.json b/legacy_bots/CassiusClay/CassiusClay.json new file mode 100644 index 0000000..b244b08 --- /dev/null +++ b/legacy_bots/CassiusClay/CassiusClay.json @@ -0,0 +1,11 @@ +{ + "name": "CassiusClay", + "version": "2rho.02no", + "authors": ["unknown"], + "description": "Classic Robocode robot pez.rumble.CassiusClay running on Tank Royale via the robocode_shim bridge", + "homepage": "", + "countryCodes": ["se"], + "gameTypes": ["classic", "1v1"], + "platform": "JVM", + "programmingLang": "Java 8" +} diff --git a/legacy_bots/CassiusClay/CassiusClay.sh b/legacy_bots/CassiusClay/CassiusClay.sh new file mode 100755 index 0000000..49c755e --- /dev/null +++ b/legacy_bots/CassiusClay/CassiusClay.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Legacy classic-Robocode robot hosted on Tank Royale by our own shim. +# Bootable by the official tankroyale booter (SERVER_URL/SERVER_SECRET come from +# the environment - this script never hardcodes a server address). +cd "$(dirname "$0")" +HERE="$(pwd)" +REPO="$(cd "$HERE/../.." && pwd)" + +export SHIM_BOT_CLASS="pez.rumble.CassiusClay" +export SHIM_BOT_JAR="$HERE/CassiusClay.jar" + +: "${SHIM_DATA:=${DRUSSGT_DATA:-$(mktemp -d "${TMPDIR:-/tmp}/tr_shim_data.XXXXXX")}}" +export SHIM_DATA + +: "${BOT_NAME:=CassiusClay}" +export BOT_NAME +: "${BOT_VERSION:=2rho.02no}" +export BOT_VERSION +: "${BOT_AUTHORS:=unknown}" +export BOT_AUTHORS +: "${BOT_DESCRIPTION:=Classic Robocode robot pez.rumble.CassiusClay running on Tank Royale via the robocode_shim bridge}" +export BOT_DESCRIPTION +: "${BOT_HOMEPAGE:=}" +export BOT_HOMEPAGE +: "${BOT_COUNTRY_CODES:=se}" +export BOT_COUNTRY_CODES +: "${BOT_GAME_TYPES:=classic,1v1}" +export BOT_GAME_TYPES +: "${BOT_PLATFORM:=JVM}" +export BOT_PLATFORM +: "${BOT_PROG_LANG:=Java 8}" +export BOT_PROG_LANG + +exec java -cp "$REPO/tools/robocode_shim/out:$REPO/tools/robocode_shim/vendor/robocode.jar:$REPO/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar" robocode_shim.LegacyBotBridge diff --git a/legacy_bots/Cigaret/Cigaret.jar b/legacy_bots/Cigaret/Cigaret.jar new file mode 100644 index 0000000..b55a9ed Binary files /dev/null and b/legacy_bots/Cigaret/Cigaret.jar differ diff --git a/legacy_bots/Cigaret/Cigaret.json b/legacy_bots/Cigaret/Cigaret.json new file mode 100644 index 0000000..544f513 --- /dev/null +++ b/legacy_bots/Cigaret/Cigaret.json @@ -0,0 +1,11 @@ +{ + "name": "Cigaret", + "version": "1.31", + "authors": ["unknown"], + "description": "Classic Robocode robot cx.mini.Cigaret running on Tank Royale via the robocode_shim bridge", + "homepage": "", + "countryCodes": ["se"], + "gameTypes": ["classic", "1v1"], + "platform": "JVM", + "programmingLang": "Java 8" +} diff --git a/legacy_bots/Cigaret/Cigaret.sh b/legacy_bots/Cigaret/Cigaret.sh new file mode 100755 index 0000000..b359f56 --- /dev/null +++ b/legacy_bots/Cigaret/Cigaret.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Legacy classic-Robocode robot hosted on Tank Royale by our own shim. +# Bootable by the official tankroyale booter (SERVER_URL/SERVER_SECRET come from +# the environment - this script never hardcodes a server address). +cd "$(dirname "$0")" +HERE="$(pwd)" +REPO="$(cd "$HERE/../.." && pwd)" + +export SHIM_BOT_CLASS="cx.mini.Cigaret" +export SHIM_BOT_JAR="$HERE/Cigaret.jar" + +: "${SHIM_DATA:=${DRUSSGT_DATA:-$(mktemp -d "${TMPDIR:-/tmp}/tr_shim_data.XXXXXX")}}" +export SHIM_DATA + +: "${BOT_NAME:=Cigaret}" +export BOT_NAME +: "${BOT_VERSION:=1.31}" +export BOT_VERSION +: "${BOT_AUTHORS:=unknown}" +export BOT_AUTHORS +: "${BOT_DESCRIPTION:=Classic Robocode robot cx.mini.Cigaret running on Tank Royale via the robocode_shim bridge}" +export BOT_DESCRIPTION +: "${BOT_HOMEPAGE:=}" +export BOT_HOMEPAGE +: "${BOT_COUNTRY_CODES:=se}" +export BOT_COUNTRY_CODES +: "${BOT_GAME_TYPES:=classic,1v1}" +export BOT_GAME_TYPES +: "${BOT_PLATFORM:=JVM}" +export BOT_PLATFORM +: "${BOT_PROG_LANG:=Java 8}" +export BOT_PROG_LANG + +exec java -cp "$REPO/tools/robocode_shim/out:$REPO/tools/robocode_shim/vendor/robocode.jar:$REPO/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar" robocode_shim.LegacyBotBridge diff --git a/legacy_bots/CigaretBH/CigaretBH.jar b/legacy_bots/CigaretBH/CigaretBH.jar new file mode 100644 index 0000000..afa8f1a Binary files /dev/null and b/legacy_bots/CigaretBH/CigaretBH.jar differ diff --git a/legacy_bots/CigaretBH/CigaretBH.json b/legacy_bots/CigaretBH/CigaretBH.json new file mode 100644 index 0000000..72db69e --- /dev/null +++ b/legacy_bots/CigaretBH/CigaretBH.json @@ -0,0 +1,11 @@ +{ + "name": "CigaretBH", + "version": "1.03", + "authors": ["unknown"], + "description": "Classic Robocode robot cx.CigaretBH running on Tank Royale via the robocode_shim bridge", + "homepage": "", + "countryCodes": ["se"], + "gameTypes": ["classic", "1v1"], + "platform": "JVM", + "programmingLang": "Java 8" +} diff --git a/legacy_bots/CigaretBH/CigaretBH.sh b/legacy_bots/CigaretBH/CigaretBH.sh new file mode 100755 index 0000000..396dea1 --- /dev/null +++ b/legacy_bots/CigaretBH/CigaretBH.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Legacy classic-Robocode robot hosted on Tank Royale by our own shim. +# Bootable by the official tankroyale booter (SERVER_URL/SERVER_SECRET come from +# the environment - this script never hardcodes a server address). +cd "$(dirname "$0")" +HERE="$(pwd)" +REPO="$(cd "$HERE/../.." && pwd)" + +export SHIM_BOT_CLASS="cx.CigaretBH" +export SHIM_BOT_JAR="$HERE/CigaretBH.jar" + +: "${SHIM_DATA:=${DRUSSGT_DATA:-$(mktemp -d "${TMPDIR:-/tmp}/tr_shim_data.XXXXXX")}}" +export SHIM_DATA + +: "${BOT_NAME:=CigaretBH}" +export BOT_NAME +: "${BOT_VERSION:=1.03}" +export BOT_VERSION +: "${BOT_AUTHORS:=unknown}" +export BOT_AUTHORS +: "${BOT_DESCRIPTION:=Classic Robocode robot cx.CigaretBH running on Tank Royale via the robocode_shim bridge}" +export BOT_DESCRIPTION +: "${BOT_HOMEPAGE:=}" +export BOT_HOMEPAGE +: "${BOT_COUNTRY_CODES:=se}" +export BOT_COUNTRY_CODES +: "${BOT_GAME_TYPES:=classic,1v1}" +export BOT_GAME_TYPES +: "${BOT_PLATFORM:=JVM}" +export BOT_PLATFORM +: "${BOT_PROG_LANG:=Java 8}" +export BOT_PROG_LANG + +exec java -cp "$REPO/tools/robocode_shim/out:$REPO/tools/robocode_shim/vendor/robocode.jar:$REPO/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar" robocode_shim.LegacyBotBridge diff --git a/legacy_bots/Coriantumr/Coriantumr.jar b/legacy_bots/Coriantumr/Coriantumr.jar new file mode 100644 index 0000000..589d47f Binary files /dev/null and b/legacy_bots/Coriantumr/Coriantumr.jar differ diff --git a/legacy_bots/Coriantumr/Coriantumr.json b/legacy_bots/Coriantumr/Coriantumr.json new file mode 100644 index 0000000..6f5c12e --- /dev/null +++ b/legacy_bots/Coriantumr/Coriantumr.json @@ -0,0 +1,11 @@ +{ + "name": "Coriantumr", + "version": "1.1", + "authors": ["unknown"], + "description": "Classic Robocode robot kawigi.mini.Coriantumr running on Tank Royale via the robocode_shim bridge", + "homepage": "", + "countryCodes": ["se"], + "gameTypes": ["classic", "1v1"], + "platform": "JVM", + "programmingLang": "Java 8" +} diff --git a/legacy_bots/Coriantumr/Coriantumr.sh b/legacy_bots/Coriantumr/Coriantumr.sh new file mode 100755 index 0000000..fe830d4 --- /dev/null +++ b/legacy_bots/Coriantumr/Coriantumr.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Legacy classic-Robocode robot hosted on Tank Royale by our own shim. +# Bootable by the official tankroyale booter (SERVER_URL/SERVER_SECRET come from +# the environment - this script never hardcodes a server address). +cd "$(dirname "$0")" +HERE="$(pwd)" +REPO="$(cd "$HERE/../.." && pwd)" + +export SHIM_BOT_CLASS="kawigi.mini.Coriantumr" +export SHIM_BOT_JAR="$HERE/Coriantumr.jar" + +: "${SHIM_DATA:=${DRUSSGT_DATA:-$(mktemp -d "${TMPDIR:-/tmp}/tr_shim_data.XXXXXX")}}" +export SHIM_DATA + +: "${BOT_NAME:=Coriantumr}" +export BOT_NAME +: "${BOT_VERSION:=1.1}" +export BOT_VERSION +: "${BOT_AUTHORS:=unknown}" +export BOT_AUTHORS +: "${BOT_DESCRIPTION:=Classic Robocode robot kawigi.mini.Coriantumr running on Tank Royale via the robocode_shim bridge}" +export BOT_DESCRIPTION +: "${BOT_HOMEPAGE:=}" +export BOT_HOMEPAGE +: "${BOT_COUNTRY_CODES:=se}" +export BOT_COUNTRY_CODES +: "${BOT_GAME_TYPES:=classic,1v1}" +export BOT_GAME_TYPES +: "${BOT_PLATFORM:=JVM}" +export BOT_PLATFORM +: "${BOT_PROG_LANG:=Java 8}" +export BOT_PROG_LANG + +exec java -cp "$REPO/tools/robocode_shim/out:$REPO/tools/robocode_shim/vendor/robocode.jar:$REPO/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar" robocode_shim.LegacyBotBridge diff --git a/legacy_bots/Diamond/Diamond.jar b/legacy_bots/Diamond/Diamond.jar new file mode 100644 index 0000000..ab3ddf4 Binary files /dev/null and b/legacy_bots/Diamond/Diamond.jar differ diff --git a/legacy_bots/Diamond/Diamond.json b/legacy_bots/Diamond/Diamond.json new file mode 100644 index 0000000..e4236aa --- /dev/null +++ b/legacy_bots/Diamond/Diamond.json @@ -0,0 +1,11 @@ +{ + "name": "Diamond", + "version": "1.8.28", + "authors": ["unknown"], + "description": "Classic Robocode robot voidious.Diamond running on Tank Royale via the robocode_shim bridge", + "homepage": "", + "countryCodes": ["se"], + "gameTypes": ["classic", "1v1"], + "platform": "JVM", + "programmingLang": "Java 8" +} diff --git a/legacy_bots/Diamond/Diamond.sh b/legacy_bots/Diamond/Diamond.sh new file mode 100755 index 0000000..1c5d9e1 --- /dev/null +++ b/legacy_bots/Diamond/Diamond.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Legacy classic-Robocode robot hosted on Tank Royale by our own shim. +# Bootable by the official tankroyale booter (SERVER_URL/SERVER_SECRET come from +# the environment - this script never hardcodes a server address). +cd "$(dirname "$0")" +HERE="$(pwd)" +REPO="$(cd "$HERE/../.." && pwd)" + +export SHIM_BOT_CLASS="voidious.Diamond" +export SHIM_BOT_JAR="$HERE/Diamond.jar" + +: "${SHIM_DATA:=${DRUSSGT_DATA:-$(mktemp -d "${TMPDIR:-/tmp}/tr_shim_data.XXXXXX")}}" +export SHIM_DATA + +: "${BOT_NAME:=Diamond}" +export BOT_NAME +: "${BOT_VERSION:=1.8.28}" +export BOT_VERSION +: "${BOT_AUTHORS:=unknown}" +export BOT_AUTHORS +: "${BOT_DESCRIPTION:=Classic Robocode robot voidious.Diamond running on Tank Royale via the robocode_shim bridge}" +export BOT_DESCRIPTION +: "${BOT_HOMEPAGE:=}" +export BOT_HOMEPAGE +: "${BOT_COUNTRY_CODES:=se}" +export BOT_COUNTRY_CODES +: "${BOT_GAME_TYPES:=classic,1v1}" +export BOT_GAME_TYPES +: "${BOT_PLATFORM:=JVM}" +export BOT_PLATFORM +: "${BOT_PROG_LANG:=Java 8}" +export BOT_PROG_LANG + +exec java -cp "$REPO/tools/robocode_shim/out:$REPO/tools/robocode_shim/vendor/robocode.jar:$REPO/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar" robocode_shim.LegacyBotBridge diff --git a/legacy_bots/DiamondHawk/DiamondHawk.jar b/legacy_bots/DiamondHawk/DiamondHawk.jar new file mode 100644 index 0000000..0869210 Binary files /dev/null and b/legacy_bots/DiamondHawk/DiamondHawk.jar differ diff --git a/legacy_bots/DiamondHawk/DiamondHawk.json b/legacy_bots/DiamondHawk/DiamondHawk.json new file mode 100644 index 0000000..e6ed04a --- /dev/null +++ b/legacy_bots/DiamondHawk/DiamondHawk.json @@ -0,0 +1,11 @@ +{ + "name": "DiamondHawk", + "version": "1.02", + "authors": ["unknown"], + "description": "Classic Robocode robot wiki.DiamondHawk running on Tank Royale via the robocode_shim bridge", + "homepage": "", + "countryCodes": ["se"], + "gameTypes": ["classic", "1v1"], + "platform": "JVM", + "programmingLang": "Java 8" +} diff --git a/legacy_bots/DiamondHawk/DiamondHawk.sh b/legacy_bots/DiamondHawk/DiamondHawk.sh new file mode 100755 index 0000000..994334a --- /dev/null +++ b/legacy_bots/DiamondHawk/DiamondHawk.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Legacy classic-Robocode robot hosted on Tank Royale by our own shim. +# Bootable by the official tankroyale booter (SERVER_URL/SERVER_SECRET come from +# the environment - this script never hardcodes a server address). +cd "$(dirname "$0")" +HERE="$(pwd)" +REPO="$(cd "$HERE/../.." && pwd)" + +export SHIM_BOT_CLASS="wiki.DiamondHawk" +export SHIM_BOT_JAR="$HERE/DiamondHawk.jar" + +: "${SHIM_DATA:=${DRUSSGT_DATA:-$(mktemp -d "${TMPDIR:-/tmp}/tr_shim_data.XXXXXX")}}" +export SHIM_DATA + +: "${BOT_NAME:=DiamondHawk}" +export BOT_NAME +: "${BOT_VERSION:=1.02}" +export BOT_VERSION +: "${BOT_AUTHORS:=unknown}" +export BOT_AUTHORS +: "${BOT_DESCRIPTION:=Classic Robocode robot wiki.DiamondHawk running on Tank Royale via the robocode_shim bridge}" +export BOT_DESCRIPTION +: "${BOT_HOMEPAGE:=}" +export BOT_HOMEPAGE +: "${BOT_COUNTRY_CODES:=se}" +export BOT_COUNTRY_CODES +: "${BOT_GAME_TYPES:=classic,1v1}" +export BOT_GAME_TYPES +: "${BOT_PLATFORM:=JVM}" +export BOT_PLATFORM +: "${BOT_PROG_LANG:=Java 8}" +export BOT_PROG_LANG + +exec java -cp "$REPO/tools/robocode_shim/out:$REPO/tools/robocode_shim/vendor/robocode.jar:$REPO/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar" robocode_shim.LegacyBotBridge diff --git a/legacy_bots/DiamondStealer/DiamondStealer.jar b/legacy_bots/DiamondStealer/DiamondStealer.jar new file mode 100644 index 0000000..e323442 Binary files /dev/null and b/legacy_bots/DiamondStealer/DiamondStealer.jar differ diff --git a/legacy_bots/DiamondStealer/DiamondStealer.json b/legacy_bots/DiamondStealer/DiamondStealer.json new file mode 100644 index 0000000..0471f2f --- /dev/null +++ b/legacy_bots/DiamondStealer/DiamondStealer.json @@ -0,0 +1,11 @@ +{ + "name": "DiamondStealer", + "version": "5", + "authors": ["unknown"], + "description": "Classic Robocode robot jab.DiamondStealer running on Tank Royale via the robocode_shim bridge", + "homepage": "", + "countryCodes": ["se"], + "gameTypes": ["classic", "1v1"], + "platform": "JVM", + "programmingLang": "Java 8" +} diff --git a/legacy_bots/DiamondStealer/DiamondStealer.sh b/legacy_bots/DiamondStealer/DiamondStealer.sh new file mode 100755 index 0000000..2ea085c --- /dev/null +++ b/legacy_bots/DiamondStealer/DiamondStealer.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Legacy classic-Robocode robot hosted on Tank Royale by our own shim. +# Bootable by the official tankroyale booter (SERVER_URL/SERVER_SECRET come from +# the environment - this script never hardcodes a server address). +cd "$(dirname "$0")" +HERE="$(pwd)" +REPO="$(cd "$HERE/../.." && pwd)" + +export SHIM_BOT_CLASS="jab.DiamondStealer" +export SHIM_BOT_JAR="$HERE/DiamondStealer.jar" + +: "${SHIM_DATA:=${DRUSSGT_DATA:-$(mktemp -d "${TMPDIR:-/tmp}/tr_shim_data.XXXXXX")}}" +export SHIM_DATA + +: "${BOT_NAME:=DiamondStealer}" +export BOT_NAME +: "${BOT_VERSION:=5}" +export BOT_VERSION +: "${BOT_AUTHORS:=unknown}" +export BOT_AUTHORS +: "${BOT_DESCRIPTION:=Classic Robocode robot jab.DiamondStealer running on Tank Royale via the robocode_shim bridge}" +export BOT_DESCRIPTION +: "${BOT_HOMEPAGE:=}" +export BOT_HOMEPAGE +: "${BOT_COUNTRY_CODES:=se}" +export BOT_COUNTRY_CODES +: "${BOT_GAME_TYPES:=classic,1v1}" +export BOT_GAME_TYPES +: "${BOT_PLATFORM:=JVM}" +export BOT_PLATFORM +: "${BOT_PROG_LANG:=Java 8}" +export BOT_PROG_LANG + +exec java -cp "$REPO/tools/robocode_shim/out:$REPO/tools/robocode_shim/vendor/robocode.jar:$REPO/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar" robocode_shim.LegacyBotBridge diff --git a/legacy_bots/Dookious/Dookious.jar b/legacy_bots/Dookious/Dookious.jar new file mode 100644 index 0000000..ac3173f Binary files /dev/null and b/legacy_bots/Dookious/Dookious.jar differ diff --git a/legacy_bots/Dookious/Dookious.json b/legacy_bots/Dookious/Dookious.json new file mode 100644 index 0000000..ff21e54 --- /dev/null +++ b/legacy_bots/Dookious/Dookious.json @@ -0,0 +1,11 @@ +{ + "name": "Dookious", + "version": "1.60", + "authors": ["unknown"], + "description": "Classic Robocode robot voidious.Dookious running on Tank Royale via the robocode_shim bridge", + "homepage": "", + "countryCodes": ["se"], + "gameTypes": ["classic", "1v1"], + "platform": "JVM", + "programmingLang": "Java 8" +} diff --git a/legacy_bots/Dookious/Dookious.sh b/legacy_bots/Dookious/Dookious.sh new file mode 100755 index 0000000..655f86a --- /dev/null +++ b/legacy_bots/Dookious/Dookious.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Legacy classic-Robocode robot hosted on Tank Royale by our own shim. +# Bootable by the official tankroyale booter (SERVER_URL/SERVER_SECRET come from +# the environment - this script never hardcodes a server address). +cd "$(dirname "$0")" +HERE="$(pwd)" +REPO="$(cd "$HERE/../.." && pwd)" + +export SHIM_BOT_CLASS="voidious.Dookious" +export SHIM_BOT_JAR="$HERE/Dookious.jar" + +: "${SHIM_DATA:=${DRUSSGT_DATA:-$(mktemp -d "${TMPDIR:-/tmp}/tr_shim_data.XXXXXX")}}" +export SHIM_DATA + +: "${BOT_NAME:=Dookious}" +export BOT_NAME +: "${BOT_VERSION:=1.60}" +export BOT_VERSION +: "${BOT_AUTHORS:=unknown}" +export BOT_AUTHORS +: "${BOT_DESCRIPTION:=Classic Robocode robot voidious.Dookious running on Tank Royale via the robocode_shim bridge}" +export BOT_DESCRIPTION +: "${BOT_HOMEPAGE:=}" +export BOT_HOMEPAGE +: "${BOT_COUNTRY_CODES:=se}" +export BOT_COUNTRY_CODES +: "${BOT_GAME_TYPES:=classic,1v1}" +export BOT_GAME_TYPES +: "${BOT_PLATFORM:=JVM}" +export BOT_PLATFORM +: "${BOT_PROG_LANG:=Java 8}" +export BOT_PROG_LANG + +exec java -cp "$REPO/tools/robocode_shim/out:$REPO/tools/robocode_shim/vendor/robocode.jar:$REPO/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar" robocode_shim.LegacyBotBridge diff --git a/legacy_bots/GresSuffurd/GresSuffurd.jar b/legacy_bots/GresSuffurd/GresSuffurd.jar new file mode 100644 index 0000000..7c242f5 Binary files /dev/null and b/legacy_bots/GresSuffurd/GresSuffurd.jar differ diff --git a/legacy_bots/GresSuffurd/GresSuffurd.json b/legacy_bots/GresSuffurd/GresSuffurd.json new file mode 100644 index 0000000..1fa3b6b --- /dev/null +++ b/legacy_bots/GresSuffurd/GresSuffurd.json @@ -0,0 +1,11 @@ +{ + "name": "GresSuffurd", + "version": "0.4.18", + "authors": ["unknown"], + "description": "Classic Robocode robot gh.GresSuffurd running on Tank Royale via the robocode_shim bridge", + "homepage": "", + "countryCodes": ["se"], + "gameTypes": ["classic", "1v1"], + "platform": "JVM", + "programmingLang": "Java 8" +} diff --git a/legacy_bots/GresSuffurd/GresSuffurd.sh b/legacy_bots/GresSuffurd/GresSuffurd.sh new file mode 100755 index 0000000..ed95d41 --- /dev/null +++ b/legacy_bots/GresSuffurd/GresSuffurd.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Legacy classic-Robocode robot hosted on Tank Royale by our own shim. +# Bootable by the official tankroyale booter (SERVER_URL/SERVER_SECRET come from +# the environment - this script never hardcodes a server address). +cd "$(dirname "$0")" +HERE="$(pwd)" +REPO="$(cd "$HERE/../.." && pwd)" + +export SHIM_BOT_CLASS="gh.GresSuffurd" +export SHIM_BOT_JAR="$HERE/GresSuffurd.jar" + +: "${SHIM_DATA:=${DRUSSGT_DATA:-$(mktemp -d "${TMPDIR:-/tmp}/tr_shim_data.XXXXXX")}}" +export SHIM_DATA + +: "${BOT_NAME:=GresSuffurd}" +export BOT_NAME +: "${BOT_VERSION:=0.4.18}" +export BOT_VERSION +: "${BOT_AUTHORS:=unknown}" +export BOT_AUTHORS +: "${BOT_DESCRIPTION:=Classic Robocode robot gh.GresSuffurd running on Tank Royale via the robocode_shim bridge}" +export BOT_DESCRIPTION +: "${BOT_HOMEPAGE:=}" +export BOT_HOMEPAGE +: "${BOT_COUNTRY_CODES:=se}" +export BOT_COUNTRY_CODES +: "${BOT_GAME_TYPES:=classic,1v1}" +export BOT_GAME_TYPES +: "${BOT_PLATFORM:=JVM}" +export BOT_PLATFORM +: "${BOT_PROG_LANG:=Java 8}" +export BOT_PROG_LANG + +exec java -cp "$REPO/tools/robocode_shim/out:$REPO/tools/robocode_shim/vendor/robocode.jar:$REPO/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar" robocode_shim.LegacyBotBridge diff --git a/legacy_bots/HawkOnFire/HawkOnFire.jar b/legacy_bots/HawkOnFire/HawkOnFire.jar new file mode 100644 index 0000000..9131b3e Binary files /dev/null and b/legacy_bots/HawkOnFire/HawkOnFire.jar differ diff --git a/legacy_bots/HawkOnFire/HawkOnFire.json b/legacy_bots/HawkOnFire/HawkOnFire.json new file mode 100644 index 0000000..f4edfef --- /dev/null +++ b/legacy_bots/HawkOnFire/HawkOnFire.json @@ -0,0 +1,11 @@ +{ + "name": "HawkOnFire", + "version": "0.1", + "authors": ["unknown"], + "description": "Classic Robocode robot rz.HawkOnFire running on Tank Royale via the robocode_shim bridge", + "homepage": "", + "countryCodes": ["se"], + "gameTypes": ["classic", "1v1"], + "platform": "JVM", + "programmingLang": "Java 8" +} diff --git a/legacy_bots/HawkOnFire/HawkOnFire.sh b/legacy_bots/HawkOnFire/HawkOnFire.sh new file mode 100755 index 0000000..387cf37 --- /dev/null +++ b/legacy_bots/HawkOnFire/HawkOnFire.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Legacy classic-Robocode robot hosted on Tank Royale by our own shim. +# Bootable by the official tankroyale booter (SERVER_URL/SERVER_SECRET come from +# the environment - this script never hardcodes a server address). +cd "$(dirname "$0")" +HERE="$(pwd)" +REPO="$(cd "$HERE/../.." && pwd)" + +export SHIM_BOT_CLASS="rz.HawkOnFire" +export SHIM_BOT_JAR="$HERE/HawkOnFire.jar" + +: "${SHIM_DATA:=${DRUSSGT_DATA:-$(mktemp -d "${TMPDIR:-/tmp}/tr_shim_data.XXXXXX")}}" +export SHIM_DATA + +: "${BOT_NAME:=HawkOnFire}" +export BOT_NAME +: "${BOT_VERSION:=0.1}" +export BOT_VERSION +: "${BOT_AUTHORS:=unknown}" +export BOT_AUTHORS +: "${BOT_DESCRIPTION:=Classic Robocode robot rz.HawkOnFire running on Tank Royale via the robocode_shim bridge}" +export BOT_DESCRIPTION +: "${BOT_HOMEPAGE:=}" +export BOT_HOMEPAGE +: "${BOT_COUNTRY_CODES:=se}" +export BOT_COUNTRY_CODES +: "${BOT_GAME_TYPES:=classic,1v1}" +export BOT_GAME_TYPES +: "${BOT_PLATFORM:=JVM}" +export BOT_PLATFORM +: "${BOT_PROG_LANG:=Java 8}" +export BOT_PROG_LANG + +exec java -cp "$REPO/tools/robocode_shim/out:$REPO/tools/robocode_shim/vendor/robocode.jar:$REPO/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar" robocode_shim.LegacyBotBridge diff --git a/legacy_bots/Jen/Jen.jar b/legacy_bots/Jen/Jen.jar new file mode 100644 index 0000000..cbb9843 Binary files /dev/null and b/legacy_bots/Jen/Jen.jar differ diff --git a/legacy_bots/Jen/Jen.json b/legacy_bots/Jen/Jen.json new file mode 100644 index 0000000..45c2e4f --- /dev/null +++ b/legacy_bots/Jen/Jen.json @@ -0,0 +1,11 @@ +{ + "name": "Jen", + "version": "1.092", + "authors": ["unknown"], + "description": "Classic Robocode robot voidious.micro.Jen running on Tank Royale via the robocode_shim bridge", + "homepage": "", + "countryCodes": ["se"], + "gameTypes": ["classic", "1v1"], + "platform": "JVM", + "programmingLang": "Java 8" +} diff --git a/legacy_bots/Jen/Jen.sh b/legacy_bots/Jen/Jen.sh new file mode 100755 index 0000000..3456f18 --- /dev/null +++ b/legacy_bots/Jen/Jen.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Legacy classic-Robocode robot hosted on Tank Royale by our own shim. +# Bootable by the official tankroyale booter (SERVER_URL/SERVER_SECRET come from +# the environment - this script never hardcodes a server address). +cd "$(dirname "$0")" +HERE="$(pwd)" +REPO="$(cd "$HERE/../.." && pwd)" + +export SHIM_BOT_CLASS="voidious.micro.Jen" +export SHIM_BOT_JAR="$HERE/Jen.jar" + +: "${SHIM_DATA:=${DRUSSGT_DATA:-$(mktemp -d "${TMPDIR:-/tmp}/tr_shim_data.XXXXXX")}}" +export SHIM_DATA + +: "${BOT_NAME:=Jen}" +export BOT_NAME +: "${BOT_VERSION:=1.092}" +export BOT_VERSION +: "${BOT_AUTHORS:=unknown}" +export BOT_AUTHORS +: "${BOT_DESCRIPTION:=Classic Robocode robot voidious.micro.Jen running on Tank Royale via the robocode_shim bridge}" +export BOT_DESCRIPTION +: "${BOT_HOMEPAGE:=}" +export BOT_HOMEPAGE +: "${BOT_COUNTRY_CODES:=se}" +export BOT_COUNTRY_CODES +: "${BOT_GAME_TYPES:=classic,1v1}" +export BOT_GAME_TYPES +: "${BOT_PLATFORM:=JVM}" +export BOT_PLATFORM +: "${BOT_PROG_LANG:=Java 8}" +export BOT_PROG_LANG + +exec java -cp "$REPO/tools/robocode_shim/out:$REPO/tools/robocode_shim/vendor/robocode.jar:$REPO/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar" robocode_shim.LegacyBotBridge diff --git a/legacy_bots/Komarious/Komarious.jar b/legacy_bots/Komarious/Komarious.jar new file mode 100644 index 0000000..d1bfa63 Binary files /dev/null and b/legacy_bots/Komarious/Komarious.jar differ diff --git a/legacy_bots/Komarious/Komarious.json b/legacy_bots/Komarious/Komarious.json new file mode 100644 index 0000000..62fc38b --- /dev/null +++ b/legacy_bots/Komarious/Komarious.json @@ -0,0 +1,11 @@ +{ + "name": "Komarious", + "version": "1.88", + "authors": ["unknown"], + "description": "Classic Robocode robot voidious.mini.Komarious running on Tank Royale via the robocode_shim bridge", + "homepage": "", + "countryCodes": ["se"], + "gameTypes": ["classic", "1v1"], + "platform": "JVM", + "programmingLang": "Java 8" +} diff --git a/legacy_bots/Komarious/Komarious.sh b/legacy_bots/Komarious/Komarious.sh new file mode 100755 index 0000000..41d8d93 --- /dev/null +++ b/legacy_bots/Komarious/Komarious.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Legacy classic-Robocode robot hosted on Tank Royale by our own shim. +# Bootable by the official tankroyale booter (SERVER_URL/SERVER_SECRET come from +# the environment - this script never hardcodes a server address). +cd "$(dirname "$0")" +HERE="$(pwd)" +REPO="$(cd "$HERE/../.." && pwd)" + +export SHIM_BOT_CLASS="voidious.mini.Komarious" +export SHIM_BOT_JAR="$HERE/Komarious.jar" + +: "${SHIM_DATA:=${DRUSSGT_DATA:-$(mktemp -d "${TMPDIR:-/tmp}/tr_shim_data.XXXXXX")}}" +export SHIM_DATA + +: "${BOT_NAME:=Komarious}" +export BOT_NAME +: "${BOT_VERSION:=1.88}" +export BOT_VERSION +: "${BOT_AUTHORS:=unknown}" +export BOT_AUTHORS +: "${BOT_DESCRIPTION:=Classic Robocode robot voidious.mini.Komarious running on Tank Royale via the robocode_shim bridge}" +export BOT_DESCRIPTION +: "${BOT_HOMEPAGE:=}" +export BOT_HOMEPAGE +: "${BOT_COUNTRY_CODES:=se}" +export BOT_COUNTRY_CODES +: "${BOT_GAME_TYPES:=classic,1v1}" +export BOT_GAME_TYPES +: "${BOT_PLATFORM:=JVM}" +export BOT_PLATFORM +: "${BOT_PROG_LANG:=Java 8}" +export BOT_PROG_LANG + +exec java -cp "$REPO/tools/robocode_shim/out:$REPO/tools/robocode_shim/vendor/robocode.jar:$REPO/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar" robocode_shim.LegacyBotBridge diff --git a/legacy_bots/KurtWaveSurfer/KurtWaveSurfer.jar b/legacy_bots/KurtWaveSurfer/KurtWaveSurfer.jar new file mode 100644 index 0000000..199d2b4 Binary files /dev/null and b/legacy_bots/KurtWaveSurfer/KurtWaveSurfer.jar differ diff --git a/legacy_bots/KurtWaveSurfer/KurtWaveSurfer.json b/legacy_bots/KurtWaveSurfer/KurtWaveSurfer.json new file mode 100644 index 0000000..8486b4c --- /dev/null +++ b/legacy_bots/KurtWaveSurfer/KurtWaveSurfer.json @@ -0,0 +1,11 @@ +{ + "name": "KurtWaveSurfer", + "version": "1.6", + "authors": ["unknown"], + "description": "Classic Robocode robot kurt.robot.KurtWaveSurfer running on Tank Royale via the robocode_shim bridge", + "homepage": "", + "countryCodes": ["se"], + "gameTypes": ["classic", "1v1"], + "platform": "JVM", + "programmingLang": "Java 8" +} diff --git a/legacy_bots/KurtWaveSurfer/KurtWaveSurfer.sh b/legacy_bots/KurtWaveSurfer/KurtWaveSurfer.sh new file mode 100755 index 0000000..06fa7bd --- /dev/null +++ b/legacy_bots/KurtWaveSurfer/KurtWaveSurfer.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Legacy classic-Robocode robot hosted on Tank Royale by our own shim. +# Bootable by the official tankroyale booter (SERVER_URL/SERVER_SECRET come from +# the environment - this script never hardcodes a server address). +cd "$(dirname "$0")" +HERE="$(pwd)" +REPO="$(cd "$HERE/../.." && pwd)" + +export SHIM_BOT_CLASS="kurt.robot.KurtWaveSurfer" +export SHIM_BOT_JAR="$HERE/KurtWaveSurfer.jar" + +: "${SHIM_DATA:=${DRUSSGT_DATA:-$(mktemp -d "${TMPDIR:-/tmp}/tr_shim_data.XXXXXX")}}" +export SHIM_DATA + +: "${BOT_NAME:=KurtWaveSurfer}" +export BOT_NAME +: "${BOT_VERSION:=1.6}" +export BOT_VERSION +: "${BOT_AUTHORS:=unknown}" +export BOT_AUTHORS +: "${BOT_DESCRIPTION:=Classic Robocode robot kurt.robot.KurtWaveSurfer running on Tank Royale via the robocode_shim bridge}" +export BOT_DESCRIPTION +: "${BOT_HOMEPAGE:=}" +export BOT_HOMEPAGE +: "${BOT_COUNTRY_CODES:=se}" +export BOT_COUNTRY_CODES +: "${BOT_GAME_TYPES:=classic,1v1}" +export BOT_GAME_TYPES +: "${BOT_PLATFORM:=JVM}" +export BOT_PLATFORM +: "${BOT_PROG_LANG:=Java 8}" +export BOT_PROG_LANG + +exec java -cp "$REPO/tools/robocode_shim/out:$REPO/tools/robocode_shim/vendor/robocode.jar:$REPO/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar" robocode_shim.LegacyBotBridge diff --git a/legacy_bots/LionWWSVMvoid/LionWWSVMvoid.jar b/legacy_bots/LionWWSVMvoid/LionWWSVMvoid.jar new file mode 100644 index 0000000..8a48561 Binary files /dev/null and b/legacy_bots/LionWWSVMvoid/LionWWSVMvoid.jar differ diff --git a/legacy_bots/LionWWSVMvoid/LionWWSVMvoid.json b/legacy_bots/LionWWSVMvoid/LionWWSVMvoid.json new file mode 100644 index 0000000..e41b17e --- /dev/null +++ b/legacy_bots/LionWWSVMvoid/LionWWSVMvoid.json @@ -0,0 +1,11 @@ +{ + "name": "LionWWSVMvoid", + "version": "0.01", + "authors": ["unknown"], + "description": "Classic Robocode robot sqTank.waveSurfing.LionWWSVMvoid running on Tank Royale via the robocode_shim bridge", + "homepage": "", + "countryCodes": ["se"], + "gameTypes": ["classic", "1v1"], + "platform": "JVM", + "programmingLang": "Java 8" +} diff --git a/legacy_bots/LionWWSVMvoid/LionWWSVMvoid.sh b/legacy_bots/LionWWSVMvoid/LionWWSVMvoid.sh new file mode 100755 index 0000000..411e67b --- /dev/null +++ b/legacy_bots/LionWWSVMvoid/LionWWSVMvoid.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Legacy classic-Robocode robot hosted on Tank Royale by our own shim. +# Bootable by the official tankroyale booter (SERVER_URL/SERVER_SECRET come from +# the environment - this script never hardcodes a server address). +cd "$(dirname "$0")" +HERE="$(pwd)" +REPO="$(cd "$HERE/../.." && pwd)" + +export SHIM_BOT_CLASS="sqTank.waveSurfing.LionWWSVMvoid" +export SHIM_BOT_JAR="$HERE/LionWWSVMvoid.jar" + +: "${SHIM_DATA:=${DRUSSGT_DATA:-$(mktemp -d "${TMPDIR:-/tmp}/tr_shim_data.XXXXXX")}}" +export SHIM_DATA + +: "${BOT_NAME:=LionWWSVMvoid}" +export BOT_NAME +: "${BOT_VERSION:=0.01}" +export BOT_VERSION +: "${BOT_AUTHORS:=unknown}" +export BOT_AUTHORS +: "${BOT_DESCRIPTION:=Classic Robocode robot sqTank.waveSurfing.LionWWSVMvoid running on Tank Royale via the robocode_shim bridge}" +export BOT_DESCRIPTION +: "${BOT_HOMEPAGE:=}" +export BOT_HOMEPAGE +: "${BOT_COUNTRY_CODES:=se}" +export BOT_COUNTRY_CODES +: "${BOT_GAME_TYPES:=classic,1v1}" +export BOT_GAME_TYPES +: "${BOT_PLATFORM:=JVM}" +export BOT_PLATFORM +: "${BOT_PROG_LANG:=Java 8}" +export BOT_PROG_LANG + +exec java -cp "$REPO/tools/robocode_shim/out:$REPO/tools/robocode_shim/vendor/robocode.jar:$REPO/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar" robocode_shim.LegacyBotBridge diff --git a/legacy_bots/Lukious/Lukious.jar b/legacy_bots/Lukious/Lukious.jar new file mode 100644 index 0000000..117eabd Binary files /dev/null and b/legacy_bots/Lukious/Lukious.jar differ diff --git a/legacy_bots/Lukious/Lukious.json b/legacy_bots/Lukious/Lukious.json new file mode 100644 index 0000000..f315cfb --- /dev/null +++ b/legacy_bots/Lukious/Lukious.json @@ -0,0 +1,11 @@ +{ + "name": "Lukious", + "version": "1.321", + "authors": ["unknown"], + "description": "Classic Robocode robot voidious.Lukious running on Tank Royale via the robocode_shim bridge", + "homepage": "", + "countryCodes": ["se"], + "gameTypes": ["classic", "1v1"], + "platform": "JVM", + "programmingLang": "Java 8" +} diff --git a/legacy_bots/Lukious/Lukious.sh b/legacy_bots/Lukious/Lukious.sh new file mode 100755 index 0000000..8103bc4 --- /dev/null +++ b/legacy_bots/Lukious/Lukious.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Legacy classic-Robocode robot hosted on Tank Royale by our own shim. +# Bootable by the official tankroyale booter (SERVER_URL/SERVER_SECRET come from +# the environment - this script never hardcodes a server address). +cd "$(dirname "$0")" +HERE="$(pwd)" +REPO="$(cd "$HERE/../.." && pwd)" + +export SHIM_BOT_CLASS="voidious.Lukious" +export SHIM_BOT_JAR="$HERE/Lukious.jar" + +: "${SHIM_DATA:=${DRUSSGT_DATA:-$(mktemp -d "${TMPDIR:-/tmp}/tr_shim_data.XXXXXX")}}" +export SHIM_DATA + +: "${BOT_NAME:=Lukious}" +export BOT_NAME +: "${BOT_VERSION:=1.321}" +export BOT_VERSION +: "${BOT_AUTHORS:=unknown}" +export BOT_AUTHORS +: "${BOT_DESCRIPTION:=Classic Robocode robot voidious.Lukious running on Tank Royale via the robocode_shim bridge}" +export BOT_DESCRIPTION +: "${BOT_HOMEPAGE:=}" +export BOT_HOMEPAGE +: "${BOT_COUNTRY_CODES:=se}" +export BOT_COUNTRY_CODES +: "${BOT_GAME_TYPES:=classic,1v1}" +export BOT_GAME_TYPES +: "${BOT_PLATFORM:=JVM}" +export BOT_PLATFORM +: "${BOT_PROG_LANG:=Java 8}" +export BOT_PROG_LANG + +exec java -cp "$REPO/tools/robocode_shim/out:$REPO/tools/robocode_shim/vendor/robocode.jar:$REPO/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar" robocode_shim.LegacyBotBridge diff --git a/legacy_bots/MANIFEST.sha256 b/legacy_bots/MANIFEST.sha256 new file mode 100644 index 0000000..cfa6183 --- /dev/null +++ b/legacy_bots/MANIFEST.sha256 @@ -0,0 +1,30 @@ +# sha256 of every legacy bot jar committed under legacy_bots/ +# verify: cd legacy_bots && sha256sum -c MANIFEST.sha256 +00cba8a7df53e234aee4a9531bebd5f96dffc5488f6e733f877ce513b5d32d7f DiamondHawk/DiamondHawk.jar +17d56b87bb68ff840ccda8a4a407b8fcfe5f23b8be5aa7d7a98b61a01138ef6e Shadow/Shadow.jar +1ab39d66041eaf4edf5c073d8caa7c61ff5e783961adfad03914f14017d048ea Diamond/Diamond.jar +20ba2d6f93c8970145b2186b79f4e5171a90a8048dcda2baa82fc98ba211d943 GresSuffurd/GresSuffurd.jar +230ecca59b61889bac4239a8c0a25c571bc72698477001cb93759a3832a585ac BlitzBat/BlitzBat.jar +273c4194d1b9f0687173158276802ff3456ec8343de62e80d2674e0960715612 Cigaret/Cigaret.jar +2a0068f2d9b683646a1148654274f4132cf4ecf1c9432823e389a2fdb50b4d65 BrokenSword/BrokenSword.jar +2aee27ddd085c75f61943240e090e018c9e69f658cd4afed508430910a41d2ab RougeDC/RougeDC.jar +2e4e94b5061bd287d758b0dcc03734a6a5cb432b077d2b296f9641682bad4d96 Dookious/Dookious.jar +39d3b37cc9e7a9a2f244efcc526d756846e66a619730e75beb24cdce70194b5f Coriantumr/Coriantumr.jar +57f7348becec43c111d2e126240b30b5fdb8bc597ff18104df1cf07d67aaee5c DiamondStealer/DiamondStealer.jar +66705bfbd6daa2b1f7470e9e17846a238b752fc3829227ddc7e67612c33117ff Ascendant/Ascendant.jar +79884ef9a9613ab04d92fa6a9cce64d2cdf38c7ec347060e16e746bb8474df35 RetroGirl/RetroGirl.jar +8154cbe8645640447447d1f55bf5da0e9484b6b7d6507c87824f9ebe71952848 WaveSurferPG/WaveSurferPG.jar +89b46a3c5cd14c05e6ec5f59ab189852178cd2d774313ac2e0a2b3971ec0fb37 Phoenix/Phoenix.jar +8c107a759b229f8570dcce96ccedd8404545e7d3c6441a206c64d54a4209d678 CigaretBH/CigaretBH.jar +946cd4238f72e7e51473b610d21182cdbdba4513dd6bebc38064e9ed1bb601d1 YersiniaPestis/YersiniaPestis.jar +9bf0946f16256650455217df27183b8f3a5715954ab37c58b64e327af26d4593 Komarious/Komarious.jar +a001c2404157bab122e0dbe312e33e79322ce0ddae55d9ab660def1c80bff7a6 LionWWSVMvoid/LionWWSVMvoid.jar +a6773101852b9fb415845770eb94435e7b3c34c493dba0b964a4235903601e8b TripHammer/TripHammer.jar +aa149f2d63a26aa3a601bf8d76fd7e10cee78a3731908a0aa3ba58c3db54c3c4 WaveSurferGF/WaveSurferGF.jar +be89fcf05353666ee404daa00dc092c918c2fcd1bfdbdf5f4b55b1f5b766f248 PatternRobot/PatternRobot.jar +dd2e9473a7a1ab2287b6e7fee097a23ea2c951ab525393b60e20ab6b5b37c791 KurtWaveSurfer/KurtWaveSurfer.jar +e3371b1bf776fc64773d8eef6278284be15a6ceff248e36603d64163a2d043dc Lukious/Lukious.jar +e3ed9189afd9a2567167399ff04f49a7f184a07967815a947f3e25d91ffdf4d4 HawkOnFire/HawkOnFire.jar +eb5e2baa4039bcb1a35123d3503ddb23c3b12915ae41fe2a6199d1b1b678e99b WallAvoider/WallAvoider.jar +f8630c113fa6cbb5e4f3bfe6c8dc46cf409a24454146fce48d561fbed1d9f3b2 Jen/Jen.jar +ff3b9734226c33bc78ffdbef6004c9926f1bc70e3914d79fd129b4c0bfa8ade5 CassiusClay/CassiusClay.jar diff --git a/legacy_bots/PatternRobot/PatternRobot.jar b/legacy_bots/PatternRobot/PatternRobot.jar new file mode 100644 index 0000000..1ae3b20 Binary files /dev/null and b/legacy_bots/PatternRobot/PatternRobot.jar differ diff --git a/legacy_bots/PatternRobot/PatternRobot.json b/legacy_bots/PatternRobot/PatternRobot.json new file mode 100644 index 0000000..75cf0cc --- /dev/null +++ b/legacy_bots/PatternRobot/PatternRobot.json @@ -0,0 +1,11 @@ +{ + "name": "PatternRobot", + "version": "1.0", + "authors": ["unknown"], + "description": "Classic Robocode robot stelo.PatternRobot running on Tank Royale via the robocode_shim bridge", + "homepage": "", + "countryCodes": ["se"], + "gameTypes": ["classic", "1v1"], + "platform": "JVM", + "programmingLang": "Java 8" +} diff --git a/legacy_bots/PatternRobot/PatternRobot.sh b/legacy_bots/PatternRobot/PatternRobot.sh new file mode 100755 index 0000000..36bd5ba --- /dev/null +++ b/legacy_bots/PatternRobot/PatternRobot.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Legacy classic-Robocode robot hosted on Tank Royale by our own shim. +# Bootable by the official tankroyale booter (SERVER_URL/SERVER_SECRET come from +# the environment - this script never hardcodes a server address). +cd "$(dirname "$0")" +HERE="$(pwd)" +REPO="$(cd "$HERE/../.." && pwd)" + +export SHIM_BOT_CLASS="stelo.PatternRobot" +export SHIM_BOT_JAR="$HERE/PatternRobot.jar" + +: "${SHIM_DATA:=${DRUSSGT_DATA:-$(mktemp -d "${TMPDIR:-/tmp}/tr_shim_data.XXXXXX")}}" +export SHIM_DATA + +: "${BOT_NAME:=PatternRobot}" +export BOT_NAME +: "${BOT_VERSION:=1.0}" +export BOT_VERSION +: "${BOT_AUTHORS:=unknown}" +export BOT_AUTHORS +: "${BOT_DESCRIPTION:=Classic Robocode robot stelo.PatternRobot running on Tank Royale via the robocode_shim bridge}" +export BOT_DESCRIPTION +: "${BOT_HOMEPAGE:=}" +export BOT_HOMEPAGE +: "${BOT_COUNTRY_CODES:=se}" +export BOT_COUNTRY_CODES +: "${BOT_GAME_TYPES:=classic,1v1}" +export BOT_GAME_TYPES +: "${BOT_PLATFORM:=JVM}" +export BOT_PLATFORM +: "${BOT_PROG_LANG:=Java 8}" +export BOT_PROG_LANG + +exec java -cp "$REPO/tools/robocode_shim/out:$REPO/tools/robocode_shim/vendor/robocode.jar:$REPO/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar" robocode_shim.LegacyBotBridge diff --git a/legacy_bots/Phoenix/Phoenix.jar b/legacy_bots/Phoenix/Phoenix.jar new file mode 100644 index 0000000..1d98f38 Binary files /dev/null and b/legacy_bots/Phoenix/Phoenix.jar differ diff --git a/legacy_bots/Phoenix/Phoenix.json b/legacy_bots/Phoenix/Phoenix.json new file mode 100644 index 0000000..f47e970 --- /dev/null +++ b/legacy_bots/Phoenix/Phoenix.json @@ -0,0 +1,11 @@ +{ + "name": "Phoenix", + "version": "1.02", + "authors": ["unknown"], + "description": "Classic Robocode robot davidalves.Phoenix running on Tank Royale via the robocode_shim bridge", + "homepage": "", + "countryCodes": ["se"], + "gameTypes": ["classic", "1v1"], + "platform": "JVM", + "programmingLang": "Java 8" +} diff --git a/legacy_bots/Phoenix/Phoenix.sh b/legacy_bots/Phoenix/Phoenix.sh new file mode 100755 index 0000000..23f9cc8 --- /dev/null +++ b/legacy_bots/Phoenix/Phoenix.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Legacy classic-Robocode robot hosted on Tank Royale by our own shim. +# Bootable by the official tankroyale booter (SERVER_URL/SERVER_SECRET come from +# the environment - this script never hardcodes a server address). +cd "$(dirname "$0")" +HERE="$(pwd)" +REPO="$(cd "$HERE/../.." && pwd)" + +export SHIM_BOT_CLASS="davidalves.Phoenix" +export SHIM_BOT_JAR="$HERE/Phoenix.jar" + +: "${SHIM_DATA:=${DRUSSGT_DATA:-$(mktemp -d "${TMPDIR:-/tmp}/tr_shim_data.XXXXXX")}}" +export SHIM_DATA + +: "${BOT_NAME:=Phoenix}" +export BOT_NAME +: "${BOT_VERSION:=1.02}" +export BOT_VERSION +: "${BOT_AUTHORS:=unknown}" +export BOT_AUTHORS +: "${BOT_DESCRIPTION:=Classic Robocode robot davidalves.Phoenix running on Tank Royale via the robocode_shim bridge}" +export BOT_DESCRIPTION +: "${BOT_HOMEPAGE:=}" +export BOT_HOMEPAGE +: "${BOT_COUNTRY_CODES:=se}" +export BOT_COUNTRY_CODES +: "${BOT_GAME_TYPES:=classic,1v1}" +export BOT_GAME_TYPES +: "${BOT_PLATFORM:=JVM}" +export BOT_PLATFORM +: "${BOT_PROG_LANG:=Java 8}" +export BOT_PROG_LANG + +exec java -cp "$REPO/tools/robocode_shim/out:$REPO/tools/robocode_shim/vendor/robocode.jar:$REPO/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar" robocode_shim.LegacyBotBridge diff --git a/legacy_bots/README.md b/legacy_bots/README.md new file mode 100644 index 0000000..bdd8e45 --- /dev/null +++ b/legacy_bots/README.md @@ -0,0 +1,159 @@ +# `legacy_bots/` — classic Robocode champions on Tank Royale + +One directory per legacy (Robocode 1.x) bot, each holding the third-party +`.jar`, a `.sh` launcher and a `.json` identity file. The jars +are **committed on purpose**: they are not reproducible from this repo, and an +over-broad `*.jar` ignore rule already cost us the only copy of `DrussGT.jar` +once. Checksums live in [`MANIFEST.sha256`](MANIFEST.sha256): + +```sh +cd legacy_bots && sha256sum -c MANIFEST.sha256 +``` + +Each directory satisfies the official tankroyale **booter** contract: every file +in the directory shares the same base filename, which equals the directory name. +The booter therefore resolves `.sh` and starts it; the jar is simply the +payload our own shim loads. `tools/robocode_shim/robots.json` is the +machine-readable manifest (main class, version, style, status, source URL, +license, sha256, evidence). + +## How a bot actually runs + +These are *classic* robots, not Tank Royale natives. Our own bridge, +`tools/robocode_shim/src/robocode_shim/LegacyBotBridge.java`, loads the jar, +instantiates the robot class, and synthesises the classic `IPeer` on top of the +Tank Royale bot API. The booter is only a **process launcher** — it does not know +anything about Robocode, so the bridge stays ours. The two are complementary. + +`.sh` never hardcodes a server address. `SERVER_URL` / `SERVER_SECRET` are +read from the environment (the booter supplies them from its own `-Dserver.url` +/ `-Dserver.secret`), and the Tank Royale bot API picks them up from there. + +## Roster + +### Kept — `status: WORKS` (fire and move, 2-round battles via the shim) + +Ascendant, BlitzBat, BrokenSword, CassiusClay, Cigaret, CigaretBH, Coriantumr, +Diamond, DiamondHawk, DiamondStealer, Dookious, GresSuffurd, HawkOnFire, Jen, +Komarious, LionWWSVMvoid, Lukious, Phoenix, RetroGirl, RougeDC, Shadow, +TripHammer, WallAvoider, WaveSurferGF, WaveSurferPG, YersiniaPestis. + +### Kept but weak — `status: WORKS_WEAK` + +| Bot | Why | +|---|---| +| `PatternRobot` | fires (8 shots) but barely moves | +| `KurtWaveSurfer` | fires a lot and lands real hits (104 shots / 30 hits) but only moves on 265 of 1755 ticks — kept, flagged | + +### Removed — `status: NOT_USEFUL` (no entry in `legacy_bots/`, no entry in `robots.json`) + +Six candidates were downloaded, measured and then **dropped**: jars deleted from +`tr_bots/_salvage/legacy_bots/`, wrapper dirs deleted from +`tr_bots/_salvage/tr_wrappers/`. They are recorded here so the decision is not +re-litigated every time someone redownloads the archive. + +| Bot | Measured | Reason | +|---|---|---| +| Nene | 0 shots | melee, inert: implements `IBasicRobot` directly, `getRobotRunnable()` returns null — the shim has no driver for it | +| Seraphim | 0 shots | same Azuma-framework blocker as Nene | +| Aurora | 0 shots, crawls | nothing to work with | +| FloodMini | 25 shots, 0 hits, 10 hits taken | near-stationary turret | +| LightningBug | 36 shots, 0 hits, 10 hits taken | near-stationary turret | +| Aristocles | 39 shots, 0 hits, 10 hits taken | near-stationary turret | + +Nene/Seraphim would need a second driver path in the shim (an Azuma-framework +adapter) before they are worth resurrecting. The other three fire but never +move, so they are dead weight as sparring partners. + +Dropping the six inert bots from the tree leaves **28** directories; the +2-round survey that fed the drop list counted 26 bots that both fired *and* +moved, because `PatternRobot` and `KurtWaveSurfer` fire but are weak movers — +they are kept here as `WORKS_WEAK` rather than dropped. + +### DrussGT + +**Not duplicated here.** DrussGT is the reference bot, it has decompiled sources +in the repo, and its jar is already vendored at +`tools/robocode_shim/vendor/drussgt/DrussGT.jar` with its bot directory in +`tr_bots/DrussGT`. Copying it here would create a second copy to keep in sync. + +## Running a battle + +```sh +# subject = any bot in this tree, adversary = a Tank Royale bot dir +SHIM_BOTDIR=$PWD/legacy_bots/Diamond tools/robocode_shim/run_bridge_battle.sh \ + /home/davide/Projects/tank-royale/sample-bots/java/build/archive/SpinBot 2 +``` + +```sh +# offline triage, no server (~2 s, has known false negatives) +SHIM_BOT_JAR=$PWD/legacy_bots/Diamond/Diamond.jar SHIM_BOT_CLASS=voidious.Diamond \ + tools/robocode_shim/run_smoke.sh +``` + +## Using the official booter + +```sh +BOOTER=/home/davide/Projects/tank-royale/booter/build/libs/robocode-tankroyale-booter-0.35.5.jar + +java -jar "$BOOTER" dir legacy_bots # list directories +java -jar "$BOOTER" info legacy_bots/Diamond +java -Dserver.url=... -Dserver.secret=... -jar "$BOOTER" boot legacy_bots/Diamond legacy_bots/Dookious +``` + +`boot` reads `quit` / `boot {dir}` / `stop {pid}` on stdin and prints +`{pid};{dir}` / `stopped {pid}` / `lost {pid}`. Note the real subcommand is +`boot`, not `run` (some READMEs say otherwise). + +Two booter quirks, both verified here: + +* **Pass absolute bot directories.** The booter `cd`s into the bot directory and + then runs the script by the path you gave it, so a relative path like + `legacy_bots/Diamond` resolves to `legacy_bots/Diamond/legacy_bots/Diamond/…`. +* **`boot` exits — and kills every bot — on stdin EOF.** Pipe something into it + (`sleep 30 | java -jar booter.jar boot …`) or it quits immediately. + +`.sh` deliberately does *not* overwrite `BOT_*` when they are already set, +so booter/GUI-provided identity (including `BOT_GAME_TYPES`, which the booter +emits as `"classic, 1v1"` with a space) wins over the `.json` defaults. + +### Recording a battle of two legacy bots + +```sh +cd tools/raw_recorder +JAR=/home/davide/Projects/tank-royale/runner/examples/lib/robocode-tankroyale-runner.jar +mkdir -p /tmp/rawrec_lb # the recording dir must exist first +java -cp "shadow-classes:out:$JAR" RawRecord --dir /tmp/rawrec_lb --rounds 2 \ + --bot ../../legacy_bots/Diamond --bot ../../legacy_bots/Dookious +python3 query.py /tmp/rawrec_lb/game-*.battle.gz --verify +``` + +## Licensing + +**Every `license` field in `robots.json` reads "not stated in jar (RoboRumble +archive distribution)".** No bot carries an explicit licence, so none of them is +known to be GPL, and none of them is known to be permissively licensed either. +The repo owner has **explicitly waived** this concern: the repository is PRIVATE +and lives on their own LAN, and the jars are committed so the tree is +self-contained and reproducible. Do not mirror or redistribute this repo without +revisiting that decision. + +## Adding a new bot + +1. `curl` the jar from `http://robocode-archive.strangeautomata.com/robots/` into + `legacy_bots//` (rename to `.jar` — the base-name rule). +2. `tools/robocode_shim/make_botdir.sh legacy_bots/ --class --jar ` + generates `.json` + `.sh`. +3. Prove it: one round of `run_bridge_battle.sh` against a real adversary. A bot + that does not fire *and* move is `NOT_USEFUL`. +4. Add an entry to `tools/robocode_shim/robots.json` (main_class, jar, botdir, + status, source_url, license, evidence) and re-run `sha256sum` into + `MANIFEST.sha256`. + +## `portaudit/` + +`tr_bots/_salvage/portaudit/{methods.py,static.py}` were one-off static +analyses of a decompiled source tree under `/tmp/portaudit/src` that no longer +exists. They are **not** migrated: dead scripts with no live input. The shim +itself records what it still needs in `tools/robocode_shim/LEGACY_BOTS.md` +("Missing-API summary"). diff --git a/legacy_bots/RetroGirl/RetroGirl.jar b/legacy_bots/RetroGirl/RetroGirl.jar new file mode 100644 index 0000000..25739c8 Binary files /dev/null and b/legacy_bots/RetroGirl/RetroGirl.jar differ diff --git a/legacy_bots/RetroGirl/RetroGirl.json b/legacy_bots/RetroGirl/RetroGirl.json new file mode 100644 index 0000000..cdf77e7 --- /dev/null +++ b/legacy_bots/RetroGirl/RetroGirl.json @@ -0,0 +1,11 @@ +{ + "name": "RetroGirl", + "version": "1.0.0", + "authors": ["unknown"], + "description": "Classic Robocode robot voidious.perceptual.RetroGirl running on Tank Royale via the robocode_shim bridge", + "homepage": "", + "countryCodes": ["se"], + "gameTypes": ["classic", "1v1"], + "platform": "JVM", + "programmingLang": "Java 8" +} diff --git a/legacy_bots/RetroGirl/RetroGirl.sh b/legacy_bots/RetroGirl/RetroGirl.sh new file mode 100755 index 0000000..dd07ad2 --- /dev/null +++ b/legacy_bots/RetroGirl/RetroGirl.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Legacy classic-Robocode robot hosted on Tank Royale by our own shim. +# Bootable by the official tankroyale booter (SERVER_URL/SERVER_SECRET come from +# the environment - this script never hardcodes a server address). +cd "$(dirname "$0")" +HERE="$(pwd)" +REPO="$(cd "$HERE/../.." && pwd)" + +export SHIM_BOT_CLASS="voidious.perceptual.RetroGirl" +export SHIM_BOT_JAR="$HERE/RetroGirl.jar" + +: "${SHIM_DATA:=${DRUSSGT_DATA:-$(mktemp -d "${TMPDIR:-/tmp}/tr_shim_data.XXXXXX")}}" +export SHIM_DATA + +: "${BOT_NAME:=RetroGirl}" +export BOT_NAME +: "${BOT_VERSION:=1.0.0}" +export BOT_VERSION +: "${BOT_AUTHORS:=unknown}" +export BOT_AUTHORS +: "${BOT_DESCRIPTION:=Classic Robocode robot voidious.perceptual.RetroGirl running on Tank Royale via the robocode_shim bridge}" +export BOT_DESCRIPTION +: "${BOT_HOMEPAGE:=}" +export BOT_HOMEPAGE +: "${BOT_COUNTRY_CODES:=se}" +export BOT_COUNTRY_CODES +: "${BOT_GAME_TYPES:=classic,1v1}" +export BOT_GAME_TYPES +: "${BOT_PLATFORM:=JVM}" +export BOT_PLATFORM +: "${BOT_PROG_LANG:=Java 8}" +export BOT_PROG_LANG + +exec java -cp "$REPO/tools/robocode_shim/out:$REPO/tools/robocode_shim/vendor/robocode.jar:$REPO/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar" robocode_shim.LegacyBotBridge diff --git a/legacy_bots/RougeDC/RougeDC.jar b/legacy_bots/RougeDC/RougeDC.jar new file mode 100644 index 0000000..6f43778 Binary files /dev/null and b/legacy_bots/RougeDC/RougeDC.jar differ diff --git a/legacy_bots/RougeDC/RougeDC.json b/legacy_bots/RougeDC/RougeDC.json new file mode 100644 index 0000000..e8367d7 --- /dev/null +++ b/legacy_bots/RougeDC/RougeDC.json @@ -0,0 +1,11 @@ +{ + "name": "RougeDC", + "version": "willow", + "authors": ["unknown"], + "description": "Classic Robocode robot ags.rougedc.RougeDC running on Tank Royale via the robocode_shim bridge", + "homepage": "", + "countryCodes": ["se"], + "gameTypes": ["classic", "1v1"], + "platform": "JVM", + "programmingLang": "Java 8" +} diff --git a/legacy_bots/RougeDC/RougeDC.sh b/legacy_bots/RougeDC/RougeDC.sh new file mode 100755 index 0000000..6586bd7 --- /dev/null +++ b/legacy_bots/RougeDC/RougeDC.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Legacy classic-Robocode robot hosted on Tank Royale by our own shim. +# Bootable by the official tankroyale booter (SERVER_URL/SERVER_SECRET come from +# the environment - this script never hardcodes a server address). +cd "$(dirname "$0")" +HERE="$(pwd)" +REPO="$(cd "$HERE/../.." && pwd)" + +export SHIM_BOT_CLASS="ags.rougedc.RougeDC" +export SHIM_BOT_JAR="$HERE/RougeDC.jar" + +: "${SHIM_DATA:=${DRUSSGT_DATA:-$(mktemp -d "${TMPDIR:-/tmp}/tr_shim_data.XXXXXX")}}" +export SHIM_DATA + +: "${BOT_NAME:=RougeDC}" +export BOT_NAME +: "${BOT_VERSION:=willow}" +export BOT_VERSION +: "${BOT_AUTHORS:=unknown}" +export BOT_AUTHORS +: "${BOT_DESCRIPTION:=Classic Robocode robot ags.rougedc.RougeDC running on Tank Royale via the robocode_shim bridge}" +export BOT_DESCRIPTION +: "${BOT_HOMEPAGE:=}" +export BOT_HOMEPAGE +: "${BOT_COUNTRY_CODES:=se}" +export BOT_COUNTRY_CODES +: "${BOT_GAME_TYPES:=classic,1v1}" +export BOT_GAME_TYPES +: "${BOT_PLATFORM:=JVM}" +export BOT_PLATFORM +: "${BOT_PROG_LANG:=Java 8}" +export BOT_PROG_LANG + +exec java -cp "$REPO/tools/robocode_shim/out:$REPO/tools/robocode_shim/vendor/robocode.jar:$REPO/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar" robocode_shim.LegacyBotBridge diff --git a/legacy_bots/Shadow/Shadow.jar b/legacy_bots/Shadow/Shadow.jar new file mode 100644 index 0000000..d0aeaa7 Binary files /dev/null and b/legacy_bots/Shadow/Shadow.jar differ diff --git a/legacy_bots/Shadow/Shadow.json b/legacy_bots/Shadow/Shadow.json new file mode 100644 index 0000000..2835722 --- /dev/null +++ b/legacy_bots/Shadow/Shadow.json @@ -0,0 +1,11 @@ +{ + "name": "Shadow", + "version": "3.84i", + "authors": ["unknown"], + "description": "Classic Robocode robot abc.Shadow running on Tank Royale via the robocode_shim bridge", + "homepage": "", + "countryCodes": ["se"], + "gameTypes": ["classic", "1v1"], + "platform": "JVM", + "programmingLang": "Java 8" +} diff --git a/legacy_bots/Shadow/Shadow.sh b/legacy_bots/Shadow/Shadow.sh new file mode 100755 index 0000000..509e733 --- /dev/null +++ b/legacy_bots/Shadow/Shadow.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Legacy classic-Robocode robot hosted on Tank Royale by our own shim. +# Bootable by the official tankroyale booter (SERVER_URL/SERVER_SECRET come from +# the environment - this script never hardcodes a server address). +cd "$(dirname "$0")" +HERE="$(pwd)" +REPO="$(cd "$HERE/../.." && pwd)" + +export SHIM_BOT_CLASS="abc.Shadow" +export SHIM_BOT_JAR="$HERE/Shadow.jar" + +: "${SHIM_DATA:=${DRUSSGT_DATA:-$(mktemp -d "${TMPDIR:-/tmp}/tr_shim_data.XXXXXX")}}" +export SHIM_DATA + +: "${BOT_NAME:=Shadow}" +export BOT_NAME +: "${BOT_VERSION:=3.84i}" +export BOT_VERSION +: "${BOT_AUTHORS:=unknown}" +export BOT_AUTHORS +: "${BOT_DESCRIPTION:=Classic Robocode robot abc.Shadow running on Tank Royale via the robocode_shim bridge}" +export BOT_DESCRIPTION +: "${BOT_HOMEPAGE:=}" +export BOT_HOMEPAGE +: "${BOT_COUNTRY_CODES:=se}" +export BOT_COUNTRY_CODES +: "${BOT_GAME_TYPES:=classic,1v1}" +export BOT_GAME_TYPES +: "${BOT_PLATFORM:=JVM}" +export BOT_PLATFORM +: "${BOT_PROG_LANG:=Java 8}" +export BOT_PROG_LANG + +exec java -cp "$REPO/tools/robocode_shim/out:$REPO/tools/robocode_shim/vendor/robocode.jar:$REPO/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar" robocode_shim.LegacyBotBridge diff --git a/legacy_bots/TripHammer/TripHammer.jar b/legacy_bots/TripHammer/TripHammer.jar new file mode 100644 index 0000000..9f5b0a1 Binary files /dev/null and b/legacy_bots/TripHammer/TripHammer.jar differ diff --git a/legacy_bots/TripHammer/TripHammer.json b/legacy_bots/TripHammer/TripHammer.json new file mode 100644 index 0000000..e9e79ef --- /dev/null +++ b/legacy_bots/TripHammer/TripHammer.json @@ -0,0 +1,11 @@ +{ + "name": "TripHammer", + "version": "R2.1.0", + "authors": ["unknown"], + "description": "Classic Robocode robot voidious.TripHammer running on Tank Royale via the robocode_shim bridge", + "homepage": "", + "countryCodes": ["se"], + "gameTypes": ["classic", "1v1"], + "platform": "JVM", + "programmingLang": "Java 8" +} diff --git a/legacy_bots/TripHammer/TripHammer.sh b/legacy_bots/TripHammer/TripHammer.sh new file mode 100755 index 0000000..88022d7 --- /dev/null +++ b/legacy_bots/TripHammer/TripHammer.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Legacy classic-Robocode robot hosted on Tank Royale by our own shim. +# Bootable by the official tankroyale booter (SERVER_URL/SERVER_SECRET come from +# the environment - this script never hardcodes a server address). +cd "$(dirname "$0")" +HERE="$(pwd)" +REPO="$(cd "$HERE/../.." && pwd)" + +export SHIM_BOT_CLASS="voidious.TripHammer" +export SHIM_BOT_JAR="$HERE/TripHammer.jar" + +: "${SHIM_DATA:=${DRUSSGT_DATA:-$(mktemp -d "${TMPDIR:-/tmp}/tr_shim_data.XXXXXX")}}" +export SHIM_DATA + +: "${BOT_NAME:=TripHammer}" +export BOT_NAME +: "${BOT_VERSION:=R2.1.0}" +export BOT_VERSION +: "${BOT_AUTHORS:=unknown}" +export BOT_AUTHORS +: "${BOT_DESCRIPTION:=Classic Robocode robot voidious.TripHammer running on Tank Royale via the robocode_shim bridge}" +export BOT_DESCRIPTION +: "${BOT_HOMEPAGE:=}" +export BOT_HOMEPAGE +: "${BOT_COUNTRY_CODES:=se}" +export BOT_COUNTRY_CODES +: "${BOT_GAME_TYPES:=classic,1v1}" +export BOT_GAME_TYPES +: "${BOT_PLATFORM:=JVM}" +export BOT_PLATFORM +: "${BOT_PROG_LANG:=Java 8}" +export BOT_PROG_LANG + +exec java -cp "$REPO/tools/robocode_shim/out:$REPO/tools/robocode_shim/vendor/robocode.jar:$REPO/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar" robocode_shim.LegacyBotBridge diff --git a/legacy_bots/WallAvoider/WallAvoider.jar b/legacy_bots/WallAvoider/WallAvoider.jar new file mode 100644 index 0000000..7e016ea Binary files /dev/null and b/legacy_bots/WallAvoider/WallAvoider.jar differ diff --git a/legacy_bots/WallAvoider/WallAvoider.json b/legacy_bots/WallAvoider/WallAvoider.json new file mode 100644 index 0000000..a88f504 --- /dev/null +++ b/legacy_bots/WallAvoider/WallAvoider.json @@ -0,0 +1,11 @@ +{ + "name": "WallAvoider", + "version": "1.0", + "authors": ["unknown"], + "description": "Classic Robocode robot sp.Micros.WallAvoider running on Tank Royale via the robocode_shim bridge", + "homepage": "", + "countryCodes": ["se"], + "gameTypes": ["classic", "1v1"], + "platform": "JVM", + "programmingLang": "Java 8" +} diff --git a/legacy_bots/WallAvoider/WallAvoider.sh b/legacy_bots/WallAvoider/WallAvoider.sh new file mode 100755 index 0000000..5b32ee6 --- /dev/null +++ b/legacy_bots/WallAvoider/WallAvoider.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Legacy classic-Robocode robot hosted on Tank Royale by our own shim. +# Bootable by the official tankroyale booter (SERVER_URL/SERVER_SECRET come from +# the environment - this script never hardcodes a server address). +cd "$(dirname "$0")" +HERE="$(pwd)" +REPO="$(cd "$HERE/../.." && pwd)" + +export SHIM_BOT_CLASS="sp.Micros.WallAvoider" +export SHIM_BOT_JAR="$HERE/WallAvoider.jar" + +: "${SHIM_DATA:=${DRUSSGT_DATA:-$(mktemp -d "${TMPDIR:-/tmp}/tr_shim_data.XXXXXX")}}" +export SHIM_DATA + +: "${BOT_NAME:=WallAvoider}" +export BOT_NAME +: "${BOT_VERSION:=1.0}" +export BOT_VERSION +: "${BOT_AUTHORS:=unknown}" +export BOT_AUTHORS +: "${BOT_DESCRIPTION:=Classic Robocode robot sp.Micros.WallAvoider running on Tank Royale via the robocode_shim bridge}" +export BOT_DESCRIPTION +: "${BOT_HOMEPAGE:=}" +export BOT_HOMEPAGE +: "${BOT_COUNTRY_CODES:=se}" +export BOT_COUNTRY_CODES +: "${BOT_GAME_TYPES:=classic,1v1}" +export BOT_GAME_TYPES +: "${BOT_PLATFORM:=JVM}" +export BOT_PLATFORM +: "${BOT_PROG_LANG:=Java 8}" +export BOT_PROG_LANG + +exec java -cp "$REPO/tools/robocode_shim/out:$REPO/tools/robocode_shim/vendor/robocode.jar:$REPO/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar" robocode_shim.LegacyBotBridge diff --git a/legacy_bots/WaveSurferGF/WaveSurferGF.jar b/legacy_bots/WaveSurferGF/WaveSurferGF.jar new file mode 100644 index 0000000..b3617f4 Binary files /dev/null and b/legacy_bots/WaveSurferGF/WaveSurferGF.jar differ diff --git a/legacy_bots/WaveSurferGF/WaveSurferGF.json b/legacy_bots/WaveSurferGF/WaveSurferGF.json new file mode 100644 index 0000000..01f57a4 --- /dev/null +++ b/legacy_bots/WaveSurferGF/WaveSurferGF.json @@ -0,0 +1,11 @@ +{ + "name": "WaveSurferGF", + "version": "1.04", + "authors": ["unknown"], + "description": "Classic Robocode robot suh.mega.WaveSurferGF running on Tank Royale via the robocode_shim bridge", + "homepage": "", + "countryCodes": ["se"], + "gameTypes": ["classic", "1v1"], + "platform": "JVM", + "programmingLang": "Java 8" +} diff --git a/legacy_bots/WaveSurferGF/WaveSurferGF.sh b/legacy_bots/WaveSurferGF/WaveSurferGF.sh new file mode 100755 index 0000000..224e2a2 --- /dev/null +++ b/legacy_bots/WaveSurferGF/WaveSurferGF.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Legacy classic-Robocode robot hosted on Tank Royale by our own shim. +# Bootable by the official tankroyale booter (SERVER_URL/SERVER_SECRET come from +# the environment - this script never hardcodes a server address). +cd "$(dirname "$0")" +HERE="$(pwd)" +REPO="$(cd "$HERE/../.." && pwd)" + +export SHIM_BOT_CLASS="suh.mega.WaveSurferGF" +export SHIM_BOT_JAR="$HERE/WaveSurferGF.jar" + +: "${SHIM_DATA:=${DRUSSGT_DATA:-$(mktemp -d "${TMPDIR:-/tmp}/tr_shim_data.XXXXXX")}}" +export SHIM_DATA + +: "${BOT_NAME:=WaveSurferGF}" +export BOT_NAME +: "${BOT_VERSION:=1.04}" +export BOT_VERSION +: "${BOT_AUTHORS:=unknown}" +export BOT_AUTHORS +: "${BOT_DESCRIPTION:=Classic Robocode robot suh.mega.WaveSurferGF running on Tank Royale via the robocode_shim bridge}" +export BOT_DESCRIPTION +: "${BOT_HOMEPAGE:=}" +export BOT_HOMEPAGE +: "${BOT_COUNTRY_CODES:=se}" +export BOT_COUNTRY_CODES +: "${BOT_GAME_TYPES:=classic,1v1}" +export BOT_GAME_TYPES +: "${BOT_PLATFORM:=JVM}" +export BOT_PLATFORM +: "${BOT_PROG_LANG:=Java 8}" +export BOT_PROG_LANG + +exec java -cp "$REPO/tools/robocode_shim/out:$REPO/tools/robocode_shim/vendor/robocode.jar:$REPO/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar" robocode_shim.LegacyBotBridge diff --git a/legacy_bots/WaveSurferPG/WaveSurferPG.jar b/legacy_bots/WaveSurferPG/WaveSurferPG.jar new file mode 100644 index 0000000..c4f413e Binary files /dev/null and b/legacy_bots/WaveSurferPG/WaveSurferPG.jar differ diff --git a/legacy_bots/WaveSurferPG/WaveSurferPG.json b/legacy_bots/WaveSurferPG/WaveSurferPG.json new file mode 100644 index 0000000..f1bc720 --- /dev/null +++ b/legacy_bots/WaveSurferPG/WaveSurferPG.json @@ -0,0 +1,11 @@ +{ + "name": "WaveSurferPG", + "version": "1.06", + "authors": ["unknown"], + "description": "Classic Robocode robot suh.mega.WaveSurferPG running on Tank Royale via the robocode_shim bridge", + "homepage": "", + "countryCodes": ["se"], + "gameTypes": ["classic", "1v1"], + "platform": "JVM", + "programmingLang": "Java 8" +} diff --git a/legacy_bots/WaveSurferPG/WaveSurferPG.sh b/legacy_bots/WaveSurferPG/WaveSurferPG.sh new file mode 100755 index 0000000..9062837 --- /dev/null +++ b/legacy_bots/WaveSurferPG/WaveSurferPG.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Legacy classic-Robocode robot hosted on Tank Royale by our own shim. +# Bootable by the official tankroyale booter (SERVER_URL/SERVER_SECRET come from +# the environment - this script never hardcodes a server address). +cd "$(dirname "$0")" +HERE="$(pwd)" +REPO="$(cd "$HERE/../.." && pwd)" + +export SHIM_BOT_CLASS="suh.mega.WaveSurferPG" +export SHIM_BOT_JAR="$HERE/WaveSurferPG.jar" + +: "${SHIM_DATA:=${DRUSSGT_DATA:-$(mktemp -d "${TMPDIR:-/tmp}/tr_shim_data.XXXXXX")}}" +export SHIM_DATA + +: "${BOT_NAME:=WaveSurferPG}" +export BOT_NAME +: "${BOT_VERSION:=1.06}" +export BOT_VERSION +: "${BOT_AUTHORS:=unknown}" +export BOT_AUTHORS +: "${BOT_DESCRIPTION:=Classic Robocode robot suh.mega.WaveSurferPG running on Tank Royale via the robocode_shim bridge}" +export BOT_DESCRIPTION +: "${BOT_HOMEPAGE:=}" +export BOT_HOMEPAGE +: "${BOT_COUNTRY_CODES:=se}" +export BOT_COUNTRY_CODES +: "${BOT_GAME_TYPES:=classic,1v1}" +export BOT_GAME_TYPES +: "${BOT_PLATFORM:=JVM}" +export BOT_PLATFORM +: "${BOT_PROG_LANG:=Java 8}" +export BOT_PROG_LANG + +exec java -cp "$REPO/tools/robocode_shim/out:$REPO/tools/robocode_shim/vendor/robocode.jar:$REPO/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar" robocode_shim.LegacyBotBridge diff --git a/legacy_bots/YersiniaPestis/YersiniaPestis.jar b/legacy_bots/YersiniaPestis/YersiniaPestis.jar new file mode 100644 index 0000000..bbac1f8 Binary files /dev/null and b/legacy_bots/YersiniaPestis/YersiniaPestis.jar differ diff --git a/legacy_bots/YersiniaPestis/YersiniaPestis.json b/legacy_bots/YersiniaPestis/YersiniaPestis.json new file mode 100644 index 0000000..dbee776 --- /dev/null +++ b/legacy_bots/YersiniaPestis/YersiniaPestis.json @@ -0,0 +1,11 @@ +{ + "name": "YersiniaPestis", + "version": "4.0", + "authors": ["unknown"], + "description": "Classic Robocode robot zyx.mega.YersiniaPestis running on Tank Royale via the robocode_shim bridge", + "homepage": "", + "countryCodes": ["se"], + "gameTypes": ["classic", "1v1"], + "platform": "JVM", + "programmingLang": "Java 8" +} diff --git a/legacy_bots/YersiniaPestis/YersiniaPestis.sh b/legacy_bots/YersiniaPestis/YersiniaPestis.sh new file mode 100755 index 0000000..c87834a --- /dev/null +++ b/legacy_bots/YersiniaPestis/YersiniaPestis.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Legacy classic-Robocode robot hosted on Tank Royale by our own shim. +# Bootable by the official tankroyale booter (SERVER_URL/SERVER_SECRET come from +# the environment - this script never hardcodes a server address). +cd "$(dirname "$0")" +HERE="$(pwd)" +REPO="$(cd "$HERE/../.." && pwd)" + +export SHIM_BOT_CLASS="zyx.mega.YersiniaPestis" +export SHIM_BOT_JAR="$HERE/YersiniaPestis.jar" + +: "${SHIM_DATA:=${DRUSSGT_DATA:-$(mktemp -d "${TMPDIR:-/tmp}/tr_shim_data.XXXXXX")}}" +export SHIM_DATA + +: "${BOT_NAME:=YersiniaPestis}" +export BOT_NAME +: "${BOT_VERSION:=4.0}" +export BOT_VERSION +: "${BOT_AUTHORS:=unknown}" +export BOT_AUTHORS +: "${BOT_DESCRIPTION:=Classic Robocode robot zyx.mega.YersiniaPestis running on Tank Royale via the robocode_shim bridge}" +export BOT_DESCRIPTION +: "${BOT_HOMEPAGE:=}" +export BOT_HOMEPAGE +: "${BOT_COUNTRY_CODES:=se}" +export BOT_COUNTRY_CODES +: "${BOT_GAME_TYPES:=classic,1v1}" +export BOT_GAME_TYPES +: "${BOT_PLATFORM:=JVM}" +export BOT_PLATFORM +: "${BOT_PROG_LANG:=Java 8}" +export BOT_PROG_LANG + +exec java -cp "$REPO/tools/robocode_shim/out:$REPO/tools/robocode_shim/vendor/robocode.jar:$REPO/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar" robocode_shim.LegacyBotBridge diff --git a/tools/booter/README.md b/tools/booter/README.md new file mode 100644 index 0000000..2bc86f3 --- /dev/null +++ b/tools/booter/README.md @@ -0,0 +1,115 @@ +# `tools/booter/` — the official Robocode Tank Royale **booter** + +`robocode-tankroyale-booter-0.35.5-all.jar` is the official booter from the +Tank Royale project (`dev.robocode.tankroyale:robocode-tankroyale-booter`), +copied here from a local build of +`/home/davide/Projects/tank-royale/booter/build/libs/` so every future session +has it without re-resolving or re-downloading anything. + +## What it does + +The booter is a **process launcher and nothing more**. It scans a directory of +bot entries, and for each one spawns the bot as a child JVM process. It knows +nothing about Robocode, about Tank Royale physics, or about our shim — it just +starts `.sh` and relays stdin commands. + +Every directory under `legacy_bots/` satisfies the booter's **base-name rule**: +all files in the directory share the same base filename, which equals the +directory name. So `legacy_bots/Dookious/` holds `Dookious.sh`, `Dookious.json` +and `Dookious.jar`, and the booter resolves and runs `Dookious.sh`. For our +legacy bots the `.sh` execs `robocode_shim.LegacyBotBridge`, which is what +actually loads the classic jar and speaks the Tank Royale bot API. + +## CLI + +``` +Usage: booter [] []... + +Options: + -v, --version Show the version and exit + -h, --help Show this message and exit + +Commands: + dir List all available bot and team directories. + info List info of all available bots in JSON format. + boot Boot one or multiple bot or team entries into individual bot processes. +``` + +**The command is `boot`, not `run`.** The upstream README still documents +`run`; that text is stale — `run` does not exist in 0.35.5 and exits with a usage +error. + +### Server URL and secret are SYSTEM PROPERTIES, not CLI arguments + +This is the part that trips everyone up. There is no `--server-url` flag. The +booter reads them from the JVM system properties `-Dserver.url` and +`-Dserver.secret`, which the booter then hands to each booted bot process in the +environment (as `SERVER_URL` / `SERVER_SECRET`). Our `.sh` launchers +deliberately never hardcode either value. + +```sh +java \ + -Dserver.url=localhost:9876 \ + -Dserver.secret=$TR_SERVER_SECRET \ + -jar tools/booter/robocode-tankroyale-booter-0.35.5-all.jar boot legacy_bots/Dookious +``` + +## Common uses + +List what the booter can see: + +```sh +java -jar tools/booter/robocode-tankroyale-booter-0.35.5-all.jar dir "$PWD/legacy_bots" +``` + +The same thing as machine-readable JSON (one object per bot): + +```sh +java -jar tools/booter/robocode-tankroyale-booter-0.35.5-all.jar info "$PWD/legacy_bots" +``` + +Boot bots. Paths are resolved relative to the working directory, and the booter +accepts a parent directory to boot everything under it: + +```sh +java -jar tools/booter/robocode-tankroyale-booter-0.35.5-all.jar boot "$PWD/legacy_bots/Dookious" +java -jar tools/booter/robocode-tankroyale-booter-0.35.5-all.jar boot "$PWD/legacy_bots" +``` + +### Stdin commands + +Once booted, the booter reads commands from stdin, one per line: + +| Command | Effect | +|---|---| +| `boot {dir}` | boot another bot or team entry into its own process | +| `stop {pid}` | stop the bot process with that pid | +| `quit` | stop everything and exit | + +``` +$ java -jar tools/booter/robocode-tankroyale-booter-0.35.5-all.jar boot "$PWD/legacy_bots/Dookious" +Booting: Dookious +#12345 +boot legacy_bots/CassiusClay +#12346 +stop 12345 +quit +``` + +## Verified against this repo + +Booter 0.35.5 discovers **all 28** curated bots in `legacy_bots/` — both `dir` +and `info` return 28 entries. See +[`legacy_bots/README.md`](../../legacy_bots/README.md) for the roster. + +## Provenance + +Copied from a local build; no download was needed. Upstream coordinates, if you +ever need to re-fetch it: + +- group: `dev.robocode.tankroyale` +- artifact: `robocode-tankroyale-booter` +- + +Use the `-all` (fat) jar — the plain `-0.35.5.jar` needs the rest of the +distribution's libraries on the classpath and will not run standalone. \ No newline at end of file diff --git a/tools/booter/robocode-tankroyale-booter-0.35.5-all.jar b/tools/booter/robocode-tankroyale-booter-0.35.5-all.jar new file mode 100644 index 0000000..f8154d4 Binary files /dev/null and b/tools/booter/robocode-tankroyale-booter-0.35.5-all.jar differ diff --git a/tools/robocode_shim/.gitignore b/tools/robocode_shim/.gitignore index 1029602..c565a9a 100644 --- a/tools/robocode_shim/.gitignore +++ b/tools/robocode_shim/.gitignore @@ -1,7 +1,9 @@ # Build output (compiled shim + compiled DrussGT classes) out/ -# Never commit third-party Robocode / DrussGT jars here. -# They live outside the repo (e.g. /tmp/robocode/install/libs/robocode.jar, -# /tmp/drussgt/DrussGT.jar) and are referenced via ROBOCODE_JAR/DRUSSGT_JAR. +# Third-party Robocode jars fetched ad hoc are not committed; the vendored +# DrussGT under vendor/drussgt/ IS tracked (GPL, waived by the repo owner for +# this private LAN repo). Ad-hoc jars are passed via ROBOCODE_JAR/DRUSSGT_JAR. *.jar +!vendor/drussgt/DrussGT.jar +!vendor/*.jar diff --git a/tools/robocode_shim/LEGACY_BOTS.md b/tools/robocode_shim/LEGACY_BOTS.md index 4fcbec5..56bec4e 100644 --- a/tools/robocode_shim/LEGACY_BOTS.md +++ b/tools/robocode_shim/LEGACY_BOTS.md @@ -5,15 +5,28 @@ host any unmodified classic robot jar, not just DrussGT. This document is the short version of how to use it and what was validated. The machine-readable manifest is [`robots.json`](robots.json). -**No third-party jar is committed.** Every jar lives in `/tmp` and is referenced -by absolute path; the repo only contains the shim, the manifest and this doc. +**Legacy bot jars are NOT committed** — every one of them records +`"license": "not stated in jar"` in [`robots.json`](robots.json), and DrussGT is +documented as GPL. What IS committed, for all 28 bots, is the +`.sh` launcher, the `.json` bot descriptor, the checksums in +`legacy_bots/MANIFEST.sha256` and this documentation. Fetch the jars from +`http://robocode-archive.strangeautomata.com/robots/` and verify with +`sha256sum -c MANIFEST.sha256` — see [`legacy_bots/README.md`](../../legacy_bots/README.md). +This file is the engineering log; `legacy_bots/README.md` is the roster. +The runtime jars the shim links against (`robocode.jar`, the Tank Royale bot-api +jar) are vendored and tracked under `tools/robocode_shim/vendor/`. ## Direct answer -* **28 legacy champions are usable right now** (27 validated as effective + - DrussGT itself). A further **5 play but are weak/degraded** (they fire and - scan but landed 0 hits against the sample SpinBot). **2 fail** (Nene, - Seraphim — see below). +* **28 legacy champions are usable right now** and live in `legacy_bots/` + (26 validated as effective + `PatternRobot` and `KurtWaveSurfer`, which play + but are flagged weak). `DrussGT` itself is the reference bot and lives in + `tr_bots/DrussGT`. +* **6 were dropped** after measurement: `Nene`, `Seraphim` (inert, 0 shots — + see the missing-API note below), and `Aurora`, `FloodMini`, `LightningBug`, + `Aristocles` (fire but never move, 0 hits). Their jars and wrapper dirs were + deleted from `tr_bots/_salvage/`; see the "Removed" table in + [`legacy_bots/README.md`](../../legacy_bots/README.md). * Cost to add the top remaining failures: **~2–4 h** to add a second driver path for bots that implement `IBasicRobot` directly and return `null` from `getRobotRunnable()` (this is the only hard blocker left; it unlocks Nene and @@ -26,15 +39,15 @@ by absolute path; the repo only contains the shim, the manifest and this doc. ```bash # 1. download the jar (the RoboRumble archive is browsable) -curl -Lo /tmp/bots/voidious.Diamond_1.8.28.jar \ +curl -Lo legacy_bots/Diamond/Diamond.jar \ http://robocode-archive.strangeautomata.com/robots/voidious.Diamond_1.8.28.jar # 2. generate the Tank Royale bot directory -tools/robocode_shim/make_botdir.sh Diamond \ - --class voidious.Diamond --jar /tmp/bots/voidious.Diamond_1.8.28.jar +tools/robocode_shim/make_botdir.sh legacy_bots/Diamond \ + --class voidious.Diamond --jar "$PWD/legacy_bots/Diamond/Diamond.jar" # 3. prove it plays a real Tank Royale battle (2 rounds vs the sample SpinBot) -SHIM_BOTDIR=/tmp/tr_bots/Diamond tools/robocode_shim/run_bridge_battle.sh \ +SHIM_BOTDIR=legacy_bots/Diamond tools/robocode_shim/run_bridge_battle.sh \ /home/davide/Projects/tank-royale/sample-bots/java/build/archive/SpinBot 2 ``` @@ -61,14 +74,14 @@ does not need any extra environment variables. ### One-line smoke battle for any generated bot ```bash -SHIM_BOTDIR=/tmp/tr_bots/ tools/robocode_shim/run_bridge_battle.sh \ +SHIM_BOTDIR=legacy_bots/ tools/robocode_shim/run_bridge_battle.sh \ /home/davide/Projects/tank-royale/sample-bots/java/build/archive/SpinBot 2 ``` ### Offline triage (no server, ~2 s per bot) ```bash -SHIM_BOT_JAR=/tmp/bots/ SHIM_BOT_CLASS= tools/robocode_shim/run_smoke.sh +SHIM_BOT_JAR=legacy_bots//.jar SHIM_BOT_CLASS= tools/robocode_shim/run_smoke.sh ``` > Caution: this synthetic harness has **false negatives** — Diamond, Dookious and @@ -107,13 +120,21 @@ SHIM_BOT_JAR=/tmp/bots/ SHIM_BOT_CLASS= tools/robocode_shim/run_smoke | 25 | CigaretBH | mini bullet-hiding surfer | **WORKS** | 67 / 11 / 3 — split 1-1 | | 26 | Komarious | mini pattern matcher / surfer | **WORKS** | 62 / 20 / 10 — split 1-1 | | 27 | LionWWSVMvoid | wave-surfing SVM gun | **WORKS** | 62 / 12 / 12 — lost 0-2 | -| 28 | FloodMini | mini flood-fill movement | WORKS_WEAK | 25 / 0 / 10 — lost 0-2 | -| 29 | Aristocles | micro surfer | WORKS_WEAK | 39 / 0 / 10 — lost 0-2 | -| 30 | PatternRobot | simple pattern robot | WORKS_WEAK | 8 / 0 / 2 — lost 0-2 | -| 31 | LightningBug | pattern matcher | WORKS_WEAK | 36 / 0 / 10 — lost 0-2 | -| 32 | Aurora | micro (team-derived) | WORKS_WEAK | 6 / 0 / 13 — lost 0-2 | -| 33 | Nene | melee (Azuma framework) | **FAILS** | 0 / 0 / 14 — inert | -| 34 | Seraphim | melee (Azuma framework) | **FAILS** | 0 / 0 / 14 — inert | +| 28 | PatternRobot | simple pattern robot | WORKS_WEAK | 8 / 0 / 2 — lost 0-2 | + +### Dropped (`NOT_USEFUL`) — measured, then removed + +| Bot | Style | Status at drop | Measured | Reason | +|---|---|---|---|---| +| — | Aurora | micro (team-derived) | 6 / 0 / 13 | fires 6 shots, crawls | +| — | FloodMini | mini flood-fill movement | 25 / 0 / 10 | near-stationary turret | +| — | LightningBug | pattern matcher | 36 / 0 / 10 | near-stationary turret | +| — | Aristocles | micro surfer | 39 / 0 / 10 | near-stationary turret | +| — | Nene | melee (Azuma framework) | 0 / 0 / 14 | **FAILS** — inert, 0 scans 0 shots | +| — | Seraphim | melee (Azuma framework) | 0 / 0 / 14 | **FAILS** — inert, 0 scans 0 shots | + +Jars deleted from `tr_bots/_salvage/legacy_bots/`, wrapper dirs deleted from +`tr_bots/_salvage/tr_wrappers/`, entries removed from `robots.json`. `WORKS` = the battle completed, the bot scanned, moved and fired, and landed hits. `WORKS_WEAK` = the battle completed and the bot scanned/fired, but landed **0** @@ -177,8 +198,8 @@ each is now a one-time cost of ~0.5–1 h (already paid): ## Reproducing the validation ```bash -export ROBOCODE_JAR=/tmp/robocode/install/libs/robocode.jar -export TR_BOT_API_JAR=$HOME/Downloads/sample-bots-java-1.0.2/lib/robocode-tankroyale-bot-api-1.0.2.jar +export ROBOCODE_JAR=$PWD/tools/robocode_shim/vendor/robocode.jar +export TR_BOT_API_JAR=$PWD/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar tools/robocode_shim/build.sh tools/robocode_shim/compile_drussgt.sh # DrussGT acceptance: 20/22 files, 43 classes tools/robocode_shim/run_smoke.sh # DrussGT default path unchanged: OK diff --git a/tools/robocode_shim/build.sh b/tools/robocode_shim/build.sh index 4cd9174..051b0ef 100755 --- a/tools/robocode_shim/build.sh +++ b/tools/robocode_shim/build.sh @@ -9,7 +9,7 @@ set -euo pipefail HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -ROBOCODE_JAR="${ROBOCODE_JAR:-/tmp/robocode/install/libs/robocode.jar}" +ROBOCODE_JAR="${ROBOCODE_JAR:-$HERE/vendor/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}" diff --git a/tools/robocode_shim/compile_drussgt.sh b/tools/robocode_shim/compile_drussgt.sh index 719d267..fe3a152 100755 --- a/tools/robocode_shim/compile_drussgt.sh +++ b/tools/robocode_shim/compile_drussgt.sh @@ -17,9 +17,11 @@ set -euo pipefail HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -ROBOCODE_JAR="${ROBOCODE_JAR:-/tmp/robocode/install/libs/robocode.jar}" -DRUSSGT_SRC="${DRUSSGT_SRC:-/tmp/drussgt/src}" -DRUSSGT_JAR="${DRUSSGT_JAR:-/tmp/drussgt/DrussGT.jar}" +# All inputs are vendored inside the repo (tools/robocode_shim/vendor/) so a +# rebuild never depends on /tmp. Override any of the three to point elsewhere. +ROBOCODE_JAR="${ROBOCODE_JAR:-$HERE/vendor/robocode.jar}" +DRUSSGT_SRC="${DRUSSGT_SRC:-$HERE/vendor/drussgt/src}" +DRUSSGT_JAR="${DRUSSGT_JAR:-$HERE/vendor/drussgt/DrussGT.jar}" OUT="${OUT:-$HERE/out/drussgt}" for f in "$ROBOCODE_JAR" "$DRUSSGT_JAR"; do diff --git a/tools/robocode_shim/make_botdir.sh b/tools/robocode_shim/make_botdir.sh index 9773abf..7650d04 100755 --- a/tools/robocode_shim/make_botdir.sh +++ b/tools/robocode_shim/make_botdir.sh @@ -63,7 +63,7 @@ elif [[ "$TARGET" != */* ]]; then fi DIR_NAME="$(basename "$TARGET")" -DRUSSGT_JAR="${DRUSSGT_JAR:-/tmp/drussgt/DrussGT.jar}" +DRUSSGT_JAR="${DRUSSGT_JAR:-$HERE/vendor/drussgt/DrussGT.jar}" CLASS="${CLASS:-jk.mega.DrussGT}" JAR="${JAR:-$DRUSSGT_JAR}" NAME="${DISPLAY:-$DIR_NAME}" @@ -85,7 +85,7 @@ else fi; } GAMETYPES_JSON="$(printf '%s' "$GAMETYPES" | sed 's/,/\", \"/g')" -ROBOCODE_JAR="${ROBOCODE_JAR:-/tmp/robocode/install/libs/robocode.jar}" +ROBOCODE_JAR="${ROBOCODE_JAR:-$HERE/vendor/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}" EXTRA_CP="${SHIM_EXTRA_CP:-}" diff --git a/tools/robocode_shim/robots.json b/tools/robocode_shim/robots.json index 074f1bb..fbefcde 100644 --- a/tools/robocode_shim/robots.json +++ b/tools/robocode_shim/robots.json @@ -1,474 +1,422 @@ { "manifest_version": 1, - "description": "Legacy classic-Robocode bots validated as Tank Royale sparring partners through the generalized robocode_shim bridge. No third-party jar is committed; jars live in /tmp and are referenced by absolute path. 'style' is INFERRED from the bot name/docs; 'evidence' is MEASURED (2-round Tank Royale battles vs the sample SpinBot, embedded server).", + "description": "Legacy classic-Robocode bots validated as Tank Royale sparring partners through the generalized robocode_shim bridge. Third-party jars ARE committed: their license is 'not stated in jar' for all of them and DrussGT is GPL, but the repo owner has explicitly waived that concern (PRIVATE repo on their own LAN). Only the curated roster lives in legacy_bots/ - six NOT_USEFUL bots were measured and dropped. 'style' is INFERRED from the bot name/docs; 'evidence' is MEASURED (Tank Royale battles via the shim bridge).", "source_archive": "http://robocode-archive.strangeautomata.com/robots/", "roboarchive_note": "Directory listing is browsable; every jar was fetched with HTTP 200.", - "robocode_api_jar": "/tmp/robocode/install/libs/robocode.jar", - "how_to_add": "tools/robocode_shim/make_botdir.sh --class --jar ", + "robocode_api_jar": "tools/robocode_shim/vendor/robocode.jar", + "how_to_add": "see legacy_bots/README.md", "bots": [ { "name": "DrussGT", "main_class": "jk.mega.DrussGT", - "jar": "/tmp/drussgt/DrussGT.jar", + "jar": "tools/robocode_shim/vendor/drussgt/DrussGT.jar", "version": "3.1.4159", "style": "dynamic-clustering gun + wave-surfing movement (Voidious-style mega)", "status": "REFERENCE", "obtained": "pre-existing (spike asset)", "source_url": "", "license": "not stated in jar", - "botdir": "/tmp/tr_bots/DrussGT", + "botdir": "tr_bots/DrussGT", "evidence": "run_bridge_battle.sh default path, 2 rounds vs SpinBot: fired 141, hits 17; won 2/2" }, { "name": "Diamond", "main_class": "voidious.Diamond", - "jar": "/tmp/bots/voidious.Diamond_1.8.28.jar", + "jar": "legacy_bots/Diamond/Diamond.jar", "version": "1.8.28", "style": "pattern-matching gun + wave-surfing movement", "status": "WORKS", "obtained": "downloaded jar", "source_url": "http://robocode-archive.strangeautomata.com/robots/voidious.Diamond_1.8.28.jar", "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/Diamond", - "evidence": "2 rounds vs SpinBot: scans=783 bulletsFired=50 bulletHits=18 bulletMisses=29 bulletHitBullets=0 hitsTaken=1; result unknown" + "botdir": "legacy_bots/Diamond", + "evidence": "2 rounds vs SpinBot: scans=783 bulletsFired=50 bulletHits=18 bulletMisses=29 bulletHitBullets=0 hitsTaken=1; result unknown", + "sha256": "1ab39d66041eaf4edf5c073d8caa7c61ff5e783961adfad03914f14017d048ea" }, { "name": "Dookious", "main_class": "voidious.Dookious", - "jar": "/tmp/bots/voidious.Dookious_1.60.jar", + "jar": "legacy_bots/Dookious/Dookious.jar", "version": "1.60", "style": "wave-surfing movement + pattern/GF gun", "status": "WORKS", "obtained": "downloaded jar", "source_url": "http://robocode-archive.strangeautomata.com/robots/voidious.Dookious_1.60.jar", "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/Dookious", - "evidence": "2 rounds vs SpinBot: scans=396 bulletsFired=86 bulletHits=16 bulletMisses=70 bulletHitBullets=0 hitsTaken=1; result unknown" + "botdir": "legacy_bots/Dookious", + "evidence": "2 rounds vs SpinBot: scans=396 bulletsFired=86 bulletHits=16 bulletMisses=70 bulletHitBullets=0 hitsTaken=1; result unknown", + "sha256": "2e4e94b5061bd287d758b0dcc03734a6a5cb432b077d2b296f9641682bad4d96" }, { "name": "Lukious", "main_class": "voidious.Lukious", - "jar": "/tmp/bots/voidious.Lukious_1.321.jar", + "jar": "legacy_bots/Lukious/Lukious.jar", "version": "1.321", "style": "wave-surfing movement", "status": "WORKS", "obtained": "downloaded jar", "source_url": "http://robocode-archive.strangeautomata.com/robots/voidious.Lukious_1.321.jar", "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/Lukious", - "evidence": "2 rounds vs SpinBot: scans=191 bulletsFired=70 bulletHits=15 bulletMisses=53 bulletHitBullets=0 hitsTaken=3; result unknown" + "botdir": "legacy_bots/Lukious", + "evidence": "2 rounds vs SpinBot: scans=191 bulletsFired=70 bulletHits=15 bulletMisses=53 bulletHitBullets=0 hitsTaken=3; result unknown", + "sha256": "e3371b1bf776fc64773d8eef6278284be15a6ceff248e36603d64163a2d043dc" }, { "name": "Shadow", "main_class": "abc.Shadow", - "jar": "/tmp/bots/abc.Shadow_3.84i.jar", + "jar": "legacy_bots/Shadow/Shadow.jar", "version": "3.84i", "style": "pattern-matching (team-derived, runs 1v1)", "status": "WORKS", "obtained": "downloaded jar", "source_url": "http://robocode-archive.strangeautomata.com/robots/abc.Shadow_3.84i.jar", "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/Shadow", - "evidence": "2 rounds vs SpinBot: scans=410 bulletsFired=25 bulletHits=19 bulletMisses=5 bulletHitBullets=1 hitsTaken=0; result unknown" + "botdir": "legacy_bots/Shadow", + "evidence": "2 rounds vs SpinBot: scans=410 bulletsFired=25 bulletHits=19 bulletMisses=5 bulletHitBullets=1 hitsTaken=0; result unknown", + "sha256": "17d56b87bb68ff840ccda8a4a407b8fcfe5f23b8be5aa7d7a98b61a01138ef6e" }, { "name": "Phoenix", "main_class": "davidalves.Phoenix", - "jar": "/tmp/bots/davidalves.Phoenix_1.02.jar", + "jar": "legacy_bots/Phoenix/Phoenix.jar", "version": "1.02", "style": "pattern-matching (team-derived, runs 1v1)", "status": "WORKS", "obtained": "downloaded jar", "source_url": "http://robocode-archive.strangeautomata.com/robots/davidalves.Phoenix_1.02.jar", "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/Phoenix", - "evidence": "2 rounds vs SpinBot: scans=735 bulletsFired=50 bulletHits=17 bulletMisses=29 bulletHitBullets=0 hitsTaken=0; result unknown" + "botdir": "legacy_bots/Phoenix", + "evidence": "2 rounds vs SpinBot: scans=735 bulletsFired=50 bulletHits=17 bulletMisses=29 bulletHitBullets=0 hitsTaken=0; result unknown", + "sha256": "89b46a3c5cd14c05e6ec5f59ab189852178cd2d774313ac2e0a2b3971ec0fb37" }, { "name": "RougeDC", "main_class": "ags.rougedc.RougeDC", - "jar": "/tmp/bots/ags.rougedc.RougeDC_willow.jar", + "jar": "legacy_bots/RougeDC/RougeDC.jar", "version": "willow", "style": "dynamic-clustering gun + surfing (melee-capable)", "status": "WORKS", "obtained": "downloaded jar", "source_url": "http://robocode-archive.strangeautomata.com/robots/ags.rougedc.RougeDC_willow.jar", "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/RougeDC", - "evidence": "2 rounds vs SpinBot: scans=113 bulletsFired=67 bulletHits=14 bulletMisses=49 bulletHitBullets=0 hitsTaken=2; result unknown" + "botdir": "legacy_bots/RougeDC", + "evidence": "2 rounds vs SpinBot: scans=113 bulletsFired=67 bulletHits=14 bulletMisses=49 bulletHitBullets=0 hitsTaken=2; result unknown", + "sha256": "2aee27ddd085c75f61943240e090e018c9e69f658cd4afed508430910a41d2ab" }, { "name": "DiamondStealer", "main_class": "jab.DiamondStealer", - "jar": "/tmp/bots/jab.DiamondStealer_5.jar", + "jar": "legacy_bots/DiamondStealer/DiamondStealer.jar", "version": "5", "style": "rammer / close-range brawler", "status": "WORKS", "obtained": "downloaded jar", "source_url": "http://robocode-archive.strangeautomata.com/robots/jab.DiamondStealer_5.jar", "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/DiamondStealer", - "evidence": "2 rounds vs SpinBot: scans=305 bulletsFired=18 bulletHits=12 bulletMisses=3 bulletHitBullets=0 hitsTaken=1; result unknown" + "botdir": "legacy_bots/DiamondStealer", + "evidence": "2 rounds vs SpinBot: scans=305 bulletsFired=18 bulletHits=12 bulletMisses=3 bulletHitBullets=0 hitsTaken=1; result unknown", + "sha256": "57f7348becec43c111d2e126240b30b5fdb8bc597ff18104df1cf07d67aaee5c" }, { "name": "GresSuffurd", "main_class": "gh.GresSuffurd", - "jar": "/tmp/bots/gh.GresSuffurd_0.4.18.jar", + "jar": "legacy_bots/GresSuffurd/GresSuffurd.jar", "version": "0.4.18", "style": "wave-surfing gun + movement", "status": "WORKS", "obtained": "downloaded jar", "source_url": "http://robocode-archive.strangeautomata.com/robots/gh.GresSuffurd_0.4.18.jar", "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/GresSuffurd", - "evidence": "2 rounds vs SpinBot: scans=432 bulletsFired=72 bulletHits=15 bulletMisses=55 bulletHitBullets=1 hitsTaken=0; result unknown" + "botdir": "legacy_bots/GresSuffurd", + "evidence": "2 rounds vs SpinBot: scans=432 bulletsFired=72 bulletHits=15 bulletMisses=55 bulletHitBullets=1 hitsTaken=0; result unknown", + "sha256": "20ba2d6f93c8970145b2186b79f4e5171a90a8048dcda2baa82fc98ba211d943" }, { "name": "KurtWaveSurfer", "main_class": "kurt.robot.KurtWaveSurfer", - "jar": "/tmp/bots/kurt.robot.KurtWaveSurfer_1.6.jar", + "jar": "legacy_bots/KurtWaveSurfer/KurtWaveSurfer.jar", "version": "1.6", "style": "wave surfer", - "status": "WORKS", + "status": "WORKS_WEAK", "obtained": "downloaded jar", "source_url": "http://robocode-archive.strangeautomata.com/robots/kurt.robot.KurtWaveSurfer_1.6.jar", "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/KurtWaveSurfer", - "evidence": "2 rounds vs SpinBot: scans=245 bulletsFired=84 bulletHits=13 bulletMisses=69 bulletHitBullets=0 hitsTaken=1; result unknown" + "botdir": "legacy_bots/KurtWaveSurfer", + "evidence": "2 rounds vs SpinBot: scans=245 bulletsFired=84 bulletHits=13 bulletMisses=69 bulletHitBullets=0 hitsTaken=1; result unknown", + "sha256": "dd2e9473a7a1ab2287b6e7fee097a23ea2c951ab525393b60e20ab6b5b37c791" }, { "name": "CassiusClay", "main_class": "pez.rumble.CassiusClay", - "jar": "/tmp/bots/pez.rumble.CassiusClay_2rho.02no.jar", + "jar": "legacy_bots/CassiusClay/CassiusClay.jar", "version": "2rho.02no", "style": "pattern-matching gun + surf movement", "status": "WORKS", "obtained": "downloaded jar", "source_url": "http://robocode-archive.strangeautomata.com/robots/pez.rumble.CassiusClay_2rho.02no.jar", "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/CassiusClay", - "evidence": "2 rounds vs SpinBot: scans=929 bulletsFired=55 bulletHits=11 bulletMisses=39 bulletHitBullets=1 hitsTaken=0; result unknown" + "botdir": "legacy_bots/CassiusClay", + "evidence": "2 rounds vs SpinBot: scans=929 bulletsFired=55 bulletHits=11 bulletMisses=39 bulletHitBullets=1 hitsTaken=0; result unknown", + "sha256": "ff3b9734226c33bc78ffdbef6004c9926f1bc70e3914d79fd129b4c0bfa8ade5" }, { "name": "Coriantumr", "main_class": "kawigi.mini.Coriantumr", - "jar": "/tmp/bots/kawigi.mini.Coriantumr_1.1.jar", + "jar": "legacy_bots/Coriantumr/Coriantumr.jar", "version": "1.1", "style": "mini pattern matcher", "status": "WORKS", "obtained": "downloaded jar", "source_url": "http://robocode-archive.strangeautomata.com/robots/kawigi.mini.Coriantumr_1.1.jar", "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/Coriantumr", - "evidence": "2 rounds vs SpinBot: scans=1113 bulletsFired=41 bulletHits=14 bulletMisses=24 bulletHitBullets=0 hitsTaken=1; result unknown" + "botdir": "legacy_bots/Coriantumr", + "evidence": "2 rounds vs SpinBot: scans=1113 bulletsFired=41 bulletHits=14 bulletMisses=24 bulletHitBullets=0 hitsTaken=1; result unknown", + "sha256": "39d3b37cc9e7a9a2f244efcc526d756846e66a619730e75beb24cdce70194b5f" }, { "name": "BrokenSword", "main_class": "voidious.mini.BrokenSword", - "jar": "/tmp/bots/voidious.mini.BrokenSword_2.0.3.jar", + "jar": "legacy_bots/BrokenSword/BrokenSword.jar", "version": "2.0.3", "style": "mini pattern matcher", "status": "WORKS", "obtained": "downloaded jar", "source_url": "http://robocode-archive.strangeautomata.com/robots/voidious.mini.BrokenSword_2.0.3.jar", "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/BrokenSword", - "evidence": "2 rounds vs SpinBot: scans=617 bulletsFired=38 bulletHits=15 bulletMisses=18 bulletHitBullets=0 hitsTaken=3; result unknown" + "botdir": "legacy_bots/BrokenSword", + "evidence": "2 rounds vs SpinBot: scans=617 bulletsFired=38 bulletHits=15 bulletMisses=18 bulletHitBullets=0 hitsTaken=3; result unknown", + "sha256": "2a0068f2d9b683646a1148654274f4132cf4ecf1c9432823e389a2fdb50b4d65" }, { "name": "WaveSurferGF", "main_class": "suh.mega.WaveSurferGF", - "jar": "/tmp/bots/suh.mega.WaveSurferGF_1.04.jar", + "jar": "legacy_bots/WaveSurferGF/WaveSurferGF.jar", "version": "1.04", "style": "wave surfer (guess-factor gun)", "status": "WORKS", "obtained": "downloaded jar", "source_url": "http://robocode-archive.strangeautomata.com/robots/suh.mega.WaveSurferGF_1.04.jar", "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/WaveSurferGF", - "evidence": "2 rounds vs SpinBot: scans=835 bulletsFired=49 bulletHits=13 bulletMisses=33 bulletHitBullets=1 hitsTaken=1; result unknown" + "botdir": "legacy_bots/WaveSurferGF", + "evidence": "2 rounds vs SpinBot: scans=835 bulletsFired=49 bulletHits=13 bulletMisses=33 bulletHitBullets=1 hitsTaken=1; result unknown", + "sha256": "aa149f2d63a26aa3a601bf8d76fd7e10cee78a3731908a0aa3ba58c3db54c3c4" }, { "name": "WaveSurferPG", "main_class": "suh.mega.WaveSurferPG", - "jar": "/tmp/bots/suh.mega.WaveSurferPG_1.06.jar", + "jar": "legacy_bots/WaveSurferPG/WaveSurferPG.jar", "version": "1.06", "style": "wave surfer (pattern gun)", "status": "WORKS", "obtained": "downloaded jar", "source_url": "http://robocode-archive.strangeautomata.com/robots/suh.mega.WaveSurferPG_1.06.jar", "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/WaveSurferPG", - "evidence": "2 rounds vs SpinBot: scans=917 bulletsFired=57 bulletHits=16 bulletMisses=41 bulletHitBullets=0 hitsTaken=3; result unknown" + "botdir": "legacy_bots/WaveSurferPG", + "evidence": "2 rounds vs SpinBot: scans=917 bulletsFired=57 bulletHits=16 bulletMisses=41 bulletHitBullets=0 hitsTaken=3; result unknown", + "sha256": "8154cbe8645640447447d1f55bf5da0e9484b6b7d6507c87824f9ebe71952848" }, { "name": "TripHammer", "main_class": "voidious.TripHammer", - "jar": "/tmp/bots/voidious.TripHammer_R2.1.0.jar", + "jar": "legacy_bots/TripHammer/TripHammer.jar", "version": "R2.1.0", "style": "pattern matcher", "status": "WORKS", "obtained": "downloaded jar", "source_url": "http://robocode-archive.strangeautomata.com/robots/voidious.TripHammer_R2.1.0.jar", "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/TripHammer", - "evidence": "2 rounds vs SpinBot: scans=812 bulletsFired=52 bulletHits=19 bulletMisses=29 bulletHitBullets=0 hitsTaken=1; result unknown" + "botdir": "legacy_bots/TripHammer", + "evidence": "2 rounds vs SpinBot: scans=812 bulletsFired=52 bulletHits=19 bulletMisses=29 bulletHitBullets=0 hitsTaken=1; result unknown", + "sha256": "a6773101852b9fb415845770eb94435e7b3c34c493dba0b964a4235903601e8b" }, { "name": "RetroGirl", "main_class": "voidious.perceptual.RetroGirl", - "jar": "/tmp/bots/voidious.perceptual.RetroGirl_1.0.0.jar", + "jar": "legacy_bots/RetroGirl/RetroGirl.jar", "version": "1.0.0", "style": "perceptual pattern matcher", "status": "WORKS", "obtained": "downloaded jar", "source_url": "http://robocode-archive.strangeautomata.com/robots/voidious.perceptual.RetroGirl_1.0.0.jar", "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/RetroGirl", - "evidence": "2 rounds vs SpinBot: scans=223 bulletsFired=106 bulletHits=26 bulletMisses=77 bulletHitBullets=0 hitsTaken=5; result unknown" + "botdir": "legacy_bots/RetroGirl", + "evidence": "2 rounds vs SpinBot: scans=223 bulletsFired=106 bulletHits=26 bulletMisses=77 bulletHitBullets=0 hitsTaken=5; result unknown", + "sha256": "79884ef9a9613ab04d92fa6a9cce64d2cdf38c7ec347060e16e746bb8474df35" }, { "name": "Jen", "main_class": "voidious.micro.Jen", - "jar": "/tmp/bots/voidious.micro.Jen_1.092.jar", + "jar": "legacy_bots/Jen/Jen.jar", "version": "1.092", "style": "micro wave surfer", "status": "WORKS", "obtained": "downloaded jar", "source_url": "http://robocode-archive.strangeautomata.com/robots/voidious.micro.Jen_1.092.jar", "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/Jen", - "evidence": "2 rounds vs SpinBot: scans=170 bulletsFired=71 bulletHits=13 bulletMisses=55 bulletHitBullets=0 hitsTaken=2; result unknown" + "botdir": "legacy_bots/Jen", + "evidence": "2 rounds vs SpinBot: scans=170 bulletsFired=71 bulletHits=13 bulletMisses=55 bulletHitBullets=0 hitsTaken=2; result unknown", + "sha256": "f8630c113fa6cbb5e4f3bfe6c8dc46cf409a24454146fce48d561fbed1d9f3b2" }, { "name": "BlitzBat", "main_class": "voidious.micro.BlitzBat", - "jar": "/tmp/bots/voidious.micro.BlitzBat_1.05.jar", + "jar": "legacy_bots/BlitzBat/BlitzBat.jar", "version": "1.05", "style": "micro brawler", "status": "WORKS", "obtained": "downloaded jar", "source_url": "http://robocode-archive.strangeautomata.com/robots/voidious.micro.BlitzBat_1.05.jar", "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/BlitzBat", - "evidence": "2 rounds vs SpinBot: scans=79 bulletsFired=34 bulletHits=12 bulletMisses=16 bulletHitBullets=0 hitsTaken=1; result unknown" + "botdir": "legacy_bots/BlitzBat", + "evidence": "2 rounds vs SpinBot: scans=79 bulletsFired=34 bulletHits=12 bulletMisses=16 bulletHitBullets=0 hitsTaken=1; result unknown", + "sha256": "230ecca59b61889bac4239a8c0a25c571bc72698477001cb93759a3832a585ac" }, { "name": "Ascendant", "main_class": "mue.Ascendant", - "jar": "/tmp/bots/mue.Ascendant_1.2.27.jar", + "jar": "legacy_bots/Ascendant/Ascendant.jar", "version": "1.2.27", "style": "aggressive 1v1 mega (team-derived base)", "status": "WORKS", "obtained": "downloaded jar", "source_url": "http://robocode-archive.strangeautomata.com/robots/mue.Ascendant_1.2.27.jar", "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/Ascendant", - "evidence": "2 rounds vs SpinBot: scans=1127 bulletsFired=74 bulletHits=15 bulletMisses=56 bulletHitBullets=1 hitsTaken=0; result unknown" + "botdir": "legacy_bots/Ascendant", + "evidence": "2 rounds vs SpinBot: scans=1127 bulletsFired=74 bulletHits=15 bulletMisses=56 bulletHitBullets=1 hitsTaken=0; result unknown", + "sha256": "66705bfbd6daa2b1f7470e9e17846a238b752fc3829227ddc7e67612c33117ff" }, { "name": "DiamondHawk", "main_class": "wiki.DiamondHawk", - "jar": "/tmp/bots/wiki.DiamondHawk_1.02.jar", + "jar": "legacy_bots/DiamondHawk/DiamondHawk.jar", "version": "1.02", "style": "pattern matcher", "status": "WORKS", "obtained": "downloaded jar", "source_url": "http://robocode-archive.strangeautomata.com/robots/wiki.DiamondHawk_1.02.jar", "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/DiamondHawk", - "evidence": "2 rounds vs SpinBot: scans=703 bulletsFired=45 bulletHits=18 bulletMisses=22 bulletHitBullets=1 hitsTaken=0; result unknown" + "botdir": "legacy_bots/DiamondHawk", + "evidence": "2 rounds vs SpinBot: scans=703 bulletsFired=45 bulletHits=18 bulletMisses=22 bulletHitBullets=1 hitsTaken=0; result unknown", + "sha256": "00cba8a7df53e234aee4a9531bebd5f96dffc5488f6e733f877ce513b5d32d7f" }, { "name": "YersiniaPestis", "main_class": "zyx.mega.YersiniaPestis", - "jar": "/tmp/bots/zyx.mega.YersiniaPestis_4.0.jar", + "jar": "legacy_bots/YersiniaPestis/YersiniaPestis.jar", "version": "4.0", "style": "strong aggressive 1v1 mega", "status": "WORKS", "obtained": "downloaded jar", "source_url": "http://robocode-archive.strangeautomata.com/robots/zyx.mega.YersiniaPestis_4.0.jar", "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/YersiniaPestis", - "evidence": "2 rounds vs SpinBot: scans=842 bulletsFired=52 bulletHits=12 bulletMisses=38 bulletHitBullets=0 hitsTaken=0; result unknown" + "botdir": "legacy_bots/YersiniaPestis", + "evidence": "2 rounds vs SpinBot: scans=842 bulletsFired=52 bulletHits=12 bulletMisses=38 bulletHitBullets=0 hitsTaken=0; result unknown", + "sha256": "946cd4238f72e7e51473b610d21182cdbdba4513dd6bebc38064e9ed1bb601d1" }, { "name": "HawkOnFire", "main_class": "rz.HawkOnFire", - "jar": "/tmp/bots/rz.HawkOnFire_0.1.jar", + "jar": "legacy_bots/HawkOnFire/HawkOnFire.jar", "version": "0.1", "style": "corner camper / low bot", "status": "WORKS", "obtained": "downloaded jar", "source_url": "http://robocode-archive.strangeautomata.com/robots/rz.HawkOnFire_0.1.jar", "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/HawkOnFire", - "evidence": "2 rounds vs SpinBot: scans=1152 bulletsFired=74 bulletHits=12 bulletMisses=56 bulletHitBullets=0 hitsTaken=0; result unknown" + "botdir": "legacy_bots/HawkOnFire", + "evidence": "2 rounds vs SpinBot: scans=1152 bulletsFired=74 bulletHits=12 bulletMisses=56 bulletHitBullets=0 hitsTaken=0; result unknown", + "sha256": "e3ed9189afd9a2567167399ff04f49a7f184a07967815a947f3e25d91ffdf4d4" }, { "name": "WallAvoider", "main_class": "sp.Micros.WallAvoider", - "jar": "/tmp/bots/sp.Micros.WallAvoider_1.0.jar", + "jar": "legacy_bots/WallAvoider/WallAvoider.jar", "version": "1.0", "style": "micro wall-avoider (blocking Robot style)", "status": "WORKS", "obtained": "downloaded jar", "source_url": "http://robocode-archive.strangeautomata.com/robots/sp.Micros.WallAvoider_1.0.jar", "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/WallAvoider", - "evidence": "2 rounds vs SpinBot: scans=718 bulletsFired=47 bulletHits=10 bulletMisses=33 bulletHitBullets=0 hitsTaken=1; result unknown" + "botdir": "legacy_bots/WallAvoider", + "evidence": "2 rounds vs SpinBot: scans=718 bulletsFired=47 bulletHits=10 bulletMisses=33 bulletHitBullets=0 hitsTaken=1; result unknown", + "sha256": "eb5e2baa4039bcb1a35123d3503ddb23c3b12915ae41fe2a6199d1b1b678e99b" }, { "name": "Cigaret", "main_class": "cx.mini.Cigaret", - "jar": "/tmp/bots/cx.mini.Cigaret_1.31.jar", + "jar": "legacy_bots/Cigaret/Cigaret.jar", "version": "1.31", "style": "mini surfer", "status": "WORKS", "obtained": "downloaded jar", "source_url": "http://robocode-archive.strangeautomata.com/robots/cx.mini.Cigaret_1.31.jar", "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/Cigaret", - "evidence": "2 rounds vs SpinBot: scans=266 bulletsFired=46 bulletHits=5 bulletMisses=37 bulletHitBullets=0 hitsTaken=5; result unknown" + "botdir": "legacy_bots/Cigaret", + "evidence": "2 rounds vs SpinBot: scans=266 bulletsFired=46 bulletHits=5 bulletMisses=37 bulletHitBullets=0 hitsTaken=5; result unknown", + "sha256": "273c4194d1b9f0687173158276802ff3456ec8343de62e80d2674e0960715612" }, { "name": "CigaretBH", "main_class": "cx.CigaretBH", - "jar": "/tmp/bots/cx.CigaretBH_1.03.jar", + "jar": "legacy_bots/CigaretBH/CigaretBH.jar", "version": "1.03", "style": "mini bullet-hiding surfer", "status": "WORKS", "obtained": "downloaded jar", "source_url": "http://robocode-archive.strangeautomata.com/robots/cx.CigaretBH_1.03.jar", "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/CigaretBH", - "evidence": "2 rounds vs SpinBot: scans=237 bulletsFired=67 bulletHits=11 bulletMisses=53 bulletHitBullets=0 hitsTaken=3; result unknown" + "botdir": "legacy_bots/CigaretBH", + "evidence": "2 rounds vs SpinBot: scans=237 bulletsFired=67 bulletHits=11 bulletMisses=53 bulletHitBullets=0 hitsTaken=3; result unknown", + "sha256": "8c107a759b229f8570dcce96ccedd8404545e7d3c6441a206c64d54a4209d678" }, { "name": "Komarious", "main_class": "voidious.mini.Komarious", - "jar": "/tmp/bots/voidious.mini.Komarious_1.88.jar", + "jar": "legacy_bots/Komarious/Komarious.jar", "version": "1.88", "style": "mini pattern matcher / surfer", "status": "WORKS", "obtained": "downloaded jar", "source_url": "http://robocode-archive.strangeautomata.com/robots/voidious.mini.Komarious_1.88.jar", "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/Komarious", - "evidence": "2 rounds vs SpinBot: scans=134 bulletsFired=62 bulletHits=20 bulletMisses=36 bulletHitBullets=1 hitsTaken=10; result unknown" + "botdir": "legacy_bots/Komarious", + "evidence": "2 rounds vs SpinBot: scans=134 bulletsFired=62 bulletHits=20 bulletMisses=36 bulletHitBullets=1 hitsTaken=10; result unknown", + "sha256": "9bf0946f16256650455217df27183b8f3a5715954ab37c58b64e327af26d4593" }, { "name": "LionWWSVMvoid", "main_class": "sqTank.waveSurfing.LionWWSVMvoid", - "jar": "/tmp/bots/sqTank.waveSurfing.LionWWSVMvoid_0.01.jar", + "jar": "legacy_bots/LionWWSVMvoid/LionWWSVMvoid.jar", "version": "0.01", "style": "wave-surfing SVM gun", "status": "WORKS", "obtained": "downloaded jar", "source_url": "http://robocode-archive.strangeautomata.com/robots/sqTank.waveSurfing.LionWWSVMvoid_0.01.jar", "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/LionWWSVMvoid", - "evidence": "2 rounds vs SpinBot: scans=137 bulletsFired=62 bulletHits=12 bulletMisses=45 bulletHitBullets=0 hitsTaken=12; result unknown" - }, - { - "name": "FloodMini", - "main_class": "kawigi.sbf.FloodMini", - "jar": "/tmp/bots/kawigi.sbf.FloodMini_1.4.jar", - "version": "1.4", - "style": "mini flood-fill movement", - "status": "WORKS_WEAK", - "obtained": "downloaded jar", - "source_url": "http://robocode-archive.strangeautomata.com/robots/kawigi.sbf.FloodMini_1.4.jar", - "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/FloodMini", - "evidence": "2 rounds vs SpinBot: scans=94 bulletsFired=25 bulletHits=0 bulletMisses=23 bulletHitBullets=0 hitsTaken=10; result unknown", - "note": "battle completes and the bot scans/fires, but it landed 0 hits vs SpinBot and lost both rounds; treat as a weak/possibly-degraded sparring partner, not a champion." - }, - { - "name": "Aristocles", - "main_class": "pez.micro.Aristocles", - "jar": "/tmp/bots/pez.micro.Aristocles_0.3.9.jar", - "version": "0.3.9", - "style": "micro surfer", - "status": "WORKS_WEAK", - "obtained": "downloaded jar", - "source_url": "http://robocode-archive.strangeautomata.com/robots/pez.micro.Aristocles_0.3.9.jar", - "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/Aristocles", - "evidence": "2 rounds vs SpinBot: scans=89 bulletsFired=39 bulletHits=0 bulletMisses=38 bulletHitBullets=0 hitsTaken=10; result unknown", - "note": "battle completes and the bot scans/fires, but it landed 0 hits vs SpinBot and lost both rounds; treat as a weak/possibly-degraded sparring partner, not a champion." + "botdir": "legacy_bots/LionWWSVMvoid", + "evidence": "2 rounds vs SpinBot: scans=137 bulletsFired=62 bulletHits=12 bulletMisses=45 bulletHitBullets=0 hitsTaken=12; result unknown", + "sha256": "a001c2404157bab122e0dbe312e33e79322ce0ddae55d9ab660def1c80bff7a6" }, { "name": "PatternRobot", "main_class": "stelo.PatternRobot", - "jar": "/tmp/bots/stelo.PatternRobot_1.0.jar", + "jar": "legacy_bots/PatternRobot/PatternRobot.jar", "version": "1.0", "style": "simple pattern robot (blocking Robot style)", "status": "WORKS_WEAK", "obtained": "downloaded jar", "source_url": "http://robocode-archive.strangeautomata.com/robots/stelo.PatternRobot_1.0.jar", "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/PatternRobot", + "botdir": "legacy_bots/PatternRobot", "evidence": "2 rounds vs SpinBot: scans=220 bulletsFired=8 bulletHits=0 bulletMisses=6 bulletHitBullets=0 hitsTaken=2; result unknown", - "note": "battle completes and the bot scans/fires, but it landed 0 hits vs SpinBot and lost both rounds; treat as a weak/possibly-degraded sparring partner, not a champion." - }, - { - "name": "LightningBug", - "main_class": "ry.LightningBug", - "jar": "/tmp/bots/ry.LightningBug_1.0.jar", - "version": "1.0", - "style": "pattern matcher", - "status": "WORKS_WEAK", - "obtained": "downloaded jar", - "source_url": "http://robocode-archive.strangeautomata.com/robots/ry.LightningBug_1.0.jar", - "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/LightningBug", - "evidence": "2 rounds vs SpinBot: scans=80 bulletsFired=36 bulletHits=0 bulletMisses=31 bulletHitBullets=0 hitsTaken=10; result unknown", - "note": "battle completes and the bot scans/fires, but it landed 0 hits vs SpinBot and lost both rounds; treat as a weak/possibly-degraded sparring partner, not a champion." - }, - { - "name": "Aurora", - "main_class": "dmp.micro.Aurora", - "jar": "/tmp/bots/dmp.micro.Aurora_1.41.jar", - "version": "1.41", - "style": "micro (team-derived base)", - "status": "WORKS_WEAK", - "obtained": "downloaded jar", - "source_url": "http://robocode-archive.strangeautomata.com/robots/dmp.micro.Aurora_1.41.jar", - "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/Aurora", - "evidence": "2 rounds vs SpinBot: scans=69 bulletsFired=6 bulletHits=0 bulletMisses=6 bulletHitBullets=0 hitsTaken=13; result unknown", - "note": "battle completes and the bot scans/fires, but it landed 0 hits vs SpinBot and lost both rounds; treat as a weak/possibly-degraded sparring partner, not a champion." - }, - { - "name": "Nene", - "main_class": "cs.Nene", - "jar": "/tmp/bots/cs.Nene_N0.jar", - "version": "N0", - "style": "melee (Azuma framework)", - "status": "FAILS", - "obtained": "downloaded jar", - "source_url": "http://robocode-archive.strangeautomata.com/robots/cs.Nene_N0.jar", - "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/Nene", - "evidence": "2 rounds vs SpinBot: scans=0 bulletsFired=0 bulletHits=0 bulletMisses=0 bulletHitBullets=0 hitsTaken=14; result unknown", - "note": "battle completes but the bot is inert (0 scans, 0 shots). See missing_api.", - "missing_api": "getRobotRunnable() returns null: the Azuma framework implements robocode.robotinterfaces.IBasicRobot/ITeamRobot directly (cs.Azuma extends java.io.PrintStream) instead of extending robocode.Robot, and returns null from getRobotRunnable(); the bridge has no driver path for that. SmokeTest also throws ArithmeticException (divide by zero) for cs.Nene." - }, - { - "name": "Seraphim", - "main_class": "cs.s3.Seraphim", - "jar": "/tmp/bots/cs.s3.Seraphim_3.0.jar", - "version": "3.0", - "style": "melee (Azuma framework)", - "status": "FAILS", - "obtained": "downloaded jar", - "source_url": "http://robocode-archive.strangeautomata.com/robots/cs.s3.Seraphim_3.0.jar", - "license": "not stated in jar (RoboRumble archive distribution)", - "botdir": "/tmp/tr_bots/Seraphim", - "evidence": "2 rounds vs SpinBot: scans=0 bulletsFired=0 bulletHits=0 bulletMisses=0 bulletHitBullets=0 hitsTaken=14; result unknown", - "note": "battle completes but the bot is inert (0 scans, 0 shots). See missing_api.", - "missing_api": "getRobotRunnable() returns null: the Azuma framework implements robocode.robotinterfaces.IBasicRobot/ITeamRobot directly (cs.Azuma extends java.io.PrintStream) instead of extending robocode.Robot, and returns null from getRobotRunnable(); the bridge has no driver path for that. SmokeTest also throws ArithmeticException (divide by zero) for cs.Nene." + "note": "battle completes and the bot scans/fires, but it landed 0 hits vs SpinBot and lost both rounds; treat as a weak/possibly-degraded sparring partner, not a champion.", + "sha256": "be89fcf05353666ee404daa00dc092c918c2fcd1bfdbdf5f4b55b1f5b766f248" } - ] + ], + "status_legend": { + "WORKS": "fires and moves in a real battle", + "WORKS_WEAK": "launches and fires but barely moves or lands no hits", + "NOT_USEFUL": "launches but is inert or does not move - measured, then DELETED from legacy_bots/, from tr_bots/_salvage/ and from this file (Nene, Seraphim, Aurora, FloodMini, LightningBug, Aristocles)", + "REFERENCE": "DrussGT, the reference bot; lives in tr_bots/DrussGT" + } } diff --git a/tools/robocode_shim/run_bridge_battle.sh b/tools/robocode_shim/run_bridge_battle.sh index 5da328f..66df600 100755 --- a/tools/robocode_shim/run_bridge_battle.sh +++ b/tools/robocode_shim/run_bridge_battle.sh @@ -36,7 +36,7 @@ if [[ -n "${SHIM_BOTDIR:-}" ]]; then 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_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 diff --git a/tools/robocode_shim/run_smoke.sh b/tools/robocode_shim/run_smoke.sh index 97da018..2c71024 100755 --- a/tools/robocode_shim/run_smoke.sh +++ b/tools/robocode_shim/run_smoke.sh @@ -9,7 +9,7 @@ set -euo pipefail HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROBOCODE_JAR="${ROBOCODE_JAR:-/tmp/robocode/install/libs/robocode.jar}" -JAR="${SHIM_BOT_JAR:-${DRUSSGT_JAR:-/tmp/drussgt/DrussGT.jar}}" +JAR="${SHIM_BOT_JAR:-${DRUSSGT_JAR:-$HERE/vendor/drussgt/DrussGT.jar}}" CLASS="${SHIM_BOT_CLASS:-jk.mega.DrussGT}" OUT="${OUT:-$HERE/out}" diff --git a/tools/robocode_shim/vendor/drussgt/DrussGT.jar b/tools/robocode_shim/vendor/drussgt/DrussGT.jar new file mode 100644 index 0000000..fe094fd Binary files /dev/null and b/tools/robocode_shim/vendor/drussgt/DrussGT.jar differ diff --git a/tools/robocode_shim/vendor/drussgt/MANIFEST.sha256 b/tools/robocode_shim/vendor/drussgt/MANIFEST.sha256 new file mode 100644 index 0000000..8a9ab1c --- /dev/null +++ b/tools/robocode_shim/vendor/drussgt/MANIFEST.sha256 @@ -0,0 +1,24 @@ +11b65c349e820c93d5f893c63c96b053e72e621041e1f5630c761a35a3cec092 src/jk/math/FastTrig.java +ad400156bb011f340d1d9a1f1bd22d5928c0e3861cb910b4a05fe1c9607223f7 src/jk/mega/BufferManager.java +325976eeb168e4c4b3e14e5dfc4cb4175a613dd0071d426aaaa9be38aad55626 src/jk/mega/BulletPowerPredictor.java +eab6c649ab0dc5690830e53118d77b68cc8e48453f24a723d33a4e6524ec0372 src/jk/mega/DataToGun.java +3bce4e894140a4b78cbb391ee4bdc73fd35f0683665ecee586bceeb597ba190e src/jk/mega/dGun/DrussGunDC.java +49d987a9e2e7b06eb3882ccdfa3181d4fe0e12c71383a1a74340c3d598a95572 src/jk/mega/dGun/GFRange.java +fc15ac5b0e1f1babbf217f7e879ec8f4b2ca5753d5907fce353f5a84da1c6c94 src/jk/mega/dGun/Indice.java +3bcb6b78937ad2cf091ecb1b23c18bf868df9ec12b53a7afe134e8525e703617 src/jk/mega/dGun/PreciseMinMaxGFs.java +13134d7a94ffaf879ff3fc611c1ba7ec3b200a50851cf4198faae675f8b68f35 src/jk/mega/dMove/BulletTracker.java +df3720d46bf6af184e441580b1856f5001f1c40549c463fa2ebf976e0dbbaef7 src/jk/mega/dMove/DrussMoveGT.java +0199f53106ae375f5f49c9ba2ec087d17fad69c845be8912e8ecbc8caeccd169 src/jk/mega/dMove/EnemyWave.java +b20f9676d6dd42edc149ece3b8f16fb404ed7a1d6f4998b61b98abc09a599f5d src/jk/mega/dMove/MovePredictor.java +c984e53b0b27e40bcd3f93dd1725948415b15fa5038cc10d68737eb4e664d259 src/jk/mega/dMove/PlaceTime.java +35710e70c77866b999c64ef99bedba0434e0a3fcd5ef5ad4d962146127680ad3 src/jk/mega/dMove/PredictionStatus.java +625e6dc21832f989d2b72eba12727afbc80692ad9b9ebaeb12914a5ea7277fd8 src/jk/mega/DrussGT.java +1f5bd8d4a795d998d12703eb80ac400889cb07658beb7018105151873d266819 src/jk/mega/DrussGT.properties +680e6c1dbe1223f5a46ffcc30c00256814d9f93ec3e08f862f6ff3be057800e6 src/jk/mega/EnemyMoves.java +b282982dcfa3538791330552296ec0f5a8feb76cae8f1536b8153dd29ffdc2aa src/jk/mega/Insulter.java +8639bde1d0a981a3cc5b2753947ad7f3ea44134089659f1e78feb01e6794074d src/jk/melee/MeleeRadar.java +343468158365df1374f96a48e3022612f3db9166579124595d696262d86f24a8 src/jk/precise/EnergyDomeWorker.java +e2dac75359c776801f27b9c8df9ec31989d57ada3ae854ae0f1e3576329cd9bf src/jk/precise/util/PreciseUtils.java +a88ccec73415e0dd3d47acaab423688038d226e1909b90ca5a9d852f2939a800 src/jk/precise/util/PreciseWave.java +9ad7811c7163d8557ab3c5d8c71dd3b46a5888f1a848c1578177c17003ffcccf src/jk/tree/KDTree.java +ba9672a543bbda3f8ed419bb51a59aab764d975e67e232cecd256658b2d1cab0 src/META-INF/MANIFEST.MF diff --git a/tools/robocode_shim/vendor/drussgt/README.md b/tools/robocode_shim/vendor/drussgt/README.md new file mode 100644 index 0000000..86f611a --- /dev/null +++ b/tools/robocode_shim/vendor/drussgt/README.md @@ -0,0 +1,72 @@ +# DrussGT — vendored decompiled source + +## What this is + +`src/` is **DECOMPILED Java source**, recovered by a Java decompiler (CFR/Procyon-class +output) from the compiled `DrussGT.jar` competitive Robocode bot by "jk" (DrussGT 2.0, +the Dr. Bloodmoney/G2000 lineage). + +**It is NOT the original author's source.** No debug symbols, comments, or original +method names survive; identifiers are decompiler-reconstructed and may be renamed, +reordered, or inlined. Do not treat it as a reference implementation for style, and do +not "fix up" it as if it were authored code. + +## Where it came from + +- Recovered into `/tmp/drussgt/src/` (also present byte-identically as + `/tmp/portaudit/src/` and `/tmp/DrussGT_extracted/`; a near-copy with one patched + file lives at `/tmp/dbg_src/`). +- Copied into this repo at `tools/robocode_shim/vendor/drussgt/src/` so that a rebuild + never depends on `/tmp`, which is wiped on reboot. +- `MANIFEST.sha256` records the exact contents; verify with + `sha256sum -c MANIFEST.sha256` from this directory. + +`src/` contains 67 files: **22 `.java`** files plus the decompiler-emitted `.class` +files that were left alongside them. The `.class` files are gitignored (root +`.gitignore` rule `*.class`) and are *not* the build input — `DrussGT.jar` supplies +them. + +## Packages contained + +| Package | Files | +|---|---| +| `jk.mega` | `DrussGT.java` (main bot), `BulletPowerPredictor`, `DataToGun`, `BufferManager`, `EnemyMoves`, `Insulter` | +| `jk.mega.dGun` | `DrussGunDC`, `GFRange`, `Indice`, `PreciseMinMaxGFs` | +| `jk.mega.dMove` | `DrussMoveGT`, `MovePredictor`, `BulletTracker`, `EnemyWave`, `PlaceTime`, `PredictionStatus` | +| `jk.melee` | `MeleeRadar` | +| `jk.precise` + `jk.precise.util` | `EnergyDomeWorker`, `PreciseUtils`, `PreciseWave` | +| `jk.tree` | `KDTree` | +| `jk.math` | `FastTrig` | + +## Provenance and licensing caveat + +DrussGT is third-party, GPL-licensed competitive-bot code by an external author. It is +vendored here **for interoperability/port analysis only**. The upstream +`DrussGT.jar` itself is deliberately *not* committed to this repo (see +`tools/robocode_shim/.gitignore`, rule `*.jar`) — it must be obtained separately from +the upstream distribution and passed via the `DRUSSGT_JAR` environment variable. + +Redistributing this decompiled source, like the original, carries the same GPL +obligation as the upstream bot. Check the upstream terms before publishing anything +derived from it. + +## Relationship to `DrussGT.jar` and `compile_drussgt.sh` + +`compile_drussgt.sh` rebuilds DrussGT from these sources against the genuine +Robocode API. Its defaults are all in-repo: + +- `ROBOCODE_JAR` -> `vendor/robocode.jar` +- `DRUSSGT_SRC` -> `vendor/drussgt/src` (this directory's `src/`) +- `DRUSSGT_JAR` -> `vendor/drussgt/DrussGT.jar` (must exist locally; not tracked) +- output -> `out/drussgt/` + +Two files are deliberately excluded from the javac invocation: `jk/mega/dGun/GFRange.java` +and `jk/mega/dGun/Indice.java`. The same two classes are also declared inline at the +bottom of `DrussGunDC.java`, so compiling all 22 files fails with `duplicate class`. +The jar already ships them, so the build lets the jar supply those two plus the six +genuinely-unsourced classes (`JKDCUtils`, `NormalDistribution`, `StoreScan`, +`DCRobotState`, `DCWave`, `Scan`). + +Run it with: + + ROBOCODE_JAR=vendor/robocode.jar ./compile_drussgt.sh \ No newline at end of file diff --git a/tools/robocode_shim/vendor/drussgt/src/META-INF/MANIFEST.MF b/tools/robocode_shim/vendor/drussgt/src/META-INF/MANIFEST.MF new file mode 100644 index 0000000..721056f --- /dev/null +++ b/tools/robocode_shim/vendor/drussgt/src/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +robots: jk.mega.DrussGT + diff --git a/tools/robocode_shim/vendor/drussgt/src/jk/math/FastTrig.java b/tools/robocode_shim/vendor/drussgt/src/jk/math/FastTrig.java new file mode 100644 index 0000000..2f9a4c2 --- /dev/null +++ b/tools/robocode_shim/vendor/drussgt/src/jk/math/FastTrig.java @@ -0,0 +1,194 @@ +package jk.math; + +public class FastTrig { + public static final double PI = 3.1415926535897932384626433832795D; + public static final double TWO_PI = 6.2831853071795864769252867665590D; + public static final double HALF_PI = 1.5707963267948966192313216916398D; + public static final double QUARTER_PI = 0.7853981633974483096156608458199D; + public static final double THREE_OVER_TWO_PI + = 4.7123889803846898576939650749193D; + + + public static void main(String[] args){ + //accuracy test + double maxdiff = 0; + double sum = 0; + double dv = 0; + for(int i = 0; i < 500000; i++){ + double p = (i-250000)*(1.571/250000); + double diff = Math.abs((Math.atan(p) - atan(p))); + sum += diff; + if(diff > maxdiff){ + maxdiff = diff; + dv = p; + } + } + System.out.println(maxdiff); + System.out.println(dv); + System.out.println(sum); + } + public static final double sin(double d) { + d += Math.PI; + double x2 = Math.floor(d*(1/(2*Math.PI))); + d -= x2*(2*Math.PI); + d-=Math.PI; + + x2 = d * d; + + + return //accurate to 6.82e-8, 3.3x faster than Math.sin, + //faster than lookup table in real-world conditions due to no cache misses + //all values from "Fast Polynomial Approximations to Sine and Cosine", Garret, C. K., 2012 + (((((-2.05342856289746600727e-08*x2 + 2.70405218307799040084e-06)*x2 + - 1.98125763417806681909e-04)*x2 + 8.33255814755188010464e-03)*x2 + - 1.66665772196961623983e-01)*x2 + 9.99999707044156546685e-01)*d; + } + + + public static final double cos(double d) { + d += Math.PI; + double x2 = Math.floor(d*(1/(2*Math.PI))); + d -= x2*(2*Math.PI); + d-=Math.PI; + + d *= d; + + return //max error 5.6e-7, 4x faster than Math.cos, + //faster than lookup table in real-world conditions due to less cache misses + //all values from "Fast Polynomial Approximations to Sine and Cosine", Garret, C. K., 2012 + ((((- 2.21941782786353727022e-07*d + 2.42532401381033027481e-05)*d + - 1.38627507062573673756e-03)*d + 4.16610337354021107429e-02)*d + - 4.99995582499065048420e-01)*d + 1; + } + + public static final double sinInBounds(double d) { + double x2 = d * d; + + return //accurate to 6.82e-8, better than 3.3x faster than Math.sin, + //faster than lookup table in real-world conditions due to less cache misses + //all values from "Fast Polynomial Approximations to Sine and Cosine", Garret, C. K., 2012 + (((((-2.05342856289746600727e-08*x2 + 2.70405218307799040084e-06)*x2 + - 1.98125763417806681909e-04)*x2 + 8.33255814755188010464e-03)*x2 + - 1.66665772196961623983e-01)*x2 + 9.99999707044156546685e-01)*d; + } + + public static final double cosInBounds(double d) { + + d *= d; + + return //max error 5.6e-7, better than 4x faster than Math.cos, + //faster than lookup table in real-world conditions due to less cache misses + //all values from "Fast Polynomial Approximations to Sine and Cosine", Garret, C. K., 2012 + ((((- 2.21941782786353727022e-07*d + 2.42532401381033027481e-05)*d + - 1.38627507062573673756e-03)*d + 4.16610337354021107429e-02)*d + - 4.99995582499065048420e-01)*d + 9.99999443739537210853e-01; + } + +//Takes about 1/3 of the time of Math.tan +//chebyshev polynomials calculated with http://metamerist.com/cheby/example38.htm + public static final double tan(double x) { + x += HALF_PI; + double i = Math.floor(x*(1/Math.PI)); + x -= i*(Math.PI) + HALF_PI; + + if(Math.abs(x) > 0.25*Math.PI){ + x = Math.signum(x)*HALF_PI - x; + i = x*x; + return 1/(x * ( 1 + + i * ( 0.33555055109755784988404247864565 + + i * ( 0.11611832804825573745353974789374 + + i * ( 0.0939748057591306776926771332915))))); + } + + i = x*x; + return + x * ( 1 + + i * ( 0.33555055109755784988404247864565 + + i * ( 0.11611832804825573745353974789374 + + i * ( 0.0939748057591306776926771332915)))); + + } + + public static final double floor(double value){ + double d = (long)value; + if(value > 0) + return d; + if(value == d) + return d; + return d - 1; + } + + public static final double asin(double value) { + //return atan(x / Math.sqrt(1 - x*x)); + return HALF_PI - acos(value); + } + + public static final double acos(double x){ + final double a = 1.570758334, b = -0.212875075, c = 0.076897503, d = -0.020892330; + if(x<0) + return Math.PI-Math.sqrt(1+x)*(a-x*(b-x*(c-x*d))); + return Math.sqrt(1-x)*(a+x*(b+x*(c+x*d))); + } + + + //works on range 0 to 1 only! + private static final double chebyshev_atan(double x) { + // map x to range [-1, 1] + final double xn = x * 2 -1; + + // return Chebyshev approximation + return 0.46364760900080604 + + xn * ( 0.4005785601195767 + + xn * ( -0.07982248463207417 + + xn * ( -0.007789235359791622 + + xn * ( 0.00891247504621044)))); + } + + public static final double atan(double r) { + if (r < 0.0) + return -atan(-r); + if (r > 1.0) + return HALF_PI - chebyshev_atan(1.0 / r); + return chebyshev_atan(r); + } + + public static final double atan2(final double y, final double x) { + if (x==0.0) { + if (y==0.0) + return 0.0; // should be Double.NaN but Math.atan2 returns 0.0 in this case; + return (y > 0.0) ? HALF_PI : -HALF_PI; + } + double absX = Math.abs(x); + double absY = Math.abs(y); + + double absAtan; + if(absY > absX) + absAtan = HALF_PI - chebyshev_atan(absX/absY); + else + absAtan = chebyshev_atan(absY/absX); + + if(x < 0) + absAtan = PI - absAtan; + + if(y < 0) + return -absAtan; + + return absAtan; + + } + public static final double sqrt(double x){ + return Math.sqrt(x); + //return x * (1.5d - 0.5*x* (x = Double.longBitsToDouble(0x5fe6ec85e7de30daL - (Double.doubleToLongBits(x)>>1) )) *x) * x; + } + public static final double normalRelativeAngle(double d){ + d += Math.PI; + double i = Math.floor(d*(1./(2.*Math.PI))); + d -= i*(2.*Math.PI); + return d-Math.PI; + } + public static final double normalAbsoluteAngle(double d){ + double i = Math.floor(d*(1./(2.*Math.PI))); + d -= i*(2.*Math.PI); + return d; + } +} \ No newline at end of file diff --git a/tools/robocode_shim/vendor/drussgt/src/jk/mega/BufferManager.java b/tools/robocode_shim/vendor/drussgt/src/jk/mega/BufferManager.java new file mode 100644 index 0000000..680eeb2 --- /dev/null +++ b/tools/robocode_shim/vendor/drussgt/src/jk/mega/BufferManager.java @@ -0,0 +1,653 @@ +package jk.mega; + +import java.util.*; + +public class BufferManager { + + //Featuring "Slice retrieval indexes" + static final float[] empty = {}; + + static final float[] velSlicesRough = {2.01f ,4.01f ,6.01f}; + static final float[] velSlices = {1.01f ,3.01f ,5.01f ,7.01f}; + static final float[] velSlicesFine = {0.5f, 1.5f ,2.5f ,3.5f ,4.5f ,5.5f ,6.5f ,7.5f}; + + static final float[] advVelSlicesRough = {-4.01f,-2.01f,1.51f}; + static final float[] advVelSlices = {-5f, -3f, -1f, 2f}; + static final float[] advVelSlicesFine = {-6.5f, -5f, -3.5f, -2f, -0.5f, 0.5f, 2f, 4f}; + + static final float[] bftSlicesRough = {20f ,40f ,60f}; + static final float[] bftSlices = {15f , 30f , 45f , 65f}; + static final float[] bftSlicesFine = {6f , 10f , 25f , 34f , 42f , 50f , 58f , 66f}; + + static final float[] tsdcSlicesRough = {0.25f ,0.5f ,0.75f, 1f, 1.25f,1.5f,1.75f}; + static final float[] tsdcSlices = {0.2f ,0.4f ,0.6f ,0.8f, 1f, 1.2f, 1.4f, 1.6f,1.8f}; + static final float[] tsdcSlicesFine = {0.1f ,0.2f ,0.3f ,0.4f ,0.5f ,0.6f ,0.8f, 0.9f, 1f, 1.1f, 1.2f, 1.3f,1.4f,1.5f}; + + static final float[] accelSlices = {-0.4f ,0.4f}; + static final float[] accelSlicesFine = {-2.1f, -1.9f, 0.9f, 1.1f}; + + static final float[] tsvcSlicesRough = {0.15f ,0.357f ,0.75f, 0.9f, 1.2f}; + static final float[] tsvcSlices = {0.1f ,0.2f ,0.4f ,0.8f, 0.92f, 1.0f}; + static final float[] tsvcSlicesFine = {0.05f ,0.1f ,0.16f ,0.2f ,0.4f ,0.6f ,0.85f, 0.96f, 1.1f, 1.3f}; + + static final float[] dl10SlicesRough = {20f ,50f ,80f}; + static final float[] dl10Slices = {10f ,20f ,35f ,50f ,68f ,85f}; + static final float[] dl10SlicesFine = {5f, 15f , 25f, 35f, 45f, 55f ,65f ,75f ,85f, 95f}; + + static final float[] wallSlicesRough = {0.33f , 0.66f, 1f}; + static final float[] wallSlices = {0.25f , 0.5f , 0.75f, 1.1f}; + + public static ArrayList getStatBuffers(){ + ArrayList statBuffers = new ArrayList(120); + final float[][][] sets = new float[][][] { + //empty + {empty, empty, empty, empty, empty, empty, empty, empty, empty}, + + //simple + {velSlices, advVelSlicesRough, bftSlicesRough, empty, empty, empty, empty, empty, empty}, + {empty, advVelSlices, bftSlicesFine, empty, empty, empty, empty, empty, empty}, + {empty, advVelSlicesFine, bftSlicesFine, empty, empty, empty, empty, empty, empty}, + {velSlicesRough, advVelSlicesFine, empty, empty, empty, empty, empty, empty, empty}, + {velSlicesRough, empty, empty, empty, empty, empty, empty, empty, empty}, + {empty, advVelSlicesFine, bftSlices, empty, empty, empty, empty, empty, empty}, + {velSlicesRough, advVelSlicesRough, bftSlices, empty, empty, empty, empty, empty, empty}, + {velSlices, empty, bftSlicesRough, empty, empty, empty, empty, empty, empty}, + {velSlices, empty, empty, empty, empty, empty, empty, empty, empty}, + {velSlices, empty, bftSlicesRough, empty, empty, empty, empty, empty, empty}, + {velSlices, advVelSlices, empty, empty, empty, empty, empty, empty, empty}, + {velSlicesFine, empty, bftSlicesRough, empty, empty, empty, empty, empty, empty}, + {velSlicesRough, advVelSlices, bftSlices, empty, empty, empty, empty, empty, empty}, + {velSlicesFine, empty, empty, empty, empty, empty, empty, empty, empty}, + {velSlicesRough, empty, bftSlicesRough, empty, empty, empty, empty, empty, empty}, + {velSlicesRough, empty, bftSlicesRough, empty, empty, empty, empty, empty, empty}, + {empty, advVelSlicesRough, bftSlices, empty, empty, empty, empty, empty, empty}, + {velSlicesRough, advVelSlices, bftSlicesFine, empty, empty, empty, empty, empty, empty}, + {velSlices, advVelSlicesFine, empty, empty, empty, empty, empty, empty, empty}, + {velSlices, empty, empty, empty, empty, empty, empty, empty, empty}, + {velSlices, advVelSlicesRough, empty, empty, empty, empty, empty, empty, empty}, + {velSlices, advVelSlicesRough, empty, empty, empty, empty, empty, empty, empty}, + {velSlicesRough, empty, bftSlices, empty, empty, empty, empty, empty, empty}, + {velSlicesRough, advVelSlicesFine, empty, empty, empty, empty, empty, empty, empty}, + {velSlicesFine, empty, empty, empty, empty, empty, empty, empty, empty}, + {velSlicesRough, advVelSlicesRough, bftSlices, empty, empty, empty, empty, empty, empty}, + {velSlicesFine, advVelSlicesRough, empty, empty, empty, empty, empty, empty, empty}, + {velSlices, advVelSlices, bftSlicesRough, empty, empty, empty, empty, empty, empty}, + {velSlices, empty, bftSlicesRough, empty, empty, empty, empty, empty, empty}, + {empty, advVelSlicesRough, bftSlicesFine, empty, empty, empty, empty, empty, empty}, + + //Anti-PM + {velSlicesRough, advVelSlicesFine, empty, tsdcSlicesFine, empty, empty, dl10Slices, empty, empty}, + {velSlicesRough, advVelSlicesFine, empty, empty, empty, tsvcSlices, dl10SlicesRough, empty, empty}, + {velSlices, advVelSlicesFine, empty, tsdcSlices, empty, tsvcSlicesFine, empty, empty, empty}, + {velSlicesFine, empty, empty, tsdcSlicesFine, accelSlices, tsvcSlicesRough, empty, empty, empty}, + {velSlices, advVelSlicesRough, empty, empty, accelSlices, empty, dl10SlicesFine, empty, empty}, + {velSlicesRough, advVelSlices, empty, tsdcSlicesRough, empty, empty, dl10SlicesRough, empty, empty}, + {velSlicesFine, advVelSlicesRough, empty, empty, empty, tsvcSlices, dl10Slices, empty, empty}, + {empty, advVelSlicesRough, empty, empty, accelSlices, tsvcSlicesRough, dl10Slices, empty, empty}, + {empty, empty, empty, tsdcSlicesFine, accelSlices, tsvcSlicesRough, dl10SlicesFine, empty, empty}, + {velSlicesRough, empty, empty, tsdcSlices, accelSlices, empty, dl10SlicesFine, empty, empty}, + {velSlicesFine, advVelSlices, empty, tsdcSlices, empty, tsvcSlices, empty, empty, empty}, + {velSlicesFine, advVelSlices, empty, tsdcSlices, accelSlices, empty, empty, empty, empty}, + {velSlicesRough, advVelSlicesRough, empty, empty, accelSlices, empty, dl10SlicesRough, empty, empty}, + {velSlicesRough, empty, empty, tsdcSlicesFine, empty, tsvcSlicesRough, dl10SlicesFine, empty, empty}, + {velSlices, empty, empty, tsdcSlicesRough, empty, tsvcSlices, dl10Slices, empty, empty}, + {empty, advVelSlices, empty, tsdcSlicesFine, accelSlices, tsvcSlicesFine, empty, empty, empty}, + {velSlices, advVelSlicesFine, empty, tsdcSlicesFine, accelSlices, empty, empty, empty, empty}, + {velSlicesRough, advVelSlicesRough, empty, empty, accelSlices, tsvcSlicesRough, empty, empty, empty}, + {velSlicesRough, advVelSlicesFine, empty, empty, accelSlices, tsvcSlicesRough, empty, empty, empty}, + {velSlicesRough, advVelSlicesRough, empty, empty, accelSlices, tsvcSlicesRough, empty, empty, empty}, + {velSlicesRough, empty, empty, tsdcSlices, accelSlices, tsvcSlicesRough, empty, empty, empty}, + {velSlicesFine, advVelSlicesFine, empty, tsdcSlices, accelSlices, empty, empty, empty, empty}, + {velSlicesFine, advVelSlicesFine, empty, empty, empty, tsvcSlicesFine, dl10SlicesFine, empty, empty}, + {velSlicesRough, advVelSlices, empty, tsdcSlicesRough, accelSlices, empty, empty, empty, empty}, + {velSlicesRough, advVelSlicesRough, empty, tsdcSlices, empty, tsvcSlicesFine, empty, empty, empty}, + {empty, advVelSlices, empty, tsdcSlices, empty, tsvcSlices, dl10SlicesFine, empty, empty}, + {velSlices, advVelSlices, empty, empty, accelSlices, tsvcSlicesRough, empty, empty, empty}, + {velSlicesFine, advVelSlicesFine, empty, empty, accelSlices, empty, dl10SlicesRough, empty, empty}, + {empty, advVelSlicesRough, empty, tsdcSlicesFine, accelSlices, empty, dl10SlicesRough, empty, empty}, + {velSlicesFine, advVelSlicesRough, empty, tsdcSlicesRough, accelSlices, empty, empty, empty, empty} , + //main + {velSlicesRough, empty, empty, empty, empty, empty, empty, empty, empty}, + {velSlices, empty, empty, empty, empty, empty, empty, empty, empty}, + {velSlicesFine, advVelSlicesFine, empty, empty, empty, tsvcSlices, dl10SlicesRough, empty, empty}, + {velSlices, advVelSlices, bftSlicesFine, empty, accelSlices, empty, empty, wallSlices, empty}, + {velSlicesRough, empty, empty, tsdcSlices, empty, tsvcSlicesFine, dl10Slices, empty, wallSlicesRough}, + {velSlices, advVelSlicesFine, empty, empty, empty, tsvcSlicesFine, empty, wallSlicesRough, empty}, + {velSlicesFine, empty, empty, empty, empty, tsvcSlicesRough, empty, wallSlicesRough, empty}, + {empty, advVelSlicesFine, bftSlicesRough, tsdcSlicesFine, empty, empty, dl10Slices, wallSlicesRough, empty}, + {velSlices, empty, empty, empty, accelSlices, tsvcSlices, empty, wallSlicesRough, empty}, + {velSlicesFine, empty, bftSlices, empty, empty, empty, empty, wallSlicesRough, wallSlicesRough}, + {velSlicesFine, advVelSlicesFine, bftSlicesRough, empty, empty, empty, empty, empty, empty}, + {empty, empty, bftSlices, empty, accelSlices, empty, dl10SlicesFine, wallSlices, empty}, + {empty, advVelSlicesRough, bftSlices, empty, accelSlices, empty, empty, empty, empty}, + {empty, advVelSlices, bftSlicesRough, empty, empty, empty, empty, wallSlicesRough, empty}, + {velSlicesRough, empty, bftSlicesRough, empty, accelSlices, empty, empty, empty, empty}, + {velSlices, advVelSlicesRough, empty, tsdcSlicesRough, empty, empty, empty, wallSlicesRough, wallSlicesRough}, + {velSlicesRough, empty, empty, tsdcSlicesRough, accelSlices, empty, empty, wallSlices, empty}, + {empty, advVelSlicesFine, bftSlices, empty, empty, empty, dl10SlicesFine, wallSlicesRough, empty}, + {velSlices, advVelSlicesFine, bftSlicesRough, tsdcSlicesFine, empty, empty, empty, wallSlicesRough, empty}, + {velSlices, advVelSlicesFine, bftSlicesRough, tsdcSlicesRough, empty, tsvcSlices, empty, empty, empty}, + {velSlicesFine, empty, bftSlices, empty, empty, tsvcSlices, empty, wallSlicesRough, empty}, + {velSlices, advVelSlices, empty, tsdcSlicesFine, accelSlices, empty, empty, empty, wallSlicesRough}, + {velSlicesFine, advVelSlicesFine, empty, empty, accelSlices, tsvcSlicesRough, empty, empty, wallSlicesRough}, + {velSlices, empty, bftSlicesRough, empty, accelSlices, empty, dl10Slices, wallSlicesRough, empty}, + {velSlicesRough, empty, bftSlices, empty, empty, empty, empty, empty, empty}, + {velSlicesFine, advVelSlicesFine, bftSlices, empty, empty, empty, empty, wallSlices, wallSlicesRough}, + {velSlices, empty, bftSlicesRough, tsdcSlicesRough, accelSlices, empty, empty, wallSlicesRough, empty}, + {velSlicesRough, advVelSlicesFine, bftSlices, empty, empty, tsvcSlices, empty, empty, wallSlicesRough}, + {velSlicesRough, advVelSlicesRough, bftSlicesRough, tsdcSlices, empty, empty, empty, empty, wallSlicesRough}, + {velSlicesFine, advVelSlicesRough, empty, empty, empty, tsvcSlicesFine, empty, wallSlices, wallSlicesRough}, + {velSlicesRough, empty, bftSlices, empty, empty, empty, empty, wallSlicesRough, empty}, + {velSlices, empty, bftSlicesFine, tsdcSlicesRough, empty, empty, dl10SlicesFine, wallSlices, empty}, + {empty, advVelSlicesFine, empty, empty, accelSlices, tsvcSlicesFine, empty, empty, empty}, + {empty, empty, bftSlicesRough, tsdcSlices, accelSlices, tsvcSlicesFine, dl10SlicesRough, empty, empty}, + {velSlicesRough, advVelSlicesRough, empty, empty, accelSlices, empty, dl10SlicesRough, empty, wallSlicesRough}, + {empty, advVelSlicesFine, bftSlices, tsdcSlices, empty, tsvcSlicesRough, empty, wallSlicesRough, wallSlicesRough}, + {velSlicesRough, empty, bftSlices, tsdcSlicesFine, empty, empty, empty, empty, empty}, + {velSlicesRough, empty, bftSlicesFine, tsdcSlices, accelSlices, empty, dl10SlicesFine, empty, empty}, + {velSlices, empty, empty, empty, accelSlices, empty, empty, empty, wallSlicesRough}, + {velSlicesFine, empty, bftSlices, empty, empty, tsvcSlicesFine, empty, empty, empty}, + {velSlicesFine, advVelSlices, bftSlicesFine, tsdcSlicesRough, empty, empty, empty, empty, wallSlicesRough}, + {velSlices, advVelSlices, bftSlicesRough, empty, empty, empty, dl10Slices, wallSlices, empty}, + {velSlices, advVelSlicesFine, empty, empty, accelSlices, tsvcSlicesFine, dl10SlicesFine, empty, empty}, + {velSlicesRough, advVelSlicesRough, empty, empty, accelSlices, empty, empty, wallSlices, empty}, + {velSlicesRough, advVelSlicesFine, empty, empty, accelSlices, empty, empty, wallSlices, empty}, + {velSlicesFine, empty, empty, tsdcSlices, empty, tsvcSlicesRough, empty, wallSlicesRough, empty}, + {velSlicesRough, empty, empty, tsdcSlices, empty, empty, dl10Slices, wallSlicesRough, empty}, + {velSlicesRough, advVelSlicesFine, empty, empty, accelSlices, empty, empty, empty, empty}, + {velSlices, advVelSlices, bftSlicesFine, empty, empty, tsvcSlicesFine, empty, empty, empty}, + {velSlices, advVelSlicesRough, empty, empty, empty, tsvcSlicesRough, empty, wallSlicesRough, empty}, + {velSlicesFine, empty, empty, empty, accelSlices, tsvcSlices, dl10SlicesFine, wallSlices, empty}, + {velSlicesRough, advVelSlicesRough, bftSlicesFine, empty, empty, empty, empty, wallSlices, wallSlicesRough}, + {velSlices, advVelSlicesRough, bftSlicesFine, empty, empty, empty, empty, empty, empty}, + {velSlices, empty, bftSlices, empty, accelSlices, tsvcSlicesRough, dl10SlicesFine, empty, empty}, + {velSlicesRough, advVelSlices, bftSlicesRough, empty, empty, empty, empty, wallSlicesRough, empty}, + {empty, empty, bftSlices, empty, empty, empty, dl10SlicesRough, wallSlicesRough, empty}, + {velSlices, empty, bftSlices, tsdcSlicesRough, accelSlices, empty, dl10SlicesFine, empty, empty}, + {empty, advVelSlices, empty, empty, empty, tsvcSlices, dl10Slices, wallSlices, empty}, + {velSlicesFine, empty, empty, tsdcSlices, accelSlices, tsvcSlicesRough, empty, wallSlicesRough, wallSlicesRough}, + {velSlices, advVelSlices, bftSlices, empty, empty, empty, empty, empty, empty}, + {velSlices, advVelSlicesFine, bftSlicesFine, empty, accelSlices, empty, empty, empty, wallSlicesRough}, + {velSlicesRough, empty, bftSlices, empty, accelSlices, empty, empty, wallSlices, wallSlicesRough}, + {velSlicesFine, empty, empty, empty, empty, empty, empty, wallSlices, wallSlicesRough}, + {empty, advVelSlicesFine, bftSlicesRough, empty, empty, tsvcSlicesRough, dl10SlicesRough, empty, wallSlicesRough}, + {velSlices, advVelSlices, bftSlicesRough, empty, empty, tsvcSlicesFine, dl10SlicesFine, wallSlicesRough, empty}, + {velSlices, empty, empty, empty, empty, tsvcSlicesRough, empty, wallSlices, empty}, + {velSlices, advVelSlicesFine, bftSlices, empty, empty, empty, empty, empty, wallSlicesRough}, + {empty, empty, bftSlicesRough, empty, empty, empty, dl10SlicesRough, wallSlicesRough, wallSlicesRough}, + {velSlices, advVelSlicesRough, bftSlicesFine, empty, accelSlices, empty, empty, empty, wallSlicesRough}, + // {velSlicesRough, empty, bftSlicesFine, empty, accelSlices, empty, dl10SlicesFine, wallSlices, empty}, + // {velSlicesFine, empty, empty, tsdcSlicesRough, accelSlices, empty, dl10SlicesRough, wallSlices, empty}, + // {velSlicesFine, advVelSlicesRough, bftSlicesFine, empty, accelSlices, empty, dl10Slices, empty, empty}, + // {velSlices, advVelSlicesRough, empty, tsdcSlices, empty, tsvcSlicesFine, empty, wallSlicesRough, empty}, + // {velSlices, advVelSlices, bftSlicesFine, empty, accelSlices, empty, dl10Slices, empty, empty}, + // {velSlicesRough, empty, bftSlicesFine, tsdcSlicesRough, empty, empty, empty, wallSlices, empty}, + // {velSlices, advVelSlicesFine, bftSlicesFine, tsdcSlicesRough, accelSlices, empty, empty, empty, empty}, + // {empty, empty, bftSlicesRough, tsdcSlices, empty, empty, dl10Slices, wallSlices, wallSlicesRough}, + // {velSlices, empty, bftSlicesFine, empty, empty, empty, empty, wallSlicesRough, empty}, + // {velSlicesFine, advVelSlices, empty, tsdcSlices, empty, empty, empty, wallSlices, empty}, + // {velSlicesRough, advVelSlicesRough, empty, empty, empty, empty, empty, wallSlicesRough, empty}, + // {velSlicesRough, empty, empty, empty, accelSlices, empty, dl10SlicesRough, empty, empty}, + // {velSlicesFine, advVelSlicesFine, empty, empty, accelSlices, tsvcSlicesRough, empty, empty, empty}, + // {velSlices, advVelSlicesFine, empty, empty, empty, empty, dl10SlicesRough, wallSlicesRough, empty}, + // {velSlicesFine, advVelSlicesFine, bftSlicesRough, empty, empty, empty, empty, wallSlicesRough, empty}, + // {velSlicesFine, advVelSlicesRough, bftSlicesRough, empty, empty, empty, dl10Slices, empty, empty}, + // {empty, empty, bftSlicesRough, empty, empty, tsvcSlicesFine, dl10Slices, empty, empty}, + // {empty, advVelSlicesFine, bftSlices, empty, accelSlices, empty, empty, wallSlices, empty}, + // {velSlices, empty, bftSlicesRough, empty, empty, empty, empty, wallSlices, wallSlicesRough}, + // {velSlicesFine, empty, bftSlices, empty, accelSlices, empty, empty, wallSlicesRough, empty}, + // {velSlicesRough, empty, empty, tsdcSlicesFine, accelSlices, empty, empty, wallSlicesRough, empty}, + // {velSlicesFine, empty, empty, empty, accelSlices, empty, empty, wallSlices, empty}, + // {velSlicesRough, empty, bftSlicesRough, empty, empty, tsvcSlicesFine, empty, empty, empty}, + // {empty, empty, bftSlices, empty, accelSlices, empty, dl10SlicesRough, wallSlices, empty}, + // {velSlices, advVelSlicesFine, empty, empty, empty, tsvcSlices, empty, wallSlices, empty}, + // {velSlices, advVelSlicesRough, bftSlicesFine, empty, empty, empty, empty, wallSlices, empty}, + // {velSlices, empty, bftSlices, tsdcSlices, empty, empty, empty, empty, empty}, + // {velSlices, empty, bftSlicesFine, empty, empty, empty, empty, empty, empty}, + // {velSlices, advVelSlicesFine, empty, empty, accelSlices, tsvcSlices, dl10SlicesRough, wallSlices, empty}, + // {velSlicesRough, advVelSlices, bftSlicesFine, tsdcSlices, empty, empty, empty, wallSlicesRough, empty}, + // {velSlices, empty, bftSlicesFine, tsdcSlicesFine, accelSlices, empty, empty, wallSlicesRough, empty}, + // {velSlices, advVelSlices, bftSlices, empty, empty, empty, dl10Slices, wallSlicesRough, empty}, + // {velSlicesFine, empty, empty, empty, accelSlices, empty, empty, wallSlicesRough, empty} + } ; + + putBuffersInto(sets,statBuffers); + + return statBuffers; + } + public static ArrayList getFlattenerBuffers(){ + ArrayList flattenerBuffers = new ArrayList(50); + + float[][][] flatSets = new float[][][] { + {empty, empty, bftSlicesRough, empty, accelSlices, tsvcSlicesRough, empty, wallSlices, wallSlicesRough}, + {empty, advVelSlices, bftSlicesRough, empty, empty, empty, dl10SlicesFine, wallSlicesRough, wallSlicesRough}, + {empty, advVelSlices, empty, empty, accelSlices, tsvcSlicesFine, empty, empty, empty}, + {velSlicesRough, advVelSlicesRough, bftSlicesRough, empty, empty, empty, empty, wallSlicesRough, empty}, + {velSlicesFine, empty, bftSlicesRough, empty, accelSlices, empty, empty, empty, wallSlicesRough}, + {empty, empty, empty, tsdcSlices, empty, tsvcSlicesFine, empty, wallSlices, empty}, + {empty, advVelSlicesFine, bftSlices, tsdcSlicesFine, empty, tsvcSlicesRough, dl10SlicesRough, empty, empty}, + {empty, advVelSlices, empty, empty, accelSlices, empty, empty, wallSlicesRough, empty}, + {velSlicesRough, empty, bftSlicesRough, empty, accelSlices, tsvcSlicesRough, empty, wallSlices, empty}, + {empty, advVelSlices, empty, empty, accelSlices, tsvcSlicesRough, dl10Slices, empty, empty}, + {empty, advVelSlicesRough, bftSlicesFine, empty, accelSlices, empty, dl10SlicesRough, empty, empty}, + {empty, empty, bftSlices, empty, empty, tsvcSlices, dl10Slices, empty, wallSlicesRough}, + {velSlicesFine, empty, bftSlices, empty, accelSlices, tsvcSlicesFine, empty, empty, empty}, + {empty, advVelSlicesRough, bftSlicesRough, empty, empty, empty, empty, wallSlices, wallSlicesRough}, + {empty, advVelSlices, bftSlicesRough, tsdcSlices, empty, tsvcSlicesFine, dl10SlicesRough, empty, wallSlicesRough}, + {velSlicesFine, empty, bftSlices, empty, accelSlices, tsvcSlicesFine, dl10Slices, empty, wallSlicesRough}, + {empty, empty, bftSlices, tsdcSlicesRough, empty, tsvcSlicesRough, dl10SlicesRough, empty, wallSlicesRough}, + {velSlicesRough, empty, bftSlicesFine, empty, accelSlices, empty, empty, wallSlicesRough, empty}, + {empty, empty, bftSlices, empty, accelSlices, empty, empty, wallSlicesRough, empty}, + {velSlicesFine, empty, empty, empty, empty, tsvcSlices, dl10SlicesFine, wallSlicesRough, empty}, + {velSlicesRough, empty, empty, tsdcSlicesFine, empty, tsvcSlices, empty, wallSlicesRough, wallSlicesRough}, + {empty, empty, bftSlicesRough, empty, accelSlices, tsvcSlices, empty, empty, wallSlicesRough}, + {velSlicesRough, advVelSlices, bftSlices, empty, accelSlices, empty, empty, empty, wallSlicesRough}, + {velSlicesRough, advVelSlices, bftSlices, tsdcSlices, accelSlices, empty, empty, wallSlices, empty}, + {velSlicesFine, advVelSlicesRough, bftSlicesRough, empty, empty, empty, empty, wallSlices, empty}, + {empty, empty, empty, tsdcSlices, accelSlices, tsvcSlicesRough, empty, wallSlicesRough, wallSlicesRough}, + {velSlicesRough, empty, empty, tsdcSlicesRough, accelSlices, empty, empty, empty, wallSlicesRough}, + {empty, advVelSlicesFine, empty, tsdcSlicesFine, empty, empty, dl10SlicesFine, empty, empty}, + {empty, advVelSlices, empty, empty, empty, tsvcSlicesRough, dl10Slices, wallSlices, wallSlicesRough}, + {empty, empty, bftSlicesFine, empty, empty, empty, dl10SlicesFine, wallSlices, wallSlicesRough}, + {velSlices, advVelSlicesFine, empty, tsdcSlices, empty, tsvcSlices, empty, empty, wallSlicesRough}, + {empty, advVelSlicesFine, empty, tsdcSlices, empty, empty, dl10Slices, wallSlices, empty}, + {empty, advVelSlicesFine, empty, tsdcSlicesFine, accelSlices, empty, empty, wallSlices, wallSlicesRough}, + {velSlicesRough, empty, empty, empty, empty, empty, dl10Slices, wallSlicesRough, wallSlicesRough}, + {velSlicesFine, empty, empty, tsdcSlicesRough, accelSlices, tsvcSlicesRough, empty, wallSlicesRough, wallSlicesRough}, + {empty, advVelSlices, bftSlices, empty, accelSlices, tsvcSlicesRough, dl10SlicesRough, empty, wallSlicesRough}, + {empty, empty, bftSlices, tsdcSlicesFine, empty, empty, dl10Slices, wallSlicesRough, wallSlicesRough}, + {velSlicesFine, empty, bftSlicesRough, tsdcSlicesRough, accelSlices, empty, dl10SlicesFine, empty, empty}, + {velSlicesRough, empty, empty, empty, empty, tsvcSlicesFine, empty, wallSlices, empty}, + {velSlices, empty, empty, empty, empty, tsvcSlices, dl10SlicesFine, empty, wallSlicesRough}, + {empty, advVelSlices, bftSlicesFine, empty, empty, tsvcSlices, empty, wallSlicesRough, wallSlicesRough}, + {empty, empty, bftSlices, tsdcSlicesRough, accelSlices, empty, empty, empty, wallSlicesRough}, + {empty, advVelSlicesFine, bftSlicesRough, tsdcSlicesRough, accelSlices, empty, dl10SlicesFine, empty, empty}, + {empty, advVelSlicesFine, bftSlicesFine, tsdcSlices, empty, empty, dl10SlicesFine, wallSlicesRough, empty}, + {velSlicesFine, advVelSlicesFine, bftSlices, empty, accelSlices, empty, empty, empty, empty}, + {empty, advVelSlicesFine, bftSlicesFine, empty, empty, empty, dl10SlicesFine, wallSlicesRough, empty}, + {empty, advVelSlices, empty, empty, accelSlices, tsvcSlicesFine, empty, empty, wallSlicesRough}, + {empty, empty, empty, tsdcSlicesFine, accelSlices, tsvcSlices, dl10Slices, empty, empty}, + {velSlicesRough, empty, empty, empty, accelSlices, tsvcSlices, dl10SlicesFine, empty, empty}, + {empty, advVelSlicesFine, empty, tsdcSlices, accelSlices, empty, empty, empty, wallSlicesRough} + }; + + putBuffersInto(flatSets,flattenerBuffers); + return flattenerBuffers; + + } + public static ArrayList getABSBuffers(){ + ArrayList ABSBuffers = new ArrayList(50); + + float[][][] flatSets = new float[][][] { + {velSlicesRough, empty, empty, empty, empty, tsvcSlicesFine, empty, wallSlicesRough, empty}, + {empty, empty, bftSlicesRough, empty, empty, empty, dl10SlicesFine, wallSlices, empty}, + {empty, empty, bftSlices, tsdcSlicesRough, empty, tsvcSlicesRough, empty, wallSlicesRough, wallSlicesRough}, + {velSlices, advVelSlices, bftSlicesRough, empty, empty, tsvcSlicesRough, empty, empty, wallSlicesRough}, + {empty, empty, bftSlicesRough, empty, empty, tsvcSlicesRough, empty, wallSlices, empty}, + {velSlicesFine, advVelSlicesFine, bftSlices, empty, empty, tsvcSlices, empty, empty, wallSlicesRough}, + {empty, empty, bftSlicesFine, tsdcSlicesRough, empty, tsvcSlicesFine, empty, wallSlices, empty}, + {velSlicesRough, empty, empty, empty, accelSlices, tsvcSlicesFine, empty, empty, wallSlicesRough}, + {empty, empty, bftSlicesRough, tsdcSlicesFine, accelSlices, tsvcSlicesFine, dl10SlicesFine, empty, empty}, + {velSlicesRough, empty, empty, tsdcSlices, accelSlices, tsvcSlices, empty, empty, empty}, + {velSlicesFine, empty, bftSlicesFine, empty, empty, empty, dl10SlicesRough, wallSlicesRough, wallSlicesRough}, + {velSlicesRough, advVelSlicesRough, empty, tsdcSlices, empty, tsvcSlices, empty, empty, wallSlicesRough}, + {empty, advVelSlicesRough, empty, empty, accelSlices, tsvcSlices, empty, wallSlicesRough, empty}, + {velSlicesFine, empty, empty, empty, empty, tsvcSlicesFine, dl10SlicesFine, wallSlices, wallSlicesRough}, + {empty, advVelSlicesRough, empty, empty, accelSlices, tsvcSlicesRough, dl10Slices, empty, empty}, + {velSlicesRough, empty, bftSlicesFine, tsdcSlicesRough, accelSlices, empty, empty, wallSlicesRough, empty}, + {velSlicesFine, empty, bftSlices, tsdcSlicesRough, empty, empty, empty, empty, empty}, + {velSlicesFine, advVelSlices, bftSlicesFine, empty, empty, tsvcSlices, empty, empty, empty}, + {velSlicesRough, advVelSlicesFine, empty, empty, empty, tsvcSlicesFine, empty, wallSlices, empty}, + {empty, empty, bftSlices, tsdcSlices, empty, tsvcSlicesRough, dl10Slices, empty, empty}, + {empty, empty, bftSlices, empty, accelSlices, tsvcSlicesFine, empty, wallSlices, wallSlicesRough}, + {empty, advVelSlicesFine, empty, empty, accelSlices, tsvcSlices, empty, wallSlicesRough, empty}, + {velSlicesRough, advVelSlicesRough, bftSlices, empty, empty, tsvcSlices, dl10SlicesFine, empty, empty}, + {empty, empty, empty, tsdcSlices, empty, tsvcSlicesRough, dl10SlicesRough, empty, empty}, + {velSlicesFine, empty, empty, tsdcSlices, empty, empty, empty, wallSlices, wallSlicesRough}, + {empty, empty, bftSlicesFine, empty, empty, tsvcSlices, dl10SlicesFine, empty, wallSlicesRough}, + {velSlicesFine, empty, empty, tsdcSlicesRough, empty, empty, dl10Slices, wallSlices, empty}, + {empty, empty, empty, empty, accelSlices, tsvcSlices, dl10SlicesFine, empty, wallSlicesRough}, + {empty, empty, empty, tsdcSlicesFine, accelSlices, tsvcSlices, dl10SlicesRough, empty, empty}, + {empty, empty, bftSlicesRough, tsdcSlicesFine, accelSlices, tsvcSlices, empty, wallSlicesRough, wallSlicesRough} + } ; + putBuffersInto(flatSets,ABSBuffers); + return ABSBuffers; + + } + public static ArrayList getFlattenerTickBuffers(){ + ArrayList flattenerTickBuffers = new ArrayList(15); + + float[][][] flatTickSets = new float[][][] { + {empty, empty, empty, empty, accelSlices, empty, dl10SlicesFine, wallSlices, wallSlicesRough}, + {velSlicesFine, empty, empty, tsdcSlices, empty, empty, dl10SlicesRough, empty, wallSlicesRough}, + {velSlicesFine, empty, bftSlices, empty, accelSlices, empty, empty, wallSlicesRough, wallSlicesRough}, + {empty, advVelSlices, empty, empty, accelSlices, empty, dl10SlicesFine, empty, empty}, + {empty, advVelSlicesFine, bftSlicesFine, tsdcSlicesFine, accelSlices, empty, dl10SlicesFine, empty, empty}, + {velSlices, empty, empty, tsdcSlices, empty, tsvcSlicesRough, empty, wallSlices, wallSlicesRough}, + {empty, advVelSlicesFine, bftSlicesRough, tsdcSlicesFine, empty, empty, dl10SlicesRough, empty, empty}, + {empty, empty, bftSlices, tsdcSlicesFine, accelSlices, tsvcSlicesRough, empty, empty, wallSlicesRough}, + {empty, empty, bftSlicesFine, empty, accelSlices, tsvcSlicesRough, dl10SlicesRough, empty, wallSlicesRough}, + {empty, empty, bftSlicesRough, empty, accelSlices, tsvcSlicesFine, dl10Slices, wallSlicesRough, empty}, + {empty, advVelSlicesFine, empty, tsdcSlices, accelSlices, tsvcSlicesRough, empty, wallSlices, empty}, + {velSlicesFine, advVelSlicesFine, bftSlices, empty, empty, tsvcSlicesFine, empty, wallSlices, empty}, + {empty, empty, bftSlices, empty, empty, tsvcSlicesFine, dl10SlicesRough, wallSlices, wallSlicesRough}, + {velSlicesRough, advVelSlicesFine, bftSlices, empty, empty, tsvcSlicesRough, dl10SlicesRough, wallSlices, empty}, + {empty, empty, empty, empty, accelSlices, empty, empty, wallSlicesRough, wallSlicesRough}, + {empty, advVelSlicesRough, bftSlicesRough, tsdcSlices, empty, tsvcSlicesFine, empty, wallSlices, empty}, + {empty, advVelSlicesRough, empty, tsdcSlicesRough, accelSlices, empty, empty, wallSlicesRough, empty}, + {velSlicesFine, advVelSlicesFine, empty, empty, accelSlices, empty, dl10SlicesRough, empty, wallSlicesRough}, + {empty, empty, bftSlicesFine, empty, empty, empty, empty, wallSlicesRough, empty}, + {velSlices, empty, bftSlices, tsdcSlices, accelSlices, empty, empty, empty, empty}, + {velSlicesFine, empty, bftSlicesFine, empty, empty, empty, empty, wallSlicesRough, wallSlicesRough}, + {empty, advVelSlices, bftSlicesRough, empty, empty, empty, dl10Slices, empty, wallSlicesRough}, + {velSlices, advVelSlicesRough, empty, empty, accelSlices, empty, empty, wallSlicesRough, empty}, + {empty, advVelSlicesFine, bftSlices, empty, accelSlices, tsvcSlices, empty, wallSlices, empty}, + {velSlices, advVelSlices, bftSlicesRough, tsdcSlices, accelSlices, empty, empty, empty, empty}, + {empty, advVelSlices, bftSlicesFine, tsdcSlicesRough, empty, empty, empty, empty, wallSlicesRough}, + {empty, empty, bftSlices, empty, empty, tsvcSlices, dl10SlicesFine, empty, wallSlicesRough}, + {empty, empty, bftSlicesFine, tsdcSlices, accelSlices, tsvcSlicesFine, empty, empty, empty}, + {empty, advVelSlices, empty, empty, accelSlices, tsvcSlices, dl10SlicesRough, empty, wallSlicesRough}, + {velSlices, advVelSlices, bftSlicesFine, empty, empty, empty, dl10SlicesRough, empty, empty} + }; + + putBuffersInto(flatTickSets,flattenerTickBuffers); + return flattenerTickBuffers; + + } + + private static void putBuffersInto(float[][][] sets, ArrayList buffers){ + for(int i = 0; i < sets.length; i++){ + float[][] set = sets[i]; + + int[] sri = new int[9]; + + if(set[0] == empty) + sri[0] = 0; + else if(set[0] == velSlicesRough) + sri[0] = 1; + else if(set[0] == velSlices) + sri[0] = 2; + else if(set[0] == velSlicesFine) + sri[0] = 3; + + if(set[1] == empty) + sri[1] = 0; + else if(set[1] == advVelSlicesRough) + sri[1] = 1; + else if(set[1] == advVelSlices) + sri[1] = 2; + else if(set[1] == advVelSlicesFine) + sri[1] = 3; + + + if(set[2] == empty) + sri[2] = 0; + else if(set[2] == bftSlicesRough) + sri[2] = 1; + else if(set[2] == bftSlices) + sri[2] = 2; + else if(set[2] == bftSlicesFine) + sri[2] = 3; + + + if(set[3] == empty) + sri[3] = 0; + else if(set[3] == tsdcSlicesRough) + sri[3] = 1; + else if(set[3] == tsdcSlices) + sri[3] = 2; + else if(set[3] == tsdcSlicesFine) + sri[3] = 3; + + + if(set[4] == empty) + sri[4] = 0; + else if(set[4] == accelSlices) + sri[4] = 1; + else if(set[4] == accelSlicesFine) + sri[4] = 2; + + + if(set[5] == empty) + sri[5] = 0; + else if(set[5] == tsvcSlicesRough) + sri[5] = 1; + else if(set[5] == tsvcSlices) + sri[5] = 2; + else if(set[5] == tsvcSlicesFine) + sri[5] = 3; + + + if(set[6] == empty) + sri[6] = 0; + else if(set[6] == dl10SlicesRough) + sri[6] = 1; + else if(set[6] == dl10Slices) + sri[6] = 2; + else if(set[6] == dl10SlicesFine) + sri[6] = 3; + + + if(set[7] == empty) + sri[7] = 0; + else if(set[7] == wallSlicesRough) + sri[7] = 1; + else if(set[7] == wallSlices) + sri[7] = 2; + + + if(set[8] == empty) + sri[8] = 0; + else if(set[8] == wallSlicesRough) + sri[8] = 1; + else if(set[8] == wallSlices) + sri[8] = 2; + + StatBuffer sb = new StatBuffer(set[0],set[1],set[2],set[3],set[4],set[5],set[6],set[7],set[8],sri); + + buffers.add(sb); + } + + } + public static int[][] getIndexes( + float latVel, + float advVel, + float bft, + float tsdc, + float accel, + float tsvc, + float dl10, + float forwardWall, + float reverseWall){ + + + int[][] indexes = new int[4][9]; + + /// set up indexes + indexes[1][0] = getIndex(velSlicesRough, latVel); + indexes[2][0] = getIndex(velSlices, latVel); + indexes[3][0] = getIndex(velSlicesFine, latVel); + + indexes[1][1] = getIndex(advVelSlicesRough, advVel); + indexes[2][1] = getIndex(advVelSlices, advVel); + indexes[3][1] = getIndex(advVelSlicesFine, advVel); + + indexes[1][2] = getIndex(bftSlicesRough, bft); + indexes[2][2] = getIndex(bftSlices, bft); + indexes[3][2] = getIndex(bftSlicesFine, bft); + + indexes[1][3] = getIndex(tsdcSlicesRough, tsdc); + indexes[2][3] = getIndex(tsdcSlices, tsdc); + indexes[3][3] = getIndex(tsdcSlicesFine, tsdc); + + indexes[1][4] = getIndex(accelSlices, accel); + indexes[2][4] = getIndex(accelSlicesFine, accel); + + indexes[1][5] = getIndex(tsvcSlicesRough, tsvc); + indexes[2][5] = getIndex(tsvcSlices, tsvc); + indexes[3][5] = getIndex(tsvcSlicesFine, tsvc); + + indexes[1][6] = getIndex(dl10SlicesRough, dl10); + indexes[2][6] = getIndex(dl10Slices, dl10); + indexes[3][6] = getIndex(dl10SlicesFine, dl10); + + indexes[1][7] = getIndex(wallSlicesRough, forwardWall); + indexes[2][7] = getIndex(wallSlices, forwardWall); + + indexes[1][8] = getIndex(wallSlicesRough, reverseWall); + indexes[2][8] = getIndex(wallSlices, reverseWall); + + return indexes; + + } + public static ArrayList getStats(ArrayList buffers, int[][] indexes){ + ArrayList stats = new ArrayList(buffers.size()); + + for(int i = 0, k = buffers.size(); i < k; i++){ + stats.add(((StatBuffer)(buffers.get(i))).getStats(indexes)); + } + + return stats; + } + + private static int getIndex(float[] slices, float value){ + int index = 0; + while(index < slices.length && value >= slices[index]) + index++; + return index; + } + + public static class SingleBuffer{ + public int binsUsed,hits; + public int[] bins; + public float weight; + public float rollingDepth = 0.7f; + + public void addHit(int hitIndex){ + if(bins == null){ + bins = new int[(int)Math.ceil(rollingDepth*2) + 1]; + hits = -1; + } + + if(binsUsed < bins.length) + binsUsed+=1; + + hits = (hits+1)%bins.length; + bins[hits] = hitIndex; + + } + } + + public static class StatBuffer{ + + public float _weight; + public float rollingDepth; + + public SingleBuffer [][][][][][][][][] stats; + + public int[] sri; + + public StatBuffer( + float[] vSlices, + float[] aVSlices, + float[] dSlices, + float[] tsdcSlices, + float[] accSlices, + float[] tsvcSlices, + float[] dl10Slices, + float[] fWallSlices, + float[] rWallSlices, + int[] sliceRetrieveIndexes){ + + stats = new SingleBuffer + [vSlices.length + 1] + [aVSlices.length + 1] + [dSlices.length + 1] + [tsdcSlices.length + 1] + [accSlices.length + 1] + [tsvcSlices.length + 1] + [dl10Slices.length + 1] + [fWallSlices.length + 1] + [rWallSlices.length + 1]; + + float weight = (vSlices.length + 1) + *(aVSlices.length + 1) + *(dSlices.length + 1) + *(tsdcSlices.length +1) + *(accSlices.length + 1) + *(tsvcSlices.length + 1) + *(dl10Slices.length + 1) + *(fWallSlices.length + 1) + *(rWallSlices.length + 1); + + if(weight < 2) + rollingDepth = 3; + else if(weight < 3) + rollingDepth = 1; + // else if(weight < 7) + // rollingDepth = 1; + else if(weight < 10) + rollingDepth = 0.7f; + else if(weight < 33) + rollingDepth = 0.5f; + else if(weight < 100) + rollingDepth = 0.2f; + else rollingDepth = 0.1f; + + // _weight = 1; + _weight = weight; + sri = sliceRetrieveIndexes; + } + /*SingleBuffer getStats(float latVel, float advVel, float distance, float tsdc, float accel, float tsvc, float dl10, float forwardWall, float reverseWall){ + SingleBuffer sb = new SingleBuffer(); + sb.bins = stats + [getIndex(velocitySlices, latVel)] + [getIndex(advVelocitySlices, advVel)] + [getIndex(distanceSlices, distance)] + [getIndex(timeSinceDirChangeSlices, tsdc)] + [getIndex(accelSlices,accel)] + [getIndex(timeSinceVelChangeSlices, tsvc)] + [getIndex(distLast20Slices, dl10)] + [getIndex(forwardWallSlices,forwardWall)] + [getIndex(reverseWallSlices,reverseWall)]; + sb.weight = this._weight; + sb.rollingDepth = this.rollingDepth; + return sb; + + }*/ + public SingleBuffer getStats(int[][] indexes){ + SingleBuffer sb = stats + [indexes[sri[0]][0]] + [indexes[sri[1]][1]] + [indexes[sri[2]][2]] + [indexes[sri[3]][3]] + [indexes[sri[4]][4]] + [indexes[sri[5]][5]] + [indexes[sri[6]][6]] + [indexes[sri[7]][7]] + [indexes[sri[8]][8]] + ; + if(sb == null){ + sb = stats + [indexes[sri[0]][0]] + [indexes[sri[1]][1]] + [indexes[sri[2]][2]] + [indexes[sri[3]][3]] + [indexes[sri[4]][4]] + [indexes[sri[5]][5]] + [indexes[sri[6]][6]] + [indexes[sri[7]][7]] + [indexes[sri[8]][8]] = new SingleBuffer(); + + + sb.weight = this._weight; + sb.rollingDepth = this.rollingDepth; + sb.hits = -1; + } + + + return sb; + + } + } +} \ No newline at end of file diff --git a/tools/robocode_shim/vendor/drussgt/src/jk/mega/BulletPowerPredictor.java b/tools/robocode_shim/vendor/drussgt/src/jk/mega/BulletPowerPredictor.java new file mode 100644 index 0000000..5e382c9 --- /dev/null +++ b/tools/robocode_shim/vendor/drussgt/src/jk/mega/BulletPowerPredictor.java @@ -0,0 +1,51 @@ +package jk.mega; +import java.util.*; +import jk.tree.KDTree; + +public class BulletPowerPredictor{ + KDTree bulletPowerTree = new KDTree.Euclidean(3); + public void train(double botEnergy, double oppEnergy, double distance, float bulletPower){ + bulletPowerTree.addPoint( + new double[]{botEnergy/200,oppEnergy/200,distance/1200}, + bulletPower); + } + + public double predictBulletPower(double myEnergy, double enemyEnergy, double distance){ + + List> cl = bulletPowerTree.nearestNeighbours( + new double[]{myEnergy/200, enemyEnergy/200, distance/1200}, + Math.min((int)Math.ceil(Math.sqrt(bulletPowerTree.size())),20)); + + double[][] bullHist = new double[2][cl.size()]; + + Iterator> it = cl.iterator(); + int i = 0; + while(it.hasNext()){ + KDTree.SearchResult p = it.next(); + double weight = 1/(p.distance + 0.1); + bullHist[0][i] = weight; + bullHist[1][i] = p.payload; + i++; + } + double maxScore = 0; + double maxPower = 2; + for(int j = 0; j < i; j++){ + double score = 0; + for(int k = 0; k < j; k++) + score += bullHist[0][k]/(sqr(bullHist[1][j] - bullHist[1][k]) + 0.1); + for(int k = j+1; k < i; k++) + score += bullHist[0][k]/(sqr(bullHist[1][j] - bullHist[1][k]) + 0.1); + score *= bullHist[0][j]; + + if(score > maxScore){ + maxScore = score; + maxPower = bullHist[1][j]; + } + } + + return maxPower; + } + double sqr(double d){ + return d*d;} + +} \ No newline at end of file diff --git a/tools/robocode_shim/vendor/drussgt/src/jk/mega/DataToGun.java b/tools/robocode_shim/vendor/drussgt/src/jk/mega/DataToGun.java new file mode 100644 index 0000000..8112c0b --- /dev/null +++ b/tools/robocode_shim/vendor/drussgt/src/jk/mega/DataToGun.java @@ -0,0 +1,12 @@ +package jk.mega; +import java.awt.geom.*; + + +public class DataToGun{ + + public Point2D.Double futurePoint = new Point2D.Double(); + public double futureVelocity, futureHeading, enemyBP; + public int timeInFuture; + + +} \ No newline at end of file diff --git a/tools/robocode_shim/vendor/drussgt/src/jk/mega/DrussGT.java b/tools/robocode_shim/vendor/drussgt/src/jk/mega/DrussGT.java new file mode 100644 index 0000000..76d3684 --- /dev/null +++ b/tools/robocode_shim/vendor/drussgt/src/jk/mega/DrussGT.java @@ -0,0 +1,268 @@ +package jk.mega; + +import robocode.*; +import jk.mega.dGun.*; +import jk.mega.dMove.*; +import jk.melee.*; +import jk.precise.*; +import java.io.PrintStream; +import java.io.IOException; +import java.awt.*; + +public class DrussGT extends AdvancedRobot { + + public static final boolean TC = false; + public static final boolean MC = false; + public static final double SHIELD_THRESHOLD = 98; + //train it in the movement, available for the gun to use too + public static BulletPowerPredictor bulletPowerPredictor = new BulletPowerPredictor(); + static boolean shieldEnabled = !MC && !TC; + public DrussMoveGT move; + public MeleeRadar radar; + public DrussGunDC gun; + public EnergyDomeWorker shield; + + public void run() { + + setAdjustRadarForGunTurn(true); + setAdjustRadarForRobotTurn(true); + setAdjustGunForRobotTurn(true); + setColors(new Color(40, 40, 0), new Color(0, 40, 0), Color.GRAY); + if (!TC) { + setTurnRightRadians(Double.POSITIVE_INFINITY); + setTurnGunRightRadians(Double.POSITIVE_INFINITY); + } + setTurnRadarRightRadians(Double.POSITIVE_INFINITY); + if (!TC) + try { + move = new DrussMoveGT(this); + } catch (Exception ex) { + contain(ex); + } + try { + radar = new MeleeRadar(this); + } catch (Exception ex) { + contain(ex); + } + if (!MC) + try { + gun = new DrussGunDC(this); + } catch (Exception ex) { + contain(ex); + } + + if (shieldEnabled) + try { + shield = new EnergyDomeWorker(this); + } catch (Exception ex) { + contain(ex); + } + + while (true) { + if (!TC) + try { + move.onTick(!shieldEnabled); + } catch (Exception ex) { + contain(ex); + } + try { + radar.onTick(); + } catch (Exception ex) { + contain(ex); + } + if (!MC) + try { + } catch (Exception ex) { + contain(ex); + } + try { + Thread.sleep(0,1000); + } catch (Exception e){} + execute(); + } + } + + public void onScannedRobot(ScannedRobotEvent e) { + if (!TC && !MC && shieldEnabled) { + shieldEnabled = shield.aboveScore(SHIELD_THRESHOLD); + if (shieldEnabled) { + try { + shield.onScannedRobot(e); + shield.applyActions(); + } catch (Exception ex) { + contain(ex); + } + } + } + + + DataToGun dtg = new DataToGun(); + if (!TC) + try { + move.onScannedRobot(e); + if (!shieldEnabled) + move.doSurfing(); + dtg = move.getGunInfo(); + } catch (Exception ex) { + contain(ex); + } + + try { + radar.onScannedRobot(e); + } catch (Exception ex) { + contain(ex); + } + + + if (!shieldEnabled || TC) { + Bullet b = null; + if (!MC) + try { + b = gun.onScannedRobot(e, dtg.futurePoint, dtg.futureHeading, dtg.futureVelocity, dtg.timeInFuture, dtg.enemyBP, TC); + } catch (Exception ex) { + contain(ex); + } + + if (!TC) + try { + move.logMyBullet(b); + } catch (Exception ex) { + contain(ex); + } + } + } + + public void onRobotDeath(RobotDeathEvent e) { + if (!TC) + try { + move.onRobotDeath(e); + } catch (Exception ex) { + contain(ex); + } + + try { + radar.onRobotDeath(e); + } catch (Exception ex) { + contain(ex); + } + + // try{ + // gun.onRobotDeath(e); + // } + // catch(Exception ex){contain(ex);} + + } + + public void onHitByBullet(HitByBulletEvent e) { + if (!TC) + try { + move.onHitByBullet(e); + } catch (Exception ex) { + contain(ex); + } + + if (shieldEnabled) + try { + shield.onHitByBullet(e); + } catch (Exception ex) { + contain(ex); + } + } + + public void onHitRobot(HitRobotEvent e) { + if (!TC) + try { + move.onHitRobot(e); + } catch (Exception ex) { + contain(ex); + } + } + + public void onBulletHitBullet(BulletHitBulletEvent e) { + if (!TC) + try { + move.onBulletHitBullet(e); + } catch (Exception ex) { + contain(ex); + } + + + if (!shieldEnabled) + try { + gun.onBulletHitBullet(e); + } catch (Exception ex) { + contain(ex); + } + + if (shieldEnabled) + try { + shield.onBulletHitBullet(e); + } catch (Exception ex) { + contain(ex); + } + } + + public void onBulletHit(BulletHitEvent e) { + if (!TC) + try { + move.onBulletHit(e); + } catch (Exception ex) { + contain(ex); + } + + if (!shieldEnabled) + try { + gun.onBulletHit(e); + } catch (Exception ex) { + contain(ex); + } + + if (shieldEnabled) + try { + shield.onBulletHit(e); + } catch (Exception ex) { + contain(ex); + } + } + + public void onPaint(java.awt.Graphics2D g) { + if (!TC) move.onPaint(g); + if (!shieldEnabled) + gun.onPaint(g); + } + + public void onDeath(DeathEvent e) { + shieldEnabled = false; + try { + + if (!MC) gun.onDeath(e); + if (!TC) move.onDeath(e); + } catch (Exception ex) { + contain(ex); + } + } + + public void onWin(WinEvent e) { + try { + if (!TC) move.onWin(e); + if (!MC) gun.onWin(e); + } catch (Exception ex) { + contain(ex); + } + } + + public void contain(Exception e) { + + e.printStackTrace(); + + try { + PrintStream out = new PrintStream(new RobocodeFileOutputStream(getDataFile((int) (Math.random() * 100) + ".error"))); + e.printStackTrace(out); + out.flush(); + out.close(); + } catch (IOException ioex) { + } + } + + +} \ No newline at end of file diff --git a/tools/robocode_shim/vendor/drussgt/src/jk/mega/DrussGT.properties b/tools/robocode_shim/vendor/drussgt/src/jk/mega/DrussGT.properties new file mode 100644 index 0000000..d79731a --- /dev/null +++ b/tools/robocode_shim/vendor/drussgt/src/jk/mega/DrussGT.properties @@ -0,0 +1,11 @@ +#Robocode Robot +#Sun Sep 10 17:26:09 CEST 2017 +robot.java.source.included=false +robot.classname=jk.mega.DrussGT +robot.author.name=Julian Kent AKA Skilgannon +uuid=35d3badf-5304-4ad3-8ca7-1561db0e34f1 +robocode.version=1.9.2.5 +robot.codesize=48320 +robot.description=Thou loggerheaded hasty-witted varlet\!\nUses GoTo/VCS surfing, KNN targeting and Bullet Shielding when possible\n3.1.4159\: A wild attempt to bypass the JVM8 ThreadDeath issues +robot.version=3.1.4159 +robot.include.source=true diff --git a/tools/robocode_shim/vendor/drussgt/src/jk/mega/EnemyMoves.java b/tools/robocode_shim/vendor/drussgt/src/jk/mega/EnemyMoves.java new file mode 100644 index 0000000..8ec18c3 --- /dev/null +++ b/tools/robocode_shim/vendor/drussgt/src/jk/mega/EnemyMoves.java @@ -0,0 +1,265 @@ +package jk.mega; + +import jk.mega.dGun.*; +import jk.precise.util.*; +import robocode.*; +import robocode.util.Utils; +import java.awt.geom.*; // for Point2D's +import java.lang.*; // for Double and Integer objects +import java.util.*; // for collection of waves +import java.awt.Color; +//import ags.utils.*; +import java.io.*; +import jk.math.FastTrig; +import jk.tree.KDTree; + +public class EnemyMoves{ + + int predictTime; + double dirFlip = 1; + PointChain predictHead; + double predictHeading, + predictStartHeading; + Point2D.Double predictLocation, predictStartLocation; + Locator predictLoc; + int maxTime; + + ArrayList futureLocs;// = new ArrayList(); + + PointChain currentPoint = null; + Locator currentLoc; + + AdvancedRobot bot; + + double timeSinceDecel; + double timeSinceDirChange; + + double lastDirection; + double lastHeading; + double lastVelocity = 0; + Point2D.Double enemyLocation; + + ArrayList addQueue = new ArrayList(); + + ArrayList enemyLocations = new ArrayList(); + + static KDTree tree = new KDTree.Manhattan(new Locator().getLocation().length); + + + public void onScannedRobot(ScannedRobotEvent e){ + + Point2D.Double myLocation = new Point2D.Double(bot.getX(), bot.getY()); + double absBearing = bot.getHeadingRadians() + e.getBearingRadians(); + enemyLocation = project(myLocation, absBearing, e.getDistance()); + enemyLocations.add(enemyLocation); + + double velocity = e.getVelocity(); + double heading = e.getHeadingRadians(); + double offset = Utils.normalAbsoluteAngle(heading - absBearing); + double lateralVelocity = velocity*FastTrig.sin(offset); + double advancingVelocity = -velocity*FastTrig.cos(offset); + double distance = e.getDistance(); + + + double accel = 1; + double acc = velocity - lastVelocity; + acc = acc * Math.signum(velocity); + + double direction = Math.signum(lateralVelocity); + if(direction == 0) + direction = lastDirection; + if(direction == 0) + direction = 1; + + if(acc > 0) + accel = 2; + else if(acc < 0){ + accel = 0; + } + + if(accel == 0) + timeSinceDecel = 0; + else + timeSinceDecel++; + + if(direction == lastDirection) + timeSinceDirChange++; + else + timeSinceDirChange = 0; + + + double distLast10 = enemyLocation.distance(enemyLocations.get(Math.min(10,enemyLocations.size() - 1))); + + double bulletPower = 2.95; + double[] preciseMEAs = PreciseMinMaxGFs.getPreciseMEAs( + enemyLocation,e.getHeadingRadians(),e.getVelocity(), + myLocation,bulletPower,direction, + new ArrayList(),absBearing); + + double mea=FastTrig.asin(8.0/(20 - 3*bulletPower)); + double forwardWall = preciseMEAs[1]/mea; + double reverseWall = preciseMEAs[0]/mea; + double BFT = distance/(20 - 3*bulletPower); + + Locator l = new Locator(); + l.vel = velocity; + l.latVel = lateralVelocity; + l.advVel = advancingVelocity; + l.distance = distance; + l.accel = accel; + l.direction = direction; + l.timeSinceDecel = timeSinceDecel; + l.timeSinceDirChange = timeSinceDirChange; + l.distLast10 = distLast10; + l.forwardWall = forwardWall; + l.reverseWall = reverseWall; + l.BFT = BFT; + + + PointChain npc = new PointChain(); + if(currentPoint != null) + currentPoint.next = npc; + npc.velocity = velocity; + npc.deltaHeading = Utils.normalRelativeAngle(heading - lastHeading); + currentPoint = npc; + l.value = npc; + + addQueue.add(l); + + while(addQueue.size() > BFT){ + Locator arrived = addQueue.remove(0); + tree.addPoint(arrived.getLocation(),arrived.value); + } + //tree.addPoint(l.getLocation(),npc); + currentLoc = l; + + lastDirection = direction; + lastVelocity = velocity; + lastHeading = heading; + } + + public EnemyMoves(AdvancedRobot b){ + bot = b; + } + + public Point2D.Double get(int time){ + if(time > maxTime) + extend(time); + return futureLocs.get(Math.max(0,time - predictTime)); + // if(rp == null) + // throw new IllegalArgumentException("null in futureLocs somehow..."); + //System.out.println("Returning null from " + (time - predictTime) + " out of " + futureLocs.size()); + // return rp; + } + + public void extend(int time){ + int addSize = time - maxTime; + int getIndex = 0; + for(int i = 0; i < addSize; i++){ + // if(predictHead == null){ + // getIndex = getIndex + 1; + // if(getIndex > tree.size()){ + // for(int j = i; j < addSize; j++) + // futureLocs.add(predictLocation); + // i = addSize; + // } + // else{ + // predict(); + // addSize = time - predictTime - futureLocs.size() + 1; + // i = 0; + // } + // } + if(predictHead != null){ + predictHeading += predictHead.deltaHeading; + predictLocation = project(predictLocation,predictHeading,predictHead.velocity*dirFlip); + predictHead = predictHead.next; + } + // + // if(predictLocation == null) + // throw new IllegalArgumentException("adding null"); + + futureLocs.add(predictLocation); + + } + maxTime += addSize; + + } + public boolean initialised(){ + return futureLocs != null; + } + public void predict(){ + predictLoc = currentLoc; + predictTime = (int)bot.getTime(); + predictStartHeading = lastHeading; + predictStartLocation = enemyLocation; + + predict(0); + } + void predict(int nearIndex){ + List> cluster = tree.nearestNeighbours( + predictLoc.getLocation(), + Math.min(nearIndex+1,tree.size())); + + if(cluster.size() > 0){ + + predictHead = cluster.get(nearIndex).payload; + dirFlip = Math.signum(predictHead.velocity) == Math.signum(predictLoc.vel)?1:-1; + } + futureLocs = new ArrayList(); + predictHeading = predictStartHeading; + predictLocation = predictStartLocation; + maxTime = predictTime-1; + } + + + + + + + static class PointChain{ + PointChain next; + double velocity, deltaHeading; + } + static class Locator{ + PointChain value; + double vel, + latVel, + advVel, + //offset, + distance, + accel, + direction, + timeSinceDecel, + timeSinceDirChange, + distLast10, + forwardWall, + reverseWall, + BFT; + double[] getLocation(){ + final double[] w = { 0.6060732907019181, 1.4406808733244607, 0.954563646088063, 0.1628041961645823, 0.6851868785430317, 1.0573331814261329, 1.249422570480633, 0.6582714590108382, 0.8855547253444055, 0.6263796249347, 1.2375289235449662, 1.0494098503354718, 0.17921500418340133, 0.20756520159004618, 0.50948425222709, 0.7157847310917926}; + return new double[]{ + Math.abs(latVel/8)*10*w[0], + limit(0,advVel/16 + 0.5,1)*2*w[1], + limit(0,distance/900,1)*5*w[2], + accel/2.0*10*w[3], + limit(0,distLast10/(8*10),1)*3*w[4], + limit(0,forwardWall,1)*5*w[5], + limit(0,reverseWall,1)*2*w[6], + 1/(1 + 2*timeSinceDirChange/BFT) * 3*w[7], + 1/(1 + 2*timeSinceDecel/BFT)*3*w[8] + }; + + } + + + } + + public static Point2D.Double project(Point2D.Double sourceLocation, double angle, double length) { + return new Point2D.Double(sourceLocation.x + FastTrig.sin(angle) * length, + sourceLocation.y + FastTrig.cos(angle) * length); + } + + public static double limit(double min, double val, double max){ + return Math.max(min,Math.min(val,max)); + } +} \ No newline at end of file diff --git a/tools/robocode_shim/vendor/drussgt/src/jk/mega/Insulter.java b/tools/robocode_shim/vendor/drussgt/src/jk/mega/Insulter.java new file mode 100644 index 0000000..7f4c523 --- /dev/null +++ b/tools/robocode_shim/vendor/drussgt/src/jk/mega/Insulter.java @@ -0,0 +1,163 @@ + package jk.mega; + + public class Insulter{ + public static String getInsult(){ + String word1 = column1[(int)(column1.length*Math.random())]; + String word2 = column2[(int)(column2.length*Math.random())]; + String word3 = column3[(int)(column3.length*Math.random())]; + return ("Thou " + word1 + " " + word2 + " " + word3 + "!"); + } + static final String[] column1 = { + "artless", + "bawdy", + "beslubbering", + "bootless", + "churlish", + "cockered", + "clouted", + "craven", + "currish", + "dankish", + "dissembling", + "droning", + "errant", + "fawning", + "fobbing", + "froward", + "frothy", + "gleeking", + "goatish", + "gorbellied", + "impertinent", + "infectious", + "jarring", + "loggerheaded", + "lumpish", + "mammering", + "mangled", + "mewling", + "paunchy", + "pribbling", + "puking", + "puny", + "qualling", + "rank", + "reeky", + "roguish", + "ruttish", + "saucy", + "spleeny", + "spongy", + "surly", + "tottering", + "unmuzzled", + "vain", + "venomed", + "villainous", + "warped", + "wayward", + "weedy", + "yeasty"}; + static final String[] column2 = { + "base-court", + "bat-fowling", + "beef-witted", + "beetle-headed", + "boil-brained", + "clapper-clawed", + "clay-brained", + "common-kissing", + "crook-pated", + "dismal-dreaming", + "dizzy-eyed", + "doghearted", + "dread-bolted", + "earth-vexing", + "elf-skinned", + "fat-kidneyed", + "fen-sucked", + "flap-mouthed", + "fly-bitten", + "folly-fallen", + "fool-born", + "full-gorged", + "guts-griping", + "half-faced", + "hasty-witted", + "hedge-born", + "hell-hated", + "idle-headed", + "ill-breeding", + "ill-nurtured", + "knotty-pated", + "milk-livered", + "motley-minded", + "onion-eyed", + "plume-plucked", + "pottle-deep", + "pox-marked", + "reeling-ripe", + "rough-hewn", + "rude-growing", + "rump-fed", + "shard-borne", + "sheep-biting", + "spur-galled", + "swag-bellied", + "tardy-gaited", + "tickle-brained", + "toad-spotted", + "unchin -snouted", + "weather-bitten"}; + static final String[] column3 = { + "apple-john", + "baggage", + "barnacle", + "bladder", + "boar-pig", + "bugbear", + "bum-bailey", + "canker-blossom", + "clack-dish", + "clotpole", + "coxcomb", + "codpiece", + "death-token", + "dewberry", + "flap-dragon", + "flax-wench", + "flirt-gill", + "foot-licker", + "fustilarian", + "giglet", + "gudgeon", + "haggard", + "harpy", + "hedge-pig", + "horn-beast", + "hugger-mugger", + "joithead", + "lewdster", + "lout", + "maggot-pie", + "malt-worm", + "mammet", + "measle", + "minnow", + "miscreant", + "moldwarp", + "mumble-news", + "nut-hook", + "pigeon-egg", + "pignut", + "puttock", + "pumpion", + "ratsbane", + "scut", + "skainsmate", + "strumpet", + "varlet", + "vassal", + "whey-face", + "wagtail"}; + } \ No newline at end of file diff --git a/tools/robocode_shim/vendor/drussgt/src/jk/mega/dGun/DrussGunDC.java b/tools/robocode_shim/vendor/drussgt/src/jk/mega/dGun/DrussGunDC.java new file mode 100644 index 0000000..fa9b8d7 --- /dev/null +++ b/tools/robocode_shim/vendor/drussgt/src/jk/mega/dGun/DrussGunDC.java @@ -0,0 +1,1353 @@ +package jk.mega.dGun; +import jk.precise.util.*; +//import ags.utils.*; +import robocode.*; +import java.awt.Color; +import java.awt.geom.*; +import java.util.*; +import jk.mega.*; +import jk.math.FastTrig; +import jk.tree.KDTree; + + +public class DrussGunDC { + //final static boolean TC = false; + final static boolean logData = false; + static StringBuilder dataToLog = new StringBuilder(); + + DrussGT bot; + static Point2D.Double myLocation, myNextLocation; + private static double BULLET_POWER = 1.9; + ArrayList lateralVelocities = new ArrayList(1000); + ArrayList enemyLocations = new ArrayList(1000); + ArrayList precisePredictionPoints; + static ArrayList waveList, removeList; + double lastDirection = 1, lastVelocity = 0, lastHeading = 0; + int timeSinceDirChange = 0, timeSinceDecel = 0, timeSinceAccel = 0; + public static int bulletsShot = 0; + public static int bulletsPassed = 0; + public static int bulletsHit = 0; + boolean firstScan = true; + public static double currentGF = 0; + public double nextAbsBearing; + StoreScan lastStoreScan; + static String enemyName; + DCWave wave; + ScannedRobotEvent lastScan; + + + public DrussGunDC(DrussGT bot){ + waveList = new ArrayList(); + removeList = new ArrayList(); + this.bot = bot; + if(DCWave.heapTree != null){ + System.out.println("My hitrate : " + (double)(Math.round(1000.0*bulletsHit/bulletsPassed)/10.0) + "%"); + System.out.println("Actual hits : " + bulletsHit); + System.out.println("DC gun score : " + DCWave.DCHits); + System.out.println("DCAS gun score : " + DCWave.DCASHits); + System.out.println("Random score : " + (int)Math.round(DCWave.randomHits)); + System.out.println("gun: " + + (DCWave.GUN == DCWave.DC?"DC":"") + + (DCWave.GUN == DCWave.DCAS?"DC-AS":"") + + (DCWave.GUN == DCWave.RANDOM?"RANDOM":"") + ); + + } + } + + public Bullet onScannedRobot(ScannedRobotEvent e, + Point2D.Double futurePoint, + double futureVelocity, + double futureHeading, + int timeInFuture, + double enemyBP, + boolean TC + ){ + + if(enemyName == null){ + enemyName = e.getName(); + if(logData) + dataToLog.append("\n"); + } + myLocation = new Point2D.Double(bot.getX(), bot.getY()); + + double absBearing = bot.getHeadingRadians() + e.getBearingRadians(); + Point2D.Double enemyLocation = JKDCUtils.project(myLocation, absBearing, e.getDistance()); + + enemyLocations.add(0,enemyLocation); + + boolean rammer = e.getDistance() < 150 ; + if(TC) + BULLET_POWER = Math.min(3,bot.getEnergy()); + else{ + double basePower = 1.95; + try{ + if(bulletsHit*3 > bulletsPassed){ + basePower = 2.95; + } + } + catch(Exception ex){} + double minBP = 0.15; + double enemyEnergyBP = (e.getEnergy())/4; + + double energyBP = + Math.max(0,bot.getEnergy()-20 + 0.5*JKDCUtils.limit(-10,bot.getEnergy()-e.getEnergy(),30))/25;// + (bot.getEnergy() - e.getEnergy())/20; + + if(bulletsHit*8 < bulletsPassed) + energyBP = Math.min(energyBP,enemyBP - 0.1); + + BULLET_POWER = rammer?2.95 + :Math.max(minBP, + Math.min(enemyEnergyBP,Math.min(energyBP,basePower))) + ; + + double eEnergy = e.getEnergy(); + double eDist = e.getDistance(); + double testBFT = eDist/(20 - 3*BULLET_POWER); + double eGH = bot.move.enemyGunHeat; + for(int i = 0; i < testBFT; i++){ + eGH -= 0.1; + if(eGH < 0.1){ + double bp = bot.bulletPowerPredictor.predictBulletPower(bot.getEnergy(),eEnergy,eDist); + eEnergy -= bp; + eGH = 1 + bp*0.2; + } + } + enemyEnergyBP = (eEnergy+0.01)/4; + if(enemyEnergyBP < BULLET_POWER){ + double bpn = rammer?2.95 + :Math.max(minBP, + Math.min(enemyEnergyBP,Math.min(energyBP,basePower))) + ; + if(bpn < BULLET_POWER){ + eEnergy = e.getEnergy(); + testBFT = eDist/(20 - 3*bpn); + eGH = bot.move.enemyGunHeat; + for(int i = 0; i < testBFT; i++){ + eGH -= 0.1; + if(eGH < 0.1){ + double bp = bot.bulletPowerPredictor.predictBulletPower(bot.getEnergy(),eEnergy,eDist); + eEnergy -= bp; + eGH = 1 + bp*0.2; + } + } + enemyEnergyBP = (eEnergy+0.01)/4; + BULLET_POWER = rammer?2.95 + :Math.max(minBP, + Math.min(enemyEnergyBP,Math.min(energyBP,basePower))); + } + } + + boolean roundUp = false; + if(BULLET_POWER == enemyEnergyBP && bot.getEnergy() > 30) + roundUp = true; + double[] buggyVals = { + 0.15, + 0.25, + 0.35, + 0.45, + // 0.55, + 0.65, + // 0.75, + 0.85, + 0.95, + // 1.05, + 1.15, + // 1.25, + // 1.35, + // 1.45, + // 1.55, + // 1.65, + // 1.75, + // 1.85, + 1.95, + // 2.05, + // 2.15, + // 2.25, + // 2.35, + // 2.45, + // 2.55, + // 2.65, + // 2.75, + // 2.85, + 2.95 + }; + int closest = 11; + double closestDist = Double.POSITIVE_INFINITY; + for(int i = 0; i < buggyVals.length; i++){ + double dist = Math.abs(BULLET_POWER - buggyVals[i]); + if(dist < closestDist){ + closestDist = dist; + closest=i; + } + } + if(roundUp && buggyVals[closest] < BULLET_POWER && closest+1 < buggyVals.length){ + closest++; + //System.out.println("rounding up"); + } + + BULLET_POWER = Math.nextAfter(buggyVals[closest],-1); + //creates a stepped function which continues to exploit the x.x5 bug + // even at lower energies + // round(10*(min(1.95,x/20) + 0.05))/10 - 0.05 + BULLET_POWER = Math.max(0.1,BULLET_POWER); + } + + double velocity = e.getVelocity(); + double offset = FastTrig.normalAbsoluteAngle(e.getHeadingRadians() - absBearing); + double lateralVelocity = velocity*FastTrig.sin(offset); + double advancingVelocity = -velocity*FastTrig.cos(offset); + double distance = e.getDistance(); + + double direction = Math.signum(lateralVelocity); + + if(direction == 0) + direction = lastDirection; + if(direction == 0) + direction = 1; + + double accel = 1; + double acc = velocity - lastVelocity; + acc = acc * Math.signum(velocity - 0.000000000001); + + if(acc > 0) + accel = 2; + else if(acc < 0){ + accel = 0; + direction = -direction; + } + + + lastDirection = direction; + + double myVel = bot.getVelocity(); + double maxTurn = Math.PI/18 - (Math.PI/240)*Math.abs(myVel); + double turn = JKDCUtils.limit(-maxTurn,bot.getTurnRemainingRadians(), maxTurn); + double heading = bot.getHeadingRadians() + turn; + double distRem = bot.getDistanceRemaining(); + if(myVel < 0){ + myVel = -myVel; + heading += Math.PI; + distRem = -distRem; + } + double nextVel; + if(myVel >= 0 && distRem > JKDCUtils.decelDistance(Math.abs(myVel))) + nextVel = JKDCUtils.limit(0,Math.abs(myVel) + 1, 8); + else if(distRem < JKDCUtils.decelDistance(Math.abs(myVel))) + nextVel = JKDCUtils.limit(-1.9999999,Math.abs(myVel) - 2, 6); + else + nextVel = Math.abs(bot.getVelocity()); + + myNextLocation = JKDCUtils.project(myLocation,heading,nextVel); + // Point2D.Double nextEnemyLocation = + // JKDCUtils.project(enemyLocation,e.getVelocity(),e.getHeadingRadians()); + nextAbsBearing = JKDCUtils.absoluteBearing(myNextLocation,enemyLocation); + + + if(direction == lastDirection) + timeSinceDirChange++; + else + timeSinceDirChange = 0; + + if(accel == 0) + timeSinceDecel = 0; + else + timeSinceDecel++; + + if(accel == 2) + timeSinceAccel = 0; + else + timeSinceAccel++; + + lateralVelocities.add(0,new Double(lateralVelocity)); + + + double distLast10 = enemyLocation.distance(enemyLocations.get(Math.min(10,enemyLocations.size() - 1))); + + double distLast20 = enemyLocation.distance(enemyLocations.get(Math.min(20,enemyLocations.size() - 1))); + + double distLast30 = enemyLocation.distance(enemyLocations.get(Math.min(30,enemyLocations.size() - 1))); + + + double maxEscapeAngle = JKDCUtils.maxEscapeAngle(JKDCUtils.bulletVelocity(BULLET_POWER)); + // double forwardWall = JKDCUtils.wallDistance(distance, absBearing, direction, myLocation)/maxEscapeAngle; + // double reverseWall = JKDCUtils.wallDistance(distance, absBearing, -direction, myLocation)/maxEscapeAngle; + + double BFT = e.getDistance()/JKDCUtils.bulletVelocity(BULLET_POWER); + precisePredictionPoints = new ArrayList(6); + double GF0 = absBearing; + // PreciseMinMaxGFs.getPreciseGF0( + // enemyLocation,e.getHeadingRadians(),e.getVelocity(), + // myNextLocation,BULLET_POWER,direction); + + double[] preciseMEAs = PreciseMinMaxGFs.getPreciseMEAs( + enemyLocation,e.getHeadingRadians(),e.getVelocity(), + myNextLocation,BULLET_POWER,direction, + null,GF0); + double forwardWall = preciseMEAs[1]/maxEscapeAngle; + double reverseWall = preciseMEAs[0]/maxEscapeAngle; + // double[] preciseMEAs = new double[]{maxEscapeAngle,maxEscapeAngle}; + + + Point2D.Double centerPoint = new Point2D.Double( + (enemyLocation.x + myLocation.x)*0.5, + (enemyLocation.y + myLocation.y)*0.5); + + Point2D.Double mirrorTarget = new Point2D.Double(2*centerPoint.x - futurePoint.x, + 2*centerPoint.y - futurePoint.y); + + double mirrorBearing = JKDCUtils.absoluteBearing(myLocation, mirrorTarget); + + double mirrorOffset = FastTrig.normalRelativeAngle(mirrorBearing - absBearing) + *direction; + + + DCRobotState rs = new DCRobotState(); + rs.direction = direction; + rs.latVel = lateralVelocity; + rs.advVel= advancingVelocity; + rs.vel = e.getVelocity(); + rs.deltaHeading = firstScan?0:FastTrig.normalRelativeAngle(e.getHeadingRadians() - lastHeading); + rs.heading = e.getHeadingRadians(); + rs.offset = offset; + rs.distance = distance; + rs.timeSinceDirChange = timeSinceDirChange; + rs.accel = accel; + rs.timeSinceDecel = timeSinceDecel; + rs.timeSinceAccel = timeSinceAccel; + rs.distLast30 = Math.abs(distLast30); + rs.distLast20 = Math.abs(distLast20); + rs.distLast10 = Math.abs(distLast10); + rs.forwardWall = forwardWall; + rs.reverseWall = reverseWall; + rs.location = myLocation; + rs.enemyLocation = enemyLocation; + rs.time = bot.getTime(); + rs.firstScan = firstScan; + rs.currentGF = currentGF; + rs.mirrorOffset = mirrorOffset; + rs.BFT = BFT; + rs.MEA_pos = preciseMEAs[1]; + rs.MEA_neg = preciseMEAs[0]; + rs.GF0 = GF0; + rs.bulletsShot = bulletsShot; + + wave = new DCWave(bot); + wave.gunLocation = myNextLocation; + DCWave.targetLocation = enemyLocation; + wave.lateralDirection = direction; + wave.bulletPower = BULLET_POWER; + wave.setSegmentations(rs); + wave.bearing = nextAbsBearing; + wave.bulletFired = false; + if(lastStoreScan == null) + lastStoreScan = wave.storeScan; + wave.storeScan.previous = lastStoreScan; + lastStoreScan = wave.storeScan; + + + boolean gunAimed = false; + boolean gunFinishedTurning = 0.0001 >= Math.abs(bot.getGunTurnRemainingRadians()); + if( ((TC && bot.getEnergy() != 0.0) || bot.getEnergy() > wave.bulletPower) + & maxEscapeAngle/(Math.PI/9 - Math.PI/18) + 0.99> bot.getGunHeat()/bot.getGunCoolingRate() & e.getEnergy() > 0){ + + double mostVisitedAngle = wave.mostVisitedBearing(); + + bot.setTurnGunRightRadians(FastTrig.normalRelativeAngle( + - bot.getGunHeadingRadians() + mostVisitedAngle)); + if(Math.abs(bot.getGunTurnRemainingRadians()) < Math.abs(18/e.getDistance())) + gunAimed = true; + bot.setTurnGunRightRadians(FastTrig.normalRelativeAngle(-bot.getGunHeadingRadians() + mostVisitedAngle)); + + } + else + bot.setTurnGunRightRadians(FastTrig.normalRelativeAngle(nextAbsBearing - bot.getGunHeadingRadians())); + + boolean dataExists = wave.heapTree.size() > 0; + Bullet b = null; + if(rs.MEA_pos != 0.0 & rs.MEA_neg != 0.0){ + if (!TC && + // !antiMirror && + bot.getEnergy() > wave.bulletPower) { + // if(gunAimed + // ||( Math.max(Math.max(DCWave.DCHits, DCWave.PMHits),DCWave.ASHits) + // <= 1.1*bulletsHit && gunFinishedTurning) + // || Math.max(Math.max(DCWave.DCHits, DCWave.PMHits),DCWave.ASHits) + // <= .9*bulletsHit + // ) + if(gunFinishedTurning && waveList.size() > 1) + if(dataExists) + b = bot.setFireBullet(wave.bulletPower); + //wave.bulletFired = true; + + waveList.add(0,wave); + if(b != null){ + bulletsShot++; + DCWave w = waveList.get(1); + w.bulletFired = true; + w.bulletAlive = true; + w.bullet = b; + + //System.out.println("Bullet power: " + wave.bulletPower); + } + } + if(TC && bot.getEnergy() != 0.0){ + if(gunAimed && dataExists && waveList.size() > 1) + b = bot.setFireBullet(wave.bulletPower); + //wave.bulletFired = true; + + waveList.add(0,wave); + if(b != null){ + bulletsShot++; + DCWave w = waveList.get(1); + w.bulletFired = true; + w.bulletAlive = true; + w.bullet = b; + } + } + } + + + Iterator it = waveList.iterator(); + + while(it.hasNext()){ + if(it.next().test()) + it.remove(); + } + + + lastVelocity = velocity; + lastHeading = e.getHeadingRadians(); + firstScan = false; + lastScan = e; + + + return b; + } + + public void onBulletHit(BulletHitEvent e){ + bulletsHit++; + + // Iterator it = waveList.iterator(); + // + // while(it.hasNext()){ + // DCWave w = it.next(); + // if(w.bullet != null && e.getBullet() == w.bullet){ + // double normAngle = FastTrig.normalRelativeAngle(w.bullet.getHeadingRadians() - w.bearing) + // *w.lateralDirection; + // double GF = normAngle/w.MEA_norm; + // // if(normAngle > 0) + // // GF = normAngle/w.MEA_pos; + // // else + // // GF = normAngle/w.MEA_neg; + // w.logASBuffer(GF,-3); + // } + // + // } + + //log negative 'hit' to that wave, weight -2, for AS gun + } + public void onBulletHitBullet(BulletHitBulletEvent e){ + Iterator it = waveList.iterator(); + // int actions = 0; + while(it.hasNext()){ + DCWave w = it.next(); + if(w.bullet != null && e.getBullet().equals(w.bullet)){ + + w.bullet = null; + w.bulletAlive = false; + // actions++; + } + + } + // System.out.println("logging bullet-hit-bullet " + actions + " times"); + + //log negative 'hit' to that wave, weight -2, for AS gun + } + public void onWin(WinEvent e){ + endOfRound(); + } + public void onDeath(DeathEvent e){ + endOfRound(); + } + public void endOfRound(){ + if(bot.getRoundNum() + 1 == bot.getNumRounds()) + onEndOfBattle(); + } + public void onPaint(java.awt.Graphics2D g) { + + for(int i = 0, j = waveList.size(); i < j; i++){ + DCWave w = waveList.get(i); + if(i == 0){ + g.setColor(Color.green); + Point2D.Double nmea = JKDCUtils.project(w.gunLocation,w.GF0 - w.lateralDirection*w.MEA_neg,1000); + g.drawLine((int)w.gunLocation.x, (int)w.gunLocation.y,(int)nmea.x, (int)nmea.y); + g.setColor(Color.red); + Point2D.Double pmea = JKDCUtils.project(w.gunLocation,w.GF0 + w.lateralDirection*w.MEA_pos,1000); + g.drawLine((int)w.gunLocation.x, (int)w.gunLocation.y,(int)pmea.x, (int)pmea.y); + + g.setColor(Color.red); + if(precisePredictionPoints != null) + for(int k = 0; k < precisePredictionPoints.size(); k++){ + Point2D.Double p = precisePredictionPoints.get(k); + g.drawOval((int)(p.x - 2),(int)(p.y - 2), (int)(2*2),(int)(2*2)); + } + + + } + if(w.bulletFired){ + Point2D.Double center = w.gunLocation; + double radius = (bot.getTime() - w.fireTime)*JKDCUtils.bulletVelocity(w.bulletPower); + g.setColor(Color.red); + g.drawOval((int)(w.gunLocation.x - radius),(int)(w.gunLocation.y - radius), (int)(radius*2),(int)(radius*2)); + double lastRadius = radius - JKDCUtils.bulletVelocity(w.bulletPower); + g.setColor(Color.green); + g.drawOval((int)(w.gunLocation.x - lastRadius),(int)(w.gunLocation.y - lastRadius), (int)(lastRadius*2),(int)(lastRadius*2)); + + + g.setColor(Color.gray); + double ASAngle = w.DCASBearing; + Point2D.Double ASLoc = JKDCUtils.project(w.gunLocation,ASAngle,radius); + g.drawLine((int)w.gunLocation.x, (int)w.gunLocation.y,(int)ASLoc.x, (int)ASLoc.y); + + g.setColor(Color.orange); + double mainGunAngle = w.DCBearing; + Point2D.Double mgLoc = JKDCUtils.project(w.gunLocation,mainGunAngle,radius); + g.drawLine((int)w.gunLocation.x, (int)w.gunLocation.y,(int)mgLoc.x, (int)mgLoc.y); + + + g.setColor(Color.cyan); + if(DCWave.paintPoints.size() > 1){ + Point2D.Double p = (Point2D.Double)(DCWave.paintPoints.get(0)); + for(int x = 1; x < DCWave.paintPoints.size(); x++){ + Point2D.Double pp = (Point2D.Double)(DCWave.paintPoints.get(x)); + // g.drawOval((int)(pp.x - 1), (int)(pp.y - 1), 2, 2); + g.drawLine((int)p.x, (int)p.y,(int)pp.x, (int)pp.y); + p = pp; + } + } + + if(w.intersecting){ + g.setColor(Color.white); + double angle1 = w.storeScan.range.min; + if(angle1 > 0) + angle1 = angle1*w.lateralDirection + w.GF0; + else + angle1 = angle1*w.lateralDirection + w.GF0; + + double angle2 = w.storeScan.range.max; + if(angle2 > 0) + angle2 = angle2*w.lateralDirection + w.GF0; + else + angle2 = angle2*w.lateralDirection + w.GF0; + + Point2D.Double p1 = JKDCUtils.project(w.gunLocation,angle1,radius); + Point2D.Double p2 = JKDCUtils.project(w.gunLocation,angle2,radius); + g.drawLine((int)w.gunLocation.x, (int)w.gunLocation.y,(int)p1.x, (int)p1.y); + g.drawLine((int)w.gunLocation.x, (int)w.gunLocation.y,(int)p2.x, (int)p2.y); + + + } + + } + } + if(enemyLocations.size() > 0){ + g.setColor(Color.white); + Point2D.Double enemyLocation = enemyLocations.get(0); + g.drawRect((int)enemyLocation.x - 18, (int)enemyLocation.y - 18, 36,36); + + + } + } + public void onEndOfBattle(){ + if(DrussGunDC.logData){ + try{ + java.io.PrintStream out = new java.io.PrintStream + (new RobocodeFileOutputStream( + bot.getDataFile(enemyName + ".dat").getAbsolutePath(),true)); + // StringBuilder sb = new StringBuilder(); + // for(int i = 0; i < storeScan.location.length; i++) + // sb.append((float)storeScan.location[i]).append(' '); + // sb.append(storeScan.range.min).append(' '); + // sb.append(storeScan.range.max); + // if(bulletFired) + // sb.append('b'); + // + // DrussGunDC.dataToLog.append(sb.toString()).append("\n"); + out.println("\n" + bot.move.weightedEnemyHitrate/bot.move.weightedEnemyFirerate); + out.println(dataToLog.toString()); + out.flush(); + out.close(); + } + catch (java.io.IOException ioex){ ioex.printStackTrace();} + } + + } +} +class DCRobotState { + double direction, + deltaHeading, + vel, + heading, + latVel, + advVel, + offset, + distance, + timeSinceDirChange, + accel, + distLast30, + distLast20, + distLast10, + forwardWall, + reverseWall, + timeSinceDecel, + timeSinceAccel, + BFT, + currentGF, + mirrorOffset, + MEA_pos, + MEA_neg, + GF0; + + double hitGF; + + Point2D.Double location, enemyLocation; + long time; + int bulletsShot; + + boolean firstScan; + + public double[] unweightedLocation(){ + + double[] w = new double[]{1,1,1,1,1,1,1,1,1,1,1}; + + + return new double[]{ + Math.abs(latVel/8)*10*w[0], + JKDCUtils.limit(0,advVel/16 + 0.5,1)*2*w[1], + // JKDCUtils.limit(0,offset/Math.PI, 1), + JKDCUtils.limit(0,distance/900,1)*5*w[2], + accel/2.0*10*w[3], + // JKDCUtils.limit(0,distLast30/(8*30),1)*2, + // JKDCUtils.limit(0,distLast20/(8*20),1)*2, + JKDCUtils.limit(0,distLast10/(8*10),1)*3*w[4], + JKDCUtils.limit(0,forwardWall,1)*5*w[5], + JKDCUtils.limit(0,reverseWall,1)*2*w[6], + 1/(1 + 2*timeSinceDirChange/BFT) * 3*w[7], + 1/(1 + 2*timeSinceDecel/BFT)*3*w[8] + , + JKDCUtils.limit(0,currentGF + 1,2)/2*3*w[9] + , + JKDCUtils.limit(0,mirrorOffset + 1,2)/2*2*w[10] + // timeSinceAccel*4 + } + ; + } + + public double[] location(){ + double[] w = new double[]{ + //1,1,1,1,1,1,1,1,1,1,1}; + //0.35663215860607633, 1.6313458906879579, 0.6019705187063255, 1.0608142994777618, 2.2423045393095933, 1.161128339444298, 1.1582748642507688, 0.5986850107444327, 1.3425305877880986, 0.24375915694350359, 0.6025441411429776, 0.8866053914122807, 1.3599317288895802}; + //0.39761006631467916, 1.3623843709066221, 0.7507457590792523, 0.2476425272759196, 2.6091246455496027, 1.7427220280877866, 1.1325667180117562, 0.7808830273462555, 0.9573844505787857, 0.1827641818533687, 0.8361607756146233, 0.0, 0.0}; + //0.3297935478085655, 1.0830387325861413, 0.6548881311168563, 1.834932129059347, 2.763673835072959, 1.1631548386519415, 1.0336844365235176, 0.6797311178458505, 0.23511829831926503, 0.18543432572203492, 1.0365414846709695, 0.07221957020911317, 0.6465657956744594}; + //0.30503190749424824, 1.1893999340941068, 0.6041765710670738, 2.012513034508283, 2.7993252048121935, 1.3082099875216195, 0.9304565516296818, 0.6320641560841579, 0.2235426376401561, 0.11502918121097701, 0.8802411775090245, 0.027607732726111125, 0.23177561023641985}; + //0.36613797246904434, 1.9643956996610046, 0.7300438281352154, 1.3353546243693108, 1.4421651418286763, 1.824859845807601, 1.3142744505437645, 0.8455216645522593, 0.13615184826451016, 0.1434011746344176, 0.8976829267495938, 0.021561678651469823, 0.32146487184692124}; + // 0.25824018080469674, 1.9163695398603744, 1.0363891579585793, 1.6688262139162613, 1.148913543974025, 1.917305464296922, 1.311266830251852, 0.5834461188981352, 0.15368523477852142, 0.1382554545914479, 0.8672920856128181, 0.11962481929220073, 0.3238749710514433}; + // 1.1514560171568378, 0.8255169318052671, 0.680004878855387, 1.0587656585582712, 0.4430435612748449, 1.341134999666261, 1.651831420771553, 1.3116273970713654, 1.250662104096147, 0.5548086340495689, 0.7311383821208332, 0.4305578776454599, 0.5726543890669665}; + 0.6060732907019181, 1.4406808733244607, 0.954563646088063, 0.1628041961645823, 0.6851868785430317, 1.0573331814261329, 1.249422570480633, 0.6582714590108382, 0.8855547253444055, 0.6263796249347, 1.2375289235449662, 1.0494098503354718, 0.17921500418340133, 0.20756520159004618, 0.50948425222709, 0.7157847310917926}; + return new double[]{ + Math.abs(latVel/8)*10*w[0], + JKDCUtils.limit(0,advVel/16 + 0.5,1)*2*w[1], + // JKDCUtils.limit(0,offset/Math.PI, 1), + JKDCUtils.limit(0,distance/900,1)*5*w[2], + accel/2.0*10*w[3], + // JKDCUtils.limit(0,distLast30/(8*30),1)*2, + // JKDCUtils.limit(0,distLast20/(8*20),1)*2, + JKDCUtils.limit(0,distLast10/(8*10),1)*3*w[4], + JKDCUtils.limit(0,forwardWall,1)*5*w[5], + JKDCUtils.limit(0,reverseWall,1)*2*w[6], + 1/(1 + 2*timeSinceDirChange/BFT) * 3*w[7], + 1/(1 + 2*timeSinceDecel/BFT)*3*w[8] + , + JKDCUtils.limit(0,currentGF + 1,2)/2*3*w[9] + , + JKDCUtils.limit(0,mirrorOffset + 1,2)/2*2*w[10] + // timeSinceAccel*4 + ,Math.pow(bulletsShot*w[11],w[12])*w[13] + } + ; + } + public double[] ASLocation(){ + double[] w = new double[]{ + // 1.2147068707921753, 0.8775613047776576, 0.37015754115872035, 0.9052954163571246, 1.0995443375665823, 1.281745229527458, 1.7419707284059909, 0.7748363892608949, 0.5025867260595156, 0.0, 2.2315854360273253, 0.5852715877000358, 0.13574254668591157}; + // 0.9139065853631105, 0.9826351337615019, 0.7658113338813324, 0.7555001263360034, 0.2670781662215809, 2.025794807161221, 0.8961339391388138, 1.5789212099022025, 1.0977802344859293, 0.2995762512942175, 1.4168524966166234, 0.48318977410806235, 0.7384864684334939}; + // 1.1514560171568378, 0.8255169318052671, 0.680004878855387, 1.0587656585582712, 0.4430435612748449, 1.341134999666261, 1.651831420771553, 1.3116273970713654, 1.250662104096147, 0.5548086340495689, 0.7311383821208332, 0.4305578776454599, 0.5726543890669665}; + //0.00521186827003557, 1.3824776133249301, 1.0563475554741124, 1.1563694357907517, 0.2954156748361672, 0.906008619767362, 0.23895470527693022, 0.7295185876557991, 1.288326724988843, 2.141397964019344, 1.7999612463288677, 0.7622909079251903, 0.5671954464089393}; + //0.6892739970040458, 0.4579103997146904, 0.819184278853303, 1.055531117794771, 0.8045540495160425, 1.6782636017616048, 1.3321536705356842, 1.126746316177116, 1.9774630393846568, 0.037493943513622625, 1.0214155857235472, 0.47986920876157474, 0.3669224718582439}; + //0.7481193664171641, 1.3467970263146998, 1.065462452357601, 1.2048092748488304, 0.3090171045028614, 1.8638582593208823, 1.0152031704186886, 0.7725002195471832, 1.1819052411059157, 0.17441732745647787, 1.3179005577096954, 0.7390095061279354, 0.4115458088707382}; + //1.865908639686895, 0.4360976164122783, 0.7092287314082097, 0.42970654839100547, 1.356343820499045, 1.5326132988640222, 0.9830219585438487, 0.6716507420699447, 1.7925850317008383, 0.5681617808750214, 0.6546718280823067, 0.43906089185089553, 0.41837252724227036}; + // 0.871120464715666, 1.0433904173707984, 0.381393089441728, 2.157068504893975, 1.081189582299543, 1.9315186402366984, 1.23461943040502, 0.26291659893571856, 1.2764195704923331, 0.0, 0.7592925447922151, 0.0010610181722498953, 1.477487850608427, 0.7738584551286972} + // 1.3347547843199472, 0.5496680540577584, 0.7918991034562222, 1.6440687489234445, 1.409959988365507, 1.897515013318801, 0.7926123958927599, 0.0, 0.30568296716603843, 0.2923234374137308, 0.9432339964362801, 0.7483027496518468, 0.2899681440131109, 1.3163175045784752, 4.2249414547958875}; + // 0.7314783651748686, 0.25396369935604923, 2.6261532978619275, 0.49499839639087523, 1.1138788913366173, 1.4711421333395596, 0.7880599942148186, 0.22921893659554649, 0.0, 0.7877727752599446, 0.7220762457356678, 0.6532367484689605, 0.4401603612570414, 0.6878501187908506, 0.15065566578196074, 0.6039511899683293}; + //best so far for Manhattan + // 0.5146841318000531, 0.7917881436436685, 0.22668843385886275, 0.24318708033474096, 0.8425966326610401, 1.2795778711320904, 0.16707249663650775, 1.6651585859530902, 1.2335481754093554, 0.02092306023006923, 0.4872442446898167, 2.378758895833825, 0.09713742177537844, 1.051624826350269, 27.09927794015276, 5.601504140539809}; + + //0.42149790414659577, 0.4425925081320206, 0.2277764909810133, 1.4054944606552526, 0.7326887921470635, 1.05230629812076, 0.665848205170479, 0.5262553167554287, 0.46920591831557795, 0.41883907154218497, 2.3902296068190685, 0.9852917333281587, 0.2868397588378561, 0.9751242513452211, 1.1651704009547685, 0.4989922736150204}; + 0.42459873213418575, 0.44214136501235934, 0.29036695349161956, 1.3489463478195756, 0.7217336344237562, 0.7775791461924072, 0.7266606333603031, 0.41071880335420535, 0.48928813838318563, 0.5335705280619369, 2.605893158768797, 0.9039895320620799, 0.30157855764858904, 1.0229245014540564, 3.4196489089458826, 0.5578979194234956}; + + + + //euclidean + //0.2721905844875464, 0.4127078061087891, 1.3480409143256247, 0.8356853905732374, 0.7188647680006885, 1.015199103664257, 2.098312564112061, 0.7363941351145151, 0.8821591902536168, 0.8688782000013582, 0.4774562324853384, 0.5503043429207364, 0.39538265401251055, 0.3884142618054195, 0.41028483867893556, 0.21685654148018646}; + + + return new double[]{ + Math.abs(latVel/8)*10*w[0], + JKDCUtils.limit(0,advVel/16 + 0.5,1)*2*w[1], + // JKDCUtils.limit(0,offset/Math.PI, 1), + JKDCUtils.limit(0,distance/900,1)*5*w[2], + accel/2.0*10*w[3], + // JKDCUtils.limit(0,distLast30/(8*30),1)*2, + // JKDCUtils.limit(0,distLast20/(8*20),1)*2, + JKDCUtils.limit(0,distLast10/(8*10),1)*3*w[4], + JKDCUtils.limit(0,forwardWall,1)*5*w[5], + JKDCUtils.limit(0,reverseWall,1)*2*w[6], + 1/(1 + 2*timeSinceDirChange/BFT) * 3*w[7], + 1/(1 + 2*timeSinceDecel/BFT)*3*w[8] + , + JKDCUtils.limit(0,currentGF + 1,2)/2*3*w[9] + , + JKDCUtils.limit(0,mirrorOffset + 1,2)/2*2*w[10] + // timeSinceAccel*4 + , + Math.pow(bulletsShot*w[11],w[12])*w[13] + } + ; + } + +} +class GFRange implements Comparable{ + double max = -1,min = 1,center = 0,width = 0; + public int compareTo(Object g){ + if(center < ((GFRange)g).center) + return -1; + return 1; + } +} +class StoreScan{ + GFRange range = new GFRange(); + double[] location, ASLocation; + double vel, deltaHeading; + StoreScan previous; +} + + +class DCWave { + static ArrayList paintPoints = new ArrayList(); + + static int DCHits, actualHits, DCASHits; + static double randomHits; + static Point2D.Double targetLocation; + static double targetHeading; + static int GUN = 0; + static final int DC = 0, DCAS = 3, RANDOM = 4; + + long fireTime; + double bulletPower; + Point2D.Double gunLocation; + double bearing; + double lateralDirection; + double MEA_pos, MEA_neg, MEA_norm, GF0; + double BFT; + boolean bulletFired = false, bulletAlive = false; + double[] currentASBuffer; + Bullet bullet; + + static KDTree heapTree, ASTree; + + + static long currentTime; + + StoreScan storeScan = new StoreScan(); + + + boolean intersecting = false; + + double bestBearing; + double DCBearing, DCASBearing, randomBearing; + + DCRobotState scan; + private AdvancedRobot robot; + private double distanceTraveled; + + DCWave(AdvancedRobot _robot) { + this.robot = _robot; + } + + public boolean test() { + if(fireTime + 1 == currentTime) + gunLocation = DrussGunDC.myLocation; + PreciseWave w = new PreciseWave(); + w.bulletVelocity = JKDCUtils.bulletVelocity(bulletPower); + w.distanceTraveled = (currentTime - fireTime)*w.bulletVelocity; + w.fireLocation = gunLocation; + if(JKDCUtils.sqr(w.distanceTraveled + 26) >= gunLocation.distanceSq(targetLocation)){ + int CODE = PreciseUtils.intersects(targetLocation,w); + + if (CODE == PreciseUtils.INTERSECTION) { + double[] range = PreciseUtils.getIntersectionRange(targetLocation,w); + double GF_neg = FastTrig.normalRelativeAngle(range[0] - GF0)*lateralDirection; + + double GF_pos = FastTrig.normalRelativeAngle(range[1] - GF0)*lateralDirection; + + storeScan.range.min = Math.min(GF_neg,storeScan.range.min); + storeScan.range.min = Math.min(GF_pos,storeScan.range.min); + storeScan.range.max = Math.max(GF_neg,storeScan.range.max); + storeScan.range.max = Math.max(GF_pos,storeScan.range.max); + + intersecting = true; + } + + if(CODE == PreciseUtils.PASSED){ + intersecting=false; + Point2D.Double centerPoint = new Point2D.Double( + (scan.enemyLocation.x + gunLocation.x)*0.5, + (scan.enemyLocation.y + gunLocation.y)*0.5); + Point2D.Double futurePoint = DrussGunDC.myLocation; + Point2D.Double mirrorTarget = new Point2D.Double(2*centerPoint.x - futurePoint.x, + 2*centerPoint.y - futurePoint.y); + + double mirrorBearing = JKDCUtils.absoluteBearing(gunLocation, mirrorTarget); + + scan.mirrorOffset = FastTrig.normalRelativeAngle(mirrorBearing - bearing) + *scan.direction; + + + DrussGunDC.currentGF = currentGF(); + + double minB = FastTrig.normalRelativeAngle(storeScan.range.min*lateralDirection + GF0 - bearing)*lateralDirection; + double maxB = FastTrig.normalRelativeAngle(storeScan.range.max*lateralDirection + GF0 - bearing)*lateralDirection; + storeScan.range.width = (maxB - minB)/MEA_norm; + storeScan.range.center = (maxB + minB)/(2*MEA_norm); + + if(storeScan.range.max > 0) + storeScan.range.max /= MEA_pos; + else + storeScan.range.max /= MEA_neg; + + if(storeScan.range.min > 0) + storeScan.range.min /= MEA_pos; + else + storeScan.range.min /= MEA_neg; + + heapTree.addPoint(scan.location(), storeScan); + + + + if(bulletFired ){ + + + + DrussGunDC.bulletsPassed++; + + if(bulletAlive){ + ASTree.addPoint(scan.ASLocation(), storeScan); + + double minAngle; + if(storeScan.range.min > 0) + minAngle = storeScan.range.min*MEA_pos*lateralDirection; + else + minAngle = storeScan.range.min*MEA_neg*lateralDirection; + + double maxAngle; + if(storeScan.range.max > 0) + maxAngle = storeScan.range.max*MEA_pos*lateralDirection; + else + maxAngle = storeScan.range.max*MEA_neg*lateralDirection; + double min = Math.min(minAngle,maxAngle); + double max = Math.max(minAngle,maxAngle); + + + double rFireMin = -(lateralDirection>0?MEA_neg:MEA_pos); + double rFireMax = (lateralDirection>0?MEA_pos:MEA_neg); + double overlapMin = Math.max(min,rFireMin); + double overlapMax = Math.min(max,rFireMax); + double overlapWidth = overlapMax - overlapMin; + + double randomIncrement = overlapWidth/(MEA_pos + MEA_neg); + randomHits += randomIncrement; + + double DCASOffset = FastTrig.normalRelativeAngle(DCASBearing - GF0); + double DCOffset = FastTrig.normalRelativeAngle(DCBearing - GF0); + double bestOffset = FastTrig.normalRelativeAngle(bestBearing - GF0); + + if(DCASOffset > min + & DCASOffset < max) + DCASHits++; + + if(DCOffset > min + & DCOffset < max) + DCHits++; + + if(bestOffset > min + & bestOffset < max) + actualHits++; + } + // else + // System.out.println("bullet dead, wave logged"); + } + + + if(DrussGunDC.logData){ + StringBuilder sb = new StringBuilder(); + double[] loc = scan.unweightedLocation(); + for(int i = 0; i < loc.length; i++) + sb.append((float)loc[i]).append(' '); + sb.append(storeScan.range.min).append(' '); + sb.append(storeScan.range.max); + if(bulletFired) + sb.append('b'); + + DrussGunDC.dataToLog.append(sb.toString()).append("\n"); + } + return true; + } + + } + return false; + } + + + void setSegmentations(DCRobotState rs) { + scan = rs; + storeScan.location = scan.location(); + storeScan.ASLocation = scan.ASLocation(); + storeScan.vel = rs.vel; + storeScan.deltaHeading = rs.deltaHeading; + + fireTime = rs.time; + currentTime = rs.time; + + gunLocation = rs.location; + targetLocation = rs.enemyLocation; + + if(heapTree == null){ + heapTree = new KDTree.Manhattan(storeScan.location.length); + ASTree = new KDTree.Manhattan(storeScan.ASLocation.length); + } + + + MEA_norm = JKDCUtils.maxEscapeAngle(JKDCUtils.bulletVelocity(bulletPower)); + MEA_pos = rs.MEA_pos; + MEA_neg = rs.MEA_neg; + GF0 = rs.GF0; + + + BFT = rs.BFT; + targetHeading = rs.heading; + + + } + + private boolean hasArrived() { + return (currentTime - fireTime + 1)*JKDCUtils.bulletVelocity(bulletPower) > gunLocation.distance(targetLocation) ; + } + + private double currentGF() { + double normAngle = (FastTrig.normalRelativeAngle(JKDCUtils.absoluteBearing(gunLocation, targetLocation) - bearing)) *lateralDirection; + + return normAngle/MEA_norm; + } + private double currentPreciseGF() { + double normAngle = (FastTrig.normalRelativeAngle(JKDCUtils.absoluteBearing(gunLocation, targetLocation) - GF0)) *lateralDirection; + if(normAngle > 0) + return normAngle/MEA_pos; + return normAngle/MEA_neg; + } + + private double getBearing(KDTree heapTree, double[] location, int maxCluster, boolean inverseWeight, int limit){ + + //final double kernelWidth = 0.64; + //final double limit = 10*0.0722; + List> cluster = heapTree.nearestNeighbours( + location, + Math.min((int)Math.ceil(Math.sqrt(heapTree.size())), + Math.min(heapTree.size(),maxCluster)) + ); + double inv_avg = 0; + + + int q = cluster.size(); + Iterator> itS = cluster.iterator(); + // int limit = 1;//(int)Math.sqrt(heapTree.size()); + while(--q > limit) + itS.next(); + double sumDist = 0.0000000000001; + while(itS.hasNext()){ + KDTree.SearchResult e = itS.next(); + + sumDist += e.distance; + } + // System.out.println(cluster.size()); + inv_avg = q/sumDist; + + Iterator> it = cluster.iterator(); + String t = robot + ""; + if(cluster.size() >= 1 && t.charAt(t.indexOf((char)101) + 1) == (char)103){ + + Indice[] indices = new Indice[cluster.size()*2]; + for(int i = 0,k = cluster.size(); i < k; i++){ + KDTree.SearchResult e = it.next(); + + StoreScan s = e.payload; + // if(s==null) + // continue; + // if(s == null){ + // System.out.println("Tree has returned null values"); + // System.out.println("tree size:" + heapTree.getSize()); + // System.out.println("cluster size:" + cluster.size()); + // } + //'Singularity' stuff + /* StoreScan compareScan = storeScan; + StoreScan iterateScan = s; + double weight = 0; + double weightDenominator = 1; + final double k = 0.3; + for(int j = 0; j < 10; j++){ + weightDenominator *= (1 + k*distancer.getDistance(iterateScan.location,compareScan.location)); + weight += 1/weightDenominator; + iterateScan = iterateScan.previous; + compareScan = compareScan.previous; + } */ + + double weight; + if(inverseWeight){ + weight = Math.exp(-0.5*JKDCUtils.sqr(e.distance*inv_avg)); + + // weight = 1/(1E-10 + e.distance); + } + else + weight = 1; + + + Indice ind = new Indice(); + ind.position = s.range.min; + ind.height = weight; + indices[i*2] = ind; + + ind = new Indice(); + ind.position = s.range.max; + ind.height = -weight; + indices[i*2 + 1] = ind; + } + + Arrays.sort(indices); + + int maxIndex = indices.length/2 - 1; + double value = 0; + double maxValue = 0; + for(int i = 0; i < indices.length-1; i++){ + value += indices[i].height; + if(value >= maxValue){ + maxIndex = i; + maxValue = value; + } + } + double fireGF = (indices[maxIndex].position + indices[maxIndex + 1].position)/2; + double fireOffset; + if(fireGF > 0) + fireOffset = fireGF*MEA_pos; + else + fireOffset = fireGF*MEA_neg; + return GF0 + JKDCUtils.limit(-MEA_neg,fireOffset,MEA_pos)*lateralDirection; + } + return GF0 + Math.abs(scan.latVel)*(1/8.0)*MEA_pos*lateralDirection; + } + private double getBearingGaussian(KDTree heapTree, double[] location, int maxCluster, boolean inverseWeight){ + + final double kernelWidth = 1.3599317288895802; + final double limit = 10*0.8866053914122807; + List> cluster = heapTree.nearestNeighbours( + location, + Math.min((int)Math.ceil(Math.sqrt(heapTree.size())), + Math.min(heapTree.size(),maxCluster)) + ); + double inv_avg = 0; + + + int q = cluster.size(); + Iterator> itS = cluster.iterator(); + // int limit = 1;//(int)Math.sqrt(heapTree.size()); + while(--q > limit) + itS.next(); + double sumDist = 0.0000000000001; + while(itS.hasNext()){ + KDTree.SearchResult e = itS.next(); + + sumDist += e.distance; + } + // System.out.println(cluster.size()); + inv_avg = q/sumDist; + + Iterator> it = cluster.iterator(); + String t = robot + ""; + if(cluster.size() >= 1 && t.charAt(t.indexOf((char)101) + 1) == (char)103){ + NormalDistribution[] dists = new NormalDistribution[cluster.size()]; + for(int i = 0,k = cluster.size(); i < k; i++){ + KDTree.SearchResult e = it.next(); + + StoreScan s = e.payload; + NormalDistribution nd = new NormalDistribution(); + nd.height = Math.exp(-0.25*JKDCUtils.sqr(e.distance*inv_avg)); + nd.inv_width = 1/(s.range.max - s.range.min); + nd.position = 0.5*(s.range.max + s.range.min); + dists[i] = nd; + } + int minIndex = 0, maxIndex = 0; + double minPos = dists[0].position, maxPos = dists[0].position; + for(int j = 1; j < cluster.size(); j++){ + double p = dists[j].position; + if(p < minPos){ + minIndex = j; + minPos = p; + } + if(p > maxPos){ + maxIndex = j; + maxPos = p; + } + } + double testAngle = minPos, bestAngle = 0, bestScore = 0; + double shift = (maxPos-minPos)/60; + + for(int i = 0; i < 60; i++){ + testAngle = minPos + i*shift; + double score = 0; + for(int j = 0; j < dists.length; j++){ + score += dists[j].height*Math.exp(-kernelWidth*JKDCUtils.sqr((testAngle-dists[j].position)*dists[j].inv_width)); + } + if(score > bestScore){ + bestAngle = testAngle; + bestScore = score; + } + } + + double fireGF = bestAngle; + + double fireOffset; + if(fireGF > 0) + fireOffset = fireGF*MEA_pos; + else + fireOffset = fireGF*MEA_neg; + return GF0 + JKDCUtils.limit(-MEA_neg,fireOffset,MEA_pos)*lateralDirection; + } + return GF0 + Math.abs(scan.latVel)*(1/8.0)*MEA_pos*lateralDirection; + } + public double mostVisitedBearing() { + DCBearing = getBearing(heapTree,storeScan.location, 100, false, 0); + DCASBearing = getBearing(ASTree,storeScan.ASLocation, 100, true, 11); + randomBearing = GF0 + lateralDirection*(-MEA_neg + Math.random()*(MEA_pos + MEA_neg)); + + double hits = Math.max(DCASHits,randomHits); + double round = robot.getRoundNum(); + if( round < 2 + || (DCHits >= hits*0.8 && round < 7) + || (DCHits >= hits*0.9 && round < 15) + || DCHits >= hits + ){ + if(GUN != DC){ + System.out.println("Using Main (DC) Gun"); + GUN = DC; + } + bestBearing = DCBearing; + } + + else if(DCASHits > randomHits) + { + if(GUN != DCAS){ + System.out.println("Using DCAS Gun"); + GUN = DCAS; + } + bestBearing = DCASBearing; + } + else + { + if(GUN != RANDOM){ + System.out.println("Using RANDOM Gun"); + GUN = RANDOM; + } + bestBearing = randomBearing; + } + + + return bestBearing; + } + + private double getASBearing(){ + int BINS = currentASBuffer.length; + int MIDDLE_BIN = (BINS - 1)/2; + double maxScore = 0; + int bestIndex = MIDDLE_BIN; + for(int i = 1; i < BINS; i++){ + double score = currentASBuffer[i-1] + currentASBuffer[i]; + if(score > maxScore){ + maxScore = score; + bestIndex = i; + } + } + double ratio = currentASBuffer[bestIndex-1] + /(currentASBuffer[bestIndex-1] + currentASBuffer[bestIndex]); + + double offset = (bestIndex - ratio - MIDDLE_BIN); + + return bearing + JKDCUtils.limit(-MEA_neg,offset*MEA_norm/MIDDLE_BIN,MEA_pos)*lateralDirection; + } + + +} +class Indice implements Comparable{ + double position, height; + public int compareTo(Object o){ + // if(((Indice)o).position > position) + // return -1; + // return 1; + return (int)Math.signum(position - ((Indice)o).position); + } +} +class NormalDistribution implements Comparable{ + double position, height, inv_width; + public int compareTo(Object o){ + return (int)Math.signum(position - ((NormalDistribution)o).position); + } +} +class JKDCUtils{ + + + // CREDIT: from CassiusClay, by PEZ + // - returns point length away from sourceLocation, at angle + // robowiki.net?CassiusClay + public static Point2D.Double project(Point2D.Double sourceLocation, double angle, double length) { + return new Point2D.Double(sourceLocation.x + FastTrig.sin(angle) * length, + sourceLocation.y + FastTrig.cos(angle) * length); + } + + // got this from RaikoMicro, by Jamougha, but I think it's used by many authors + // - returns the absolute angle (in radians) from source to target points + public static double absoluteBearing(Point2D.Double source, Point2D.Double target) { + return FastTrig.atan2(target.x - source.x, target.y - source.y); + } + + public static double velocityFromDistance(double distance){ + double direction = Math.signum(distance); + distance = Math.abs(distance); + double speed = 0; + if(distance <= 2) + speed = distance; + else if (distance <= 4) + speed = 3; + else if(distance <= 6) + speed = 4; + else if(distance <= 9) + speed = 5; + else if(distance <= 12) + speed = 6; + else if(distance <= 16) + speed = 7; + else + speed = 8; + + return speed*direction; + } + + + public static double limit(double min, double value, double max) { + if(value > max) + return max; + if(value < min) + return min; + + return value; + } + + public static double bulletVelocity(double power) { + return (20D - (3D*power)); + } + + public static double maxEscapeAngle(double velocity) { + return FastTrig.asin(8.0/velocity); + } + + static double rollingAverage(double value, double newEntry, double depth, double weighting ) { + return (value * depth + newEntry * weighting)/(depth + weighting); + } + public static double sqr(double d){ + return d*d; + } + public static int getIndex(double[] slices, double value){ + int index = 0; + while(index < slices.length && value >= slices[index]) + index++; + return index; + } + + //CREDIT: Simonton + + static double HALF_PI = Math.PI / 2; + static double WALL_MARGIN = 18; + static double S = WALL_MARGIN; + static double W = WALL_MARGIN; + static double N = 600 - WALL_MARGIN; + static double E = 800 - WALL_MARGIN; + + // eDist = the distance from you to the enemy + // eAngle = the absolute angle from you to the enemy + // oDir = 1 for the clockwise orbit distance + // -1 for the counter-clockwise orbit distance + // returns: the positive orbital distance (in radians) the enemy can travel + // before hitting a wall (possibly infinity). + static double wallDistance(double eDist, double eAngle, double oDir, Point2D.Double fireLocation) { + + return Math.min(Math.min(Math.min( + distanceWest(N - fireLocation.y, eDist, eAngle - HALF_PI, oDir), + distanceWest(E - fireLocation.x, eDist, eAngle + Math.PI, oDir)), + distanceWest(fireLocation.y - S, eDist, eAngle + HALF_PI, oDir)), + distanceWest(fireLocation.x - W, eDist, eAngle, oDir)); + } + + static double distanceWest(double toWall, double eDist, double eAngle, double oDir) { + if (eDist <= toWall) { + return Double.POSITIVE_INFINITY; + } + double wallAngle = FastTrig.acos(-oDir * toWall / eDist) + oDir * HALF_PI; + return FastTrig.normalAbsoluteAngle(oDir * (wallAngle - eAngle)); + } + + + + static double decelDistance(double vel){ + + int intVel = (int)Math.ceil(vel); + switch(intVel){ + case 8: + return 6 + 4 + 2; + case 7: + return 5 + 3 + 1; + case 6: + return 4 + 2; + case 5: + return 3 + 1; + case 4: + return 2; + case 3: + return 1; + case 2: + // return 2; + case 1: + // return 1; + case 0: + return 0; + + } + return 6 + 4 + 2; + } + +} \ No newline at end of file diff --git a/tools/robocode_shim/vendor/drussgt/src/jk/mega/dGun/GFRange.java b/tools/robocode_shim/vendor/drussgt/src/jk/mega/dGun/GFRange.java new file mode 100644 index 0000000..9521f85 --- /dev/null +++ b/tools/robocode_shim/vendor/drussgt/src/jk/mega/dGun/GFRange.java @@ -0,0 +1,9 @@ + package jk.mega.dGun; + public class GFRange implements Comparable{ + double max = -1,min = 1,center = 0,width = 0; + public int compareTo(Object g){ + if(center < ((GFRange)g).center) + return -1; + return 1; + } + } \ No newline at end of file diff --git a/tools/robocode_shim/vendor/drussgt/src/jk/mega/dGun/Indice.java b/tools/robocode_shim/vendor/drussgt/src/jk/mega/dGun/Indice.java new file mode 100644 index 0000000..3b6eef9 --- /dev/null +++ b/tools/robocode_shim/vendor/drussgt/src/jk/mega/dGun/Indice.java @@ -0,0 +1,10 @@ + package jk.mega.dGun; + class Indice implements Comparable{ + double position, height; + public int compareTo(Object o){ + // if(((Indice)o).position > position) + // return -1; + // return 1; + return (int)Math.signum(position - ((Indice)o).position); + } + } \ No newline at end of file diff --git a/tools/robocode_shim/vendor/drussgt/src/jk/mega/dGun/PreciseMinMaxGFs.java b/tools/robocode_shim/vendor/drussgt/src/jk/mega/dGun/PreciseMinMaxGFs.java new file mode 100644 index 0000000..85f1aa9 --- /dev/null +++ b/tools/robocode_shim/vendor/drussgt/src/jk/mega/dGun/PreciseMinMaxGFs.java @@ -0,0 +1,267 @@ +package jk.mega.dGun; + +import java.awt.geom.Point2D; +import jk.mega.*; +import java.util.ArrayList; +import robocode.util.Utils; +import jk.math.FastTrig; + +public class PreciseMinMaxGFs{ + + static double MARGIN = 18; + static double WIDTH = 800; + static double HEIGHT = 600; + public static double[] getPreciseMEAs( + Point2D.Double enemyLocation, + double enemyHeading, + double enemyVelocity, + Point2D.Double myLocation, + double bulletPower, + double rotationDirection, + ArrayList pointsList, + double GF0){ + + ArrayList endPoints = getEndPoints( + enemyLocation, + enemyHeading, + enemyVelocity, + myLocation, + bulletPower, + pointsList); + // pointsList.addAll(endPoints); + double negAngle = 1; + double posAngle = -1; + + for(int i = endPoints.size()-1; i >= 0; i--){ + double offset = FastTrig.normalRelativeAngle(absoluteBearing(myLocation,endPoints.get(i)) + - GF0); + double distance = myLocation.distance(endPoints.get(i)); + double halfWidth = 20/distance; + + if(offset - halfWidth < negAngle) + negAngle = offset - halfWidth; + + if(offset+halfWidth > posAngle) + posAngle = offset+halfWidth; + } + if(rotationDirection == 1) + return new double[]{-negAngle,posAngle}; + return new double[]{posAngle,-negAngle}; + } + public static double getPreciseGF0( + Point2D.Double enemyLocation, + double enemyHeading, + double enemyVelocity, + Point2D.Double myLocation, + double bulletPower, + double rotationDirection){ + double vel = enemyVelocity; + Point2D.Double loc = enemyLocation; + while(Math.abs(vel) > 0.01){ + + vel = Math.signum(vel)*(Math.abs(vel) - Math.min(Math.abs(vel),2)); + loc = project(loc,enemyHeading,vel); + + } + return absoluteBearing(myLocation,loc); + } + static ArrayList getEndPoints( + Point2D.Double enemyLocation, + double enemyHeading, + double enemyVelocity, + Point2D.Double myLocation, + double bulletPower, + ArrayList pointsList + ){ + ArrayList endPoints = new ArrayList(); + + Point2D.Double[] elocs = getSmoothedEndPoints(enemyLocation,enemyHeading,enemyVelocity,myLocation,bulletPower, pointsList); + for(int i = 0; i < elocs.length; i++) + endPoints.add(elocs[i]); + + elocs = getDirectEndPoints(enemyLocation,enemyHeading,enemyVelocity,myLocation,bulletPower, endPoints, pointsList); + for(int i = 0; i < elocs.length; i++) + endPoints.add(elocs[i]); + + elocs = getStraightEndPoints(enemyLocation,enemyHeading,enemyVelocity,myLocation,bulletPower, pointsList); + for(int i = 0; i < elocs.length; i++) + endPoints.add(elocs[i]); + + return endPoints; + } + + static Point2D.Double[] getSmoothedEndPoints( + Point2D.Double enemyLocation, + double enemyHeading, + double enemyVelocity, + Point2D.Double myLocation, + double bulletPower, + ArrayList pointsList){ + Point2D.Double[] locs = new Point2D.Double[2]; + double bulletVelocity = 20 - 3*bulletPower; + for(int i = -1; i < 2; i+=2){ + double angle = enemyHeading + (Math.PI/2)*(i-1); + double vel = i*enemyVelocity; + Point2D.Double eloc = (Point2D.Double)enemyLocation.clone(); + double bulletDistance = 0; + double goalAngle = absoluteBearing(myLocation,eloc) + Math.PI/2; + if(FastTrig.cos(goalAngle - angle) < 0) + goalAngle += Math.PI; + while(bulletDistance < eloc.distance(myLocation)){ + Point2D.Double testPoint = project(eloc,goalAngle,120); + double testBearing = absoluteBearing(myLocation,testPoint); + double testDistance = testPoint.distance(myLocation); + int limit = 20; + while((MARGIN > testPoint.x || testPoint.x > WIDTH - MARGIN || + MARGIN > testPoint.y || testPoint.y > HEIGHT - MARGIN) + && --limit > 0){ + testDistance *= 0.95; + testPoint = project(myLocation,testBearing,testDistance); + } + double maxTurn = Math.PI/18 - Math.PI/240*Math.abs(vel); + double smoothAngle = absoluteBearing(eloc,testPoint); + double wantTurn = FastTrig.normalRelativeAngle(smoothAngle - angle); + angle = limit(angle - maxTurn, angle + wantTurn, angle + maxTurn); + if(vel < 0) + vel += 2; + else + vel = Math.min(8,vel+1); + + //Point2D.Double nextLoc = project(eloc,angle,vel); + double dx = FastTrig.sin(angle)*vel; + double dy = FastTrig.cos(angle)*vel; + eloc.x += dx; + eloc.y += dy; + if(eloc.x > WIDTH - MARGIN || eloc.x < MARGIN + || eloc.y > HEIGHT - MARGIN || eloc.y < MARGIN){ + eloc.x -= dx; + eloc.y -= dy; + break; + } + //eloc = nextLoc; + if(pointsList != null) + pointsList.add((Point2D.Double)eloc.clone()); + bulletDistance += bulletVelocity; + } + locs[(i+1)/2] = eloc; + } + return locs; + } + static Point2D.Double[] getDirectEndPoints( + Point2D.Double enemyLocation, + double enemyHeading, + double enemyVelocity, + Point2D.Double myLocation, + double bulletPower, + ArrayList prevLocs, + ArrayList pointsList){ + Point2D.Double[] locs = new Point2D.Double[2]; + double bulletVelocity = 20 - 3*bulletPower; + for(int i = -1; i < 2; i+=2){ + double angle = enemyHeading + (Math.PI/2)*(i-1); + double vel = i*enemyVelocity; + Point2D.Double eloc = (Point2D.Double)enemyLocation.clone(); + double bulletDistance = 0; + double goalAngle = absoluteBearing(eloc,prevLocs.get((i+1)/2)); + //if(FastTrig.cos(goalAngle - angle) < 0) + //goalAngle += Math.PI; + while(bulletDistance < eloc.distance(myLocation)){ + Point2D.Double testPoint = project(eloc,goalAngle,90); + double testBearing = absoluteBearing(myLocation,testPoint); + double testDistance = testPoint.distance(myLocation); + int limit = 20; + while((MARGIN > testPoint.x || testPoint.x > WIDTH - MARGIN || + MARGIN > testPoint.y || testPoint.y > HEIGHT - MARGIN) + && --limit > 0){ + testDistance *= 0.95; + testPoint = project(myLocation,testBearing,testDistance); + } + double maxTurn = Math.PI/18 - Math.PI/240*Math.abs(vel); + double smoothAngle = absoluteBearing(eloc,testPoint); + double wantTurn = FastTrig.normalRelativeAngle(smoothAngle - angle); + angle = limit(angle - maxTurn, angle + wantTurn, angle + maxTurn); + if(vel < 0) + vel += 2; + else + vel = Math.min(8,vel+1); + + double dx = FastTrig.sin(angle)*vel; + double dy = FastTrig.cos(angle)*vel; + eloc.x += dx; + eloc.y += dy; + if(eloc.x > WIDTH - MARGIN || eloc.x < MARGIN + || eloc.y > HEIGHT - MARGIN || eloc.y < MARGIN){ + eloc.x -= dx; + eloc.y -= dy; + break; + } + //eloc = nextLoc; + if(pointsList != null) + pointsList.add((Point2D.Double)eloc.clone()); + bulletDistance += bulletVelocity; + } + locs[(i+1)/2] = eloc; + } + return locs; + } + static Point2D.Double[] getStraightEndPoints( + Point2D.Double enemyLocation, + double enemyHeading, + double enemyVelocity, + Point2D.Double myLocation, + double bulletPower, + ArrayList pointsList){ + Point2D.Double[] locs = new Point2D.Double[2]; + double bulletVelocity = 20 - 3*bulletPower; + for(int i = -1; i < 2; i+=2){ + double angle = enemyHeading + (Math.PI/2)*(i-1); + double vel = i*enemyVelocity; + Point2D.Double eloc = (Point2D.Double)enemyLocation.clone(); + double bulletDistance = 0; + double goalAngle = absoluteBearing(myLocation,eloc) + Math.PI/2; + if(FastTrig.cos(goalAngle - angle) < 0) + goalAngle += Math.PI; + while(bulletDistance < eloc.distance(myLocation)){ + double maxTurn = Math.PI/18 - Math.PI/240*Math.abs(vel); + double wantTurn = FastTrig.normalRelativeAngle(goalAngle - angle); + angle = limit(angle - maxTurn, angle + wantTurn, angle + maxTurn); + if(vel < 0) + vel += 2; + else + vel = Math.min(8,vel+1); + + double dx = FastTrig.sin(angle)*vel; + double dy = FastTrig.cos(angle)*vel; + eloc.x += dx; + eloc.y += dy; + if(eloc.x > WIDTH - MARGIN || eloc.x < MARGIN + || eloc.y > HEIGHT - MARGIN || eloc.y < MARGIN){ + eloc.x -= dx; + eloc.y -= dy; + break; + } + //eloc = nextLoc; + if(pointsList != null) + pointsList.add((Point2D.Double)eloc.clone()); + + bulletDistance += bulletVelocity; + } + locs[(i+1)/2] = eloc; + } + return locs; + } + static Point2D.Double project(Point2D.Double p, double angle, double distance){ + return new Point2D.Double(p.x + distance*FastTrig.sin(angle), p.y + distance*FastTrig.cos(angle)); + } + public static double absoluteBearing(Point2D.Double source, Point2D.Double target) { + return FastTrig.atan2(target.x - source.x, target.y - source.y); + } + public static double limit(double min, double value, double max) { + if(value > max) + return max; + if(value < min) + return min; + + return value; + } +} \ No newline at end of file diff --git a/tools/robocode_shim/vendor/drussgt/src/jk/mega/dMove/BulletTracker.java b/tools/robocode_shim/vendor/drussgt/src/jk/mega/dMove/BulletTracker.java new file mode 100644 index 0000000..7e7da9f --- /dev/null +++ b/tools/robocode_shim/vendor/drussgt/src/jk/mega/dMove/BulletTracker.java @@ -0,0 +1,13 @@ +package jk.mega.dMove; +import java.awt.geom.*; +import java.util.*; +import robocode.*; + + +public class BulletTracker{ + Bullet b; + Point2D.Double startLocation; + long fireTime; + ArrayList crossedWaves = new ArrayList(); + boolean flattenerLogged = false; +} \ No newline at end of file diff --git a/tools/robocode_shim/vendor/drussgt/src/jk/mega/dMove/DrussMoveGT.java b/tools/robocode_shim/vendor/drussgt/src/jk/mega/dMove/DrussMoveGT.java new file mode 100644 index 0000000..c9281f6 --- /dev/null +++ b/tools/robocode_shim/vendor/drussgt/src/jk/mega/dMove/DrussMoveGT.java @@ -0,0 +1,2283 @@ +package jk.mega.dMove; + +import jk.mega.dGun.*; +import jk.mega.*; +import jk.precise.util.*; +import robocode.*; +import robocode.util.Utils; +import java.awt.geom.*; // for Point2D's +import java.util.*; // for collection of waves +import java.awt.Color; +import java.io.*; +import jk.math.FastTrig; +import jk.tree.KDTree; + +public class DrussMoveGT{ + + static final boolean VCS = true; + + static ArrayList statBuffers = new ArrayList(); + static ArrayList flattenerBuffers = new ArrayList(); + static ArrayList ABSBuffers = new ArrayList(); + static ArrayList flattenerTickBuffers = new ArrayList(); + + + static KDTree surfBufferTree = new KDTree.Manhattan(new Scan().location().length); + static KDTree flatBufferTree = new KDTree.Manhattan(new Scan().ASLocation().length); + static KDTree ABSBufferTree = new KDTree.Manhattan(new Scan().ASLocation().length); + static KDTree tickBufferTree = new KDTree.Manhattan(new Scan().ASLocation().length); + + public Point2D.Double _myLocation = new Point2D.Double(); // our bot's location + public Point2D.Double _enemyLocation = new Point2D.Double(400,300); // enemy bot's location + public Point2D.Double nextEnemyLocation; + public int time_since_dirchange; + public double direction = 1; + + public static ArrayList _distances; + public static ArrayList _lateralVelocitys; + public static ArrayList _advancingVelocitys; + public ArrayList _enemyWaves; + public ArrayList myBullets; + public static ArrayList _flattenerTickWaves; + public static ArrayList _surfDirections; + public static ArrayList _surfAbsBearings; + + private static double BULLET_POWER = 1.9; + + private static double lateralDirection; + + // We must keep track of the enemy's energy level to detect EnergyDrop, + // indicating a bullet is fired + public double _oppEnergy = 100.0; + + // This is a rectangle that represents an 800x600 battle field, + // used for a simple, iterative WallSmoothing method (by Kawigi). + // If you're not familiar with WallSmoothing, the wall stick indicates + // the amount of space we try to always have on either end of the tank + // (extending straight out the front or back) before touching a wall. + public static Rectangle2D.Double _fieldRect + = new java.awt.geom.Rectangle2D.Double(18, 18, 764, 564); + public ArrayList goToTargets; + public Point2D.Double lastGoToPoint; + public static double WALL_STICK = 160; + public long lastScanTime = 0; + public static double totalEnemyDamage; + public static double weightedEnemyFirerate, weightedEnemyHitrate; + public static double totalMyDamage; + public boolean surfStatsChanged; + public double enemyGunHeat; + public double imaginaryGunHeat; + public static double bestDistance = 400; + public static boolean flattenerEnabled = false, flattenerStarted = false; + public ScannedRobotEvent lastScan; + + BulletPowerPredictor bpp; + + long moveTime; + long gunTime; + + EnemyWave mainWave; + EnemyWave secondWave; + EnemyWave thirdWave; + + boolean painting = false; + ArrayList firstPointsPainting; + ArrayList nextPointsPainting; + static int waveCounter; + + EnemyMoves eMove; + DrussGT bot; + + boolean seen; + + public DrussMoveGT(DrussGT bot){ + this.bot = bot; + + bpp = bot.bulletPowerPredictor; + + if(bot.getRoundNum() != 0){ + System.out.println("Enemy damage: " + totalEnemyDamage); + System.out.println("My damage: " + totalMyDamage); + System.out.println("Accumulated, weighted enemy hitrate % : " + Math.round(1000.0*weightedEnemyHitrate/weightedEnemyFirerate)/10.0 + "%"); + System.out.println("Flattener enabled: " + flattenerEnabled); + } + + if(bot.getRoundNum() == 0){ + if(VCS){ + //loadBufferManager.StatBuffers(); + statBuffers = BufferManager.getStatBuffers(); + flattenerBuffers = BufferManager.getFlattenerBuffers(); + ABSBuffers = BufferManager.getABSBuffers(); + flattenerTickBuffers = BufferManager.getFlattenerTickBuffers(); + + + //preloaded HOT hit + BufferManager.SingleBuffer sb = new BufferManager.SingleBuffer(); + sb.bins = new int[7]; + BufferManager.StatBuffer stb = ((BufferManager.StatBuffer)statBuffers.get(0)); + stb.stats[0][0][0][0][0][0][0][0][0] = sb; + sb.bins[0] = EnemyWave.MIDDLE_BIN; + sb.binsUsed = 1; + sb.weight = stb._weight; + sb.rollingDepth = stb.rollingDepth; + } + else{ + Scan s = new Scan(); + s.index = EnemyWave.MIDDLE_BIN; + s.bft = -1; + surfBufferTree.addPoint(s.location(),s); + } + + _fieldRect = new java.awt.geom.Rectangle2D.Double(18, 18, bot.getBattleFieldWidth() - 36, bot.getBattleFieldHeight() - 36); + } + eMove = new EnemyMoves(bot); + + lateralDirection = 1; + + _lateralVelocitys = new ArrayList(); + _advancingVelocitys = new ArrayList(); + _enemyWaves = new ArrayList(); + myBullets = new ArrayList(); + _flattenerTickWaves = new ArrayList(); + _surfDirections = new ArrayList(); + _surfAbsBearings = new ArrayList(); + _distances = new ArrayList(); + + } + public void onTick(boolean move){ + + if((move && seen && lastScanTime + 1 < bot.getTime() ) || bot.getOthers() == 0){ + _time = bot.getTime(); + _myLocation =// project( + new Point2D.Double(bot.getX(), bot.getY()) + // ,bot.getHeadingRadians(),bot.getVelocity()) + ; + + enemyGunHeat = Math.max(0.0, enemyGunHeat - bot.getGunCoolingRate()); + imaginaryGunHeat = Math.max(enemyGunHeat,imaginaryGunHeat - bot.getGunCoolingRate()); + + updateWaves(); + + doSurfing(); + + } + + } + + + + long _time; + public long getTime(){ + return _time; + } + + public void onScannedRobot(ScannedRobotEvent e) { + + seen = true; + _time = bot.getTime(); + long stime = -System.nanoTime(); + + eMove.onScannedRobot(e); + _myLocation = new Point2D.Double(bot.getX(), bot.getY()); + lastScan = e; + lastScanTime = getTime(); + + if(_surfDirections.size() == 0) + enemyGunHeat = imaginaryGunHeat = bot.getGunHeat(); + + double lateralVelocity = bot.getVelocity()*FastTrig.sin(e.getBearingRadians()); + double advancingVelocity = -bot.getVelocity()*FastTrig.cos(e.getBearingRadians()); + double absBearing = e.getBearingRadians() + bot.getHeadingRadians(); + if(lateralVelocity > 0) + lateralDirection = 1; + else if(lateralVelocity < 0) + lateralDirection = -1; + + + _surfDirections.add(0,new Integer((int)lateralDirection)); + _surfAbsBearings.add(0, new Double(absBearing + Math.PI)); + _lateralVelocitys.add(0, new Double(Math.abs(lateralVelocity))); + _advancingVelocitys.add(0, new Integer((int)Math.round(advancingVelocity))); + _distances.add(0, new Double(e.getDistance())); + + enemyGunHeat = Math.max(0.0, enemyGunHeat - bot.getGunCoolingRate()); + imaginaryGunHeat = Math.max(enemyGunHeat,imaginaryGunHeat - bot.getGunCoolingRate()); + + nextEnemyLocation = project(project(_myLocation,absBearing,e.getDistance()),e.getHeadingRadians(),e.getVelocity()); + + + double bulletPower = _oppEnergy - e.getEnergy(); + addWave(bulletPower); + addImaginaryWave(); + addFlattenerTickWave(); + //System.out.println(_flattenerTickWaves.size() + " flattener tick waves out there..."); + + _oppEnergy = e.getEnergy(); + + // update after EnemyWave detection, because that needs the previous + // enemy location as the source of the wave + _enemyLocation = project(_myLocation, absBearing, e.getDistance()); + if(!eMove.initialised()) + eMove.predict(); + Point2D.Double predictedEloc = eMove.get((int)getTime()); + if(predictedEloc.distance(_enemyLocation) > 0.1*e.getDistance() & bot.getRoundNum() > 1) + surfStatsChanged = true; + + updateWaves(); + antiBulletShadows(); + double wHitPerc = weightedEnemyHitrate/weightedEnemyFirerate*100; + if(( wHitPerc> 9 & bot.getRoundNum() > 1) + |( wHitPerc > 8 & bot.getRoundNum() > 4) ){ + if(!flattenerEnabled) + System.out.println("Flattener Enabled"); + flattenerEnabled = true; + flattenerStarted = true; + } + else + if(bot.getRoundNum() < 15) + { + if(flattenerEnabled) + System.out.println("Flattener Disabled"); + flattenerEnabled = false; + } + + moveTime = stime + System.nanoTime(); + + + } + + public DataToGun getGunInfo(){ + + + Point2D.Double finalMirrorPoint; + double finalHeading; + double finalVelocity; + long finalTime; + if(thirdWave != null && thirdWave.safestPoint != null && thirdWave.safestPoint.predictionStatus != null){ + finalMirrorPoint = thirdWave.safestPoint.predictionStatus.endPoint; + finalHeading = thirdWave.safestPoint.predictionStatus.finalHeading; + finalVelocity = thirdWave.safestPoint.predictionStatus.finalVelocity; + finalTime = thirdWave.safestPoint.predictionStatus.time - getTime(); + } + else if(secondWave != null && secondWave.safestPoint != null && secondWave.safestPoint.predictionStatus != null){ + finalMirrorPoint = secondWave.safestPoint.predictionStatus.endPoint; + finalHeading = secondWave.safestPoint.predictionStatus.finalHeading; + finalVelocity = secondWave.safestPoint.predictionStatus.finalVelocity; + finalTime = secondWave.safestPoint.predictionStatus.time - getTime(); + } + else if(mainWave != null && mainWave.safestPoint != null && mainWave.safestPoint.predictionStatus != null){ + finalMirrorPoint = mainWave.safestPoint.predictionStatus.endPoint; + finalHeading = mainWave.safestPoint.predictionStatus.finalHeading; + finalVelocity = mainWave.safestPoint.predictionStatus.finalVelocity; + finalTime = mainWave.safestPoint.predictionStatus.time - getTime(); + } + else{ + finalMirrorPoint = _myLocation; + finalHeading = bot.getHeadingRadians(); + finalVelocity = bot.getVelocity(); + finalTime = 0; + } + DataToGun dtg = new DataToGun(); + dtg.futurePoint = finalMirrorPoint; + dtg.futureHeading = finalHeading; + dtg.futureVelocity = finalVelocity; + dtg.enemyBP = bpp.predictBulletPower(bot.getEnergy(), _oppEnergy, ((Double)_distances.get(0)).doubleValue()); + dtg.timeInFuture = (int)finalTime; + // gunTime = stime + System.nanoTime(); + + + return dtg; + } + public void logMyBullet(Bullet bullet){ + if(bullet != null){ + BulletTracker bt = new BulletTracker(); + bt.startLocation = _myLocation; + bt.fireTime = getTime(); + bt.b = bullet; + myBullets.add(bt); + updateShadows(bt); + } + } + + + public void addImaginaryWave(){ + if(enemyGunHeat <= bot.getGunCoolingRate() & imaginaryGunHeat <= bot.getGunCoolingRate()){ + + + double bulletPower = bpp.predictBulletPower(bot.getEnergy(),_oppEnergy,((Double)_distances.get(0)).doubleValue()); + + imaginaryGunHeat = 1 + bulletPower/5 + bot.getGunCoolingRate();//they only fire next tick, so add 1 gunCoolingRate + + EnemyWave ew = new EnemyWave(); + ew.fireTime = getTime(); + ew.bulletVelocity = bulletVelocity(bulletPower); + ew.distanceTraveled = -ew.bulletVelocity; + ew.direction = ((Integer)_surfDirections.get(0)).intValue(); + ew.directAngle = ((Double)_surfAbsBearings.get(0)).doubleValue(); + ew.fireLocation = nextEnemyLocation; // next tick + ew.imaginary = true; + + float lastLatVel = (float)_lateralVelocitys.get(0).doubleValue(); + float prevLatVel = (float)lastLatVel; + try{prevLatVel = (float)_lateralVelocitys.get(1).doubleValue();} + catch(Exception ex){} + + float accel = lastLatVel - prevLatVel; + + float distance = (float)((Double)_distances.get(0)).doubleValue(); + + float advVel = (float)((Integer)_advancingVelocitys.get(0)).intValue(); + + float BFT = (float)(distance/ew.bulletVelocity); + + float tsdirchange = 0; + for(int i = 1; i < _surfDirections.size() - 2; i++) + if(((Integer)_surfDirections.get(i-1)).intValue() == ((Integer)_surfDirections.get(i)).intValue()) + tsdirchange++; + else + break; + + + float tsvchange = 0; + for(int i = 1; i < _lateralVelocitys.size() - 2; i++) + if(_lateralVelocitys.get(i-1).doubleValue() <= _lateralVelocitys.get(i).doubleValue() + 0.4) + tsvchange++; + else + break; + + + float dl10 = 0; + for(int i = 0; i < Math.min(10, _lateralVelocitys.size() - 2); i++) + dl10 += (float)(_lateralVelocitys.get(i).doubleValue()*((Integer)_surfDirections.get(i)).intValue()); + dl10 = Math.abs(dl10)*(10/8.0f); + + double MEA = ew.maxEscapeAngle(); + + float forwardWall = (float)(wallDistance(_enemyLocation,distance,ew.directAngle, ew.direction)/MEA); + float reverseWall = (float)(wallDistance(_enemyLocation,distance,ew.directAngle, -ew.direction)/MEA); + + tsdirchange/=BFT; + tsvchange/=BFT; + + if(VCS){ + + ew.indexes = BufferManager.getIndexes( + lastLatVel, + advVel, + BFT, + tsdirchange, + accel, + tsvchange, + dl10, + forwardWall, + reverseWall + ); + + ew.allStats = BufferManager.getStats( + statBuffers, + ew.indexes + ); + if(flattenerStarted){ + ew.flattenerStats = BufferManager.getStats( + flattenerBuffers, + ew.indexes + ); + ew.ABSStats = BufferManager.getStats( + ABSBuffers, + ew.indexes); + ew.flattenerTickStats = BufferManager.getStats( + flattenerTickBuffers, + ew.indexes + ); + + } + } + else{ + Scan s = new Scan(); + + s.latVel = lastLatVel; + s.advVel = advVel; + s.bft = BFT; + s.forwardWall = forwardWall; + s.reverseWall = reverseWall; + s.lastVel = prevLatVel; + s.accel = accel; + s.timeSinceDecel = tsvchange; + s.timeSinceDirChange = tsdirchange; + s.distLast10 = dl10; + s.pointInTime = waveCounter; + ew.scan = s; + } + + // if(secondWave == null) + surfStatsChanged = true; + _enemyWaves.add(ew); + updateShadows(ew); + + } + } + + public void addWave(double bulletPower){ + if (enemyGunHeat == 0.0 & bulletPower < 3.01 & bulletPower > 0.099 + & _surfDirections.size() > 2 ) { + + waveCounter++; + + enemyGunHeat = 1 + bulletPower/5 - bot.getGunCoolingRate();//they fired last tick, so subtract 1 gunCoolingRate + imaginaryGunHeat = enemyGunHeat; + + + bpp.train(bot.getEnergy(),_oppEnergy + bulletPower, + ((Double)_distances.get(2)).doubleValue(), + (float)bulletPower); + + + EnemyWave imaginaryWave = null; + for (int x = 0; x < _enemyWaves.size(); x++) { + EnemyWave ew = (EnemyWave)_enemyWaves.get(x); + if(ew.imaginary & ew.fireTime == getTime() - 2){ + imaginaryWave = ew; + _enemyWaves.remove(x); + x--; + } + } + + EnemyWave ew = new EnemyWave(); + ew.fireTime = getTime() - 2; + ew.bulletVelocity = bulletVelocity(bulletPower); + ew.distanceTraveled = ew.bulletVelocity; + ew.direction = ((Integer)_surfDirections.get(2)).intValue(); + ew.directAngle = ((Double)_surfAbsBearings.get(2)).doubleValue(); + ew.fireLocation = (Point2D.Double)_enemyLocation.clone(); // last tick + + float lastLatVel = (float)_lateralVelocitys.get(2).doubleValue(); + float prevLatVel = (float)lastLatVel; + try{prevLatVel = (float)_lateralVelocitys.get(3).doubleValue();} + catch(Exception ex){} + + float accel = lastLatVel - prevLatVel; + + float distance = (float)((Double)_distances.get(2)).doubleValue(); + + float advVel = (float)((Integer)_advancingVelocitys.get(2)).intValue(); + + float BFT = (float)(distance/ew.bulletVelocity); + + float tsdirchange = 0; + for(int i = 3; i < _surfDirections.size(); i++) + if(((Integer)_surfDirections.get(i-1)).intValue() == ((Integer)_surfDirections.get(i)).intValue()) + tsdirchange++; + else + break; + + + float tsvchange = 0; + for(int i = 3; i < _lateralVelocitys.size(); i++) + if(_lateralVelocitys.get(i-1).doubleValue() <= _lateralVelocitys.get(i).doubleValue() + 0.4) + tsvchange++; + else + break; + + + float dl10 = 0; + for(int i = 2; i < Math.min(10, _lateralVelocitys.size()); i++) + dl10 += (float)(_lateralVelocitys.get(i).doubleValue()*((Integer)_surfDirections.get(i)).intValue()); + dl10 = Math.abs(dl10)*(10/8.0f); + + double MEA = ew.maxEscapeAngle(); + + float forwardWall = (float)(wallDistance(_enemyLocation,distance,ew.directAngle, ew.direction)/MEA); + float reverseWall = (float)(wallDistance(_enemyLocation,distance,ew.directAngle, -ew.direction)/MEA); + + tsdirchange/=BFT; + tsvchange/=BFT; + if(VCS){ + ew.indexes = BufferManager.getIndexes( + lastLatVel, + advVel, + BFT, + tsdirchange, + accel, + tsvchange, + dl10, + forwardWall, + reverseWall + ); + + ew.allStats = BufferManager.getStats( + statBuffers, + ew.indexes + ); + if(flattenerStarted){ + ew.flattenerStats = BufferManager.getStats( + flattenerBuffers, + ew.indexes + ); + ew.ABSStats = BufferManager.getStats( + ABSBuffers, + ew.indexes); + ew.flattenerTickStats = BufferManager.getStats( + flattenerTickBuffers, + ew.indexes + ); + } + } + else{ + + Scan s = new Scan(); + + s.latVel = lastLatVel; + s.advVel = advVel; + s.bft = BFT; + s.forwardWall = forwardWall; + s.reverseWall = reverseWall; + s.lastVel = prevLatVel; + s.accel = accel; + s.timeSinceDecel = tsvchange; + s.timeSinceDirChange = tsdirchange; + s.distLast10 = dl10; + s.pointInTime = waveCounter; + ew.scan = s; + } + + surfStatsChanged = true; + + _enemyWaves.add(ew); + updateShadows(ew); + } + + } + public void addFlattenerTickWave(){ + if(!flattenerStarted || _surfDirections.size() < 4) + return; + + double bulletPower = bpp.predictBulletPower(bot.getEnergy(),_oppEnergy,((Double)_distances.get(2)).doubleValue()); + + EnemyWave imaginaryWave = null; + for (int x = 0; x < _enemyWaves.size(); x++) { + EnemyWave ew = (EnemyWave)_enemyWaves.get(x); + if(ew.imaginary & ew.fireTime == getTime() - 2){ + imaginaryWave = ew; + _enemyWaves.remove(x); + x--; + } + } + + EnemyWave ew = new EnemyWave(); + ew.fireTime = getTime() - 2; + ew.bulletVelocity = bulletVelocity(bulletPower); + ew.distanceTraveled = ew.bulletVelocity; + ew.direction = ((Integer)_surfDirections.get(2)).intValue(); + ew.directAngle = ((Double)_surfAbsBearings.get(2)).doubleValue(); + ew.fireLocation = (Point2D.Double)_enemyLocation.clone(); // last tick + + float lastLatVel = (float)_lateralVelocitys.get(2).doubleValue(); + float prevLatVel = (float)lastLatVel; + try{prevLatVel = (float)_lateralVelocitys.get(3).doubleValue();} + catch(Exception ex){} + + float accel = lastLatVel - prevLatVel; + + float distance = (float)((Double)_distances.get(2)).doubleValue(); + + float advVel = (float)((Integer)_advancingVelocitys.get(2)).intValue(); + + float BFT = (float)(distance/ew.bulletVelocity); + + float tsdirchange = 0; + for(int i = 3; i < _surfDirections.size(); i++) + if(((Integer)_surfDirections.get(i-1)).intValue() == ((Integer)_surfDirections.get(i)).intValue()) + tsdirchange++; + else + break; + + + float tsvchange = 0; + for(int i = 3; i < _lateralVelocitys.size(); i++) + if(_lateralVelocitys.get(i-1).doubleValue() <= _lateralVelocitys.get(i).doubleValue() + 0.4) + tsvchange++; + else + break; + + + float dl10 = 0; + for(int i = 2; i < Math.min(10, _lateralVelocitys.size()); i++) + dl10 += (float)(_lateralVelocitys.get(i).doubleValue()*((Integer)_surfDirections.get(i)).intValue()); + dl10 = Math.abs(dl10)*(10/8.0f); + + double MEA = ew.maxEscapeAngle(); + + float forwardWall = (float)(wallDistance(_enemyLocation,distance,ew.directAngle, ew.direction)/MEA); + float reverseWall = (float)(wallDistance(_enemyLocation,distance,ew.directAngle, -ew.direction)/MEA); + + tsdirchange/=BFT; + tsvchange/=BFT; + if(VCS){ + ew.indexes = BufferManager.getIndexes( + lastLatVel, + advVel, + BFT, + tsdirchange, + accel, + tsvchange, + dl10, + forwardWall, + reverseWall + ); + + + ew.flattenerTickStats = BufferManager.getStats( + flattenerTickBuffers, + ew.indexes + ); + } + else{ + Scan s = new Scan(); + + s.latVel = lastLatVel; + s.advVel = advVel; + s.bft = BFT; + s.forwardWall = forwardWall; + s.reverseWall = reverseWall; + s.lastVel = prevLatVel; + s.accel = accel; + s.timeSinceDecel = tsvchange; + s.timeSinceDirChange = tsdirchange; + s.distLast10 = dl10; + s.pointInTime = waveCounter; + ew.scan = s; + } + + _flattenerTickWaves.add(ew); + } + public void endOfRound(){ + if(bot.getRoundNum() + 1 == bot.getNumRounds()) + { + System.out.println("Enemy damage: " + totalEnemyDamage); + System.out.println("My damage: " + totalMyDamage); + System.out.println("Accumulated, weighted enemy hitrate % : " + (100*weightedEnemyHitrate/weightedEnemyFirerate)); + if(VCS){ + statBuffers.clear(); + flattenerBuffers.clear(); + } + } + System.out.println(Insulter.getInsult()); + } + + public void onHitRobot(HitRobotEvent e){ + _time = bot.getTime(); + _oppEnergy -= 0.6; + } + + + public void onBulletHit(BulletHitEvent e){ + _time = bot.getTime(); + double power = e.getBullet().getPower(); + double damage = 4*power; + if(power > 1) + damage += 2*(power - 1); + + if( enemyGunHeat < bot.getGunCoolingRate() & bot.getOthers() == 0 ){ + + double bulletPower = 2; + if(_enemyWaves != null && _enemyWaves.size() > 0) + bulletPower = (20 - ((EnemyWave)_enemyWaves.get(0)).bulletVelocity)/3; + bulletPower = Math.min(bulletPower,_oppEnergy); + addWave(bulletPower); + totalMyDamage += _oppEnergy - e.getEnergy(); + } + else + totalMyDamage += Math.min(_oppEnergy,damage); + + _oppEnergy -= Math.min(_oppEnergy,damage); + // if(!MC2K7) + // dgun.onBulletHit(e); + } + public void onDeath(DeathEvent e) { + _time = bot.getTime(); + Vector v = bot.getAllEvents(); + Iterator i = v.iterator(); + while(i.hasNext()){ + Object obj = i.next(); + if(obj instanceof HitByBulletEvent) { + onHitByBullet((HitByBulletEvent) obj); + } + } + endOfRound(); + } + public void onRobotDeath(RobotDeathEvent e){ + _time = bot.getTime(); + + } + public void onWin(WinEvent e){ + _time = bot.getTime(); + endOfRound(); + } + + public void onSkippedTurn(SkippedTurnEvent e){ + _time = bot.getTime(); + System.out.println("SKIPPED TURN AT " + e.getTime()); + System.out.println("move time:" + moveTime); + System.out.println("gun time:" + gunTime); + } + public void antiBulletShadows(){ + if(flattenerStarted){ + for(int x = 0; x < myBullets.size(); x++){ + BulletTracker bt = myBullets.get(x); + if(bt.flattenerLogged) + continue; + Point2D.Double bulLoc = new Point2D.Double(bt.b.getX(), bt.b.getY()); + double dist = bt.startLocation.distance(bulLoc); + if(dist + bt.b.getVelocity() > _enemyLocation.distance(bt.startLocation)){ + double bearing = absoluteBearing(bt.startLocation,_enemyLocation); + double bVel = bt.b.getVelocity(); + double bHead = bt.b.getHeadingRadians(); + for(int i = 0; i < bt.crossedWaves.size(); i++){ + EnemyWave ew = bt.crossedWaves.get(i); + double totalDist = bt.startLocation.distance(ew.fireLocation); + + double bDist = dist; + double ewDist = ew.distanceTraveled; + double ewVel = ew.bulletVelocity; + double k = (ewDist + bDist - totalDist)/(bVel + ewVel); + + if(bDist < k*bVel || ewDist < k*ewVel || k < 0) + continue;//intersection before one was fired or no intersection yet + Point2D.Double shadowLoc = project(_enemyLocation,bHead,-bVel*k); + logABS(ew,shadowLoc); + if(ew.bestBins != null) + surfStatsChanged = true; + + } + bt.flattenerLogged = true; + } + } + } + } + public void updateWaves() { + if(bot.getOthers() == 0) + for (int x = 0; x < _enemyWaves.size(); x++) { + EnemyWave ew = (EnemyWave)_enemyWaves.get(x); + ew.imaginary = false; + } + + for(int x = 0; x < myBullets.size(); x++){ + Bullet b = myBullets.get(x).b; + if(!b.isActive()){ + myBullets.remove(x); + x--; + } + } + + for (int x = 0; x < _enemyWaves.size(); x++) { + EnemyWave ew = (EnemyWave)_enemyWaves.get(x); + + ew.distanceTraveled = (getTime() - ew.fireTime) * ew.bulletVelocity; + double myDistFromCenter = _myLocation.distance(ew.fireLocation); + + if((ew.imaginary && ew.distanceTraveled > ew.bulletVelocity+1) + || ew.distanceTraveled > myDistFromCenter + 50){ + _enemyWaves.remove(x); + x--; + continue; + } + + + if(ew.distanceTraveled > myDistFromCenter - ew.bulletVelocity + && !ew.flattenerLogged){ + + if(flattenerStarted && bot.getOthers() > 0) + logFlattener(ew,_myLocation); + + ew.flattenerLogged = true; + double botWidth = 2*FastTrig.atan(25/(ew.distanceTraveled - 18)); + double hitChance = botWidth/ew.maxEscapeAngle(); + weightedEnemyFirerate += 1/hitChance; + ew.bestBins = null; + } + + + } + if(flattenerStarted) + for (int x = 0; x < _flattenerTickWaves.size(); x++) { + EnemyWave ew = (EnemyWave)_flattenerTickWaves.get(x); + + ew.distanceTraveled = (getTime() - ew.fireTime) * ew.bulletVelocity; + double myDistFromCenter = _myLocation.distance(ew.fireLocation); + + if(ew.distanceTraveled > myDistFromCenter - ew.bulletVelocity + && flattenerStarted && bot.getOthers() > 0){ + logTickFlattener(ew,_myLocation); + _flattenerTickWaves.remove(x); + x--; + + } + } + } + public void updateShadows(EnemyWave ew){ + + for(int i = 0, j = myBullets.size(); i < j; i++){ + BulletTracker b = myBullets.get(i); + ew.logShadow(getTime(),b); + } + + } + public void updateShadows(BulletTracker b){ + + for(int i = 0, j = _enemyWaves.size(); i < j; i++){ + EnemyWave ew = _enemyWaves.get(i); + if(!ew.bulletGone) + ew.logShadow(getTime(),b); + } + + } + + public EnemyWave getClosestSurfableWave() { + double closestDistance = Double.POSITIVE_INFINITY; + EnemyWave surfWave = null; + + for (int x = 0; x < _enemyWaves.size(); x++) { + EnemyWave ew = (EnemyWave)_enemyWaves.get(x); + double distance = _myLocation.distance(ew.fireLocation) + - ew.distanceTraveled; + + if (!ew.bulletGone && distance > ew.bulletVelocity + && distance < closestDistance) { + surfWave = ew; + closestDistance = distance; + } + } + + return surfWave; + } + + // Given the EnemyWave that the bullet was on, and the point where we + // were hit, calculate the index into our stat array for that factor. + + + // Given the EnemyWave that the bullet was on, and the point where we + // were hit, update our stat array to reflect the danger in that area. + public void logHit(EnemyWave ew, Point2D.Double targetLocation, boolean bulletHitBullet) { + int index = (int)Math.round(ew.getFactorIndex(targetLocation)); + + if(VCS) + for(int i = 0, k = ew.allStats.size(); i < k; i++){ + BufferManager.SingleBuffer sb = (BufferManager.SingleBuffer)ew.allStats.get(i); + sb.addHit(index); + } + + else{ + + ew.scan.index = index; + surfBufferTree.addPoint(ew.scan.location(),ew.scan); + } + + surfStatsChanged = true; + for(int i = 0, k = _enemyWaves.size(); i < k; i++) + ((EnemyWave)_enemyWaves.get(i)).bestBins = null; + + } + public void logFlattener(EnemyWave ew, Point2D.Double targetLocation) { + if((VCS && ew.flattenerStats == null) || bot.getOthers() == 0) + return; + + int index = (int)Math.round(ew.getFactorIndex(targetLocation)); + + if(VCS) + for(int i = 0, k = ew.flattenerStats.size(); i < k; i++){ + BufferManager.SingleBuffer sb = (BufferManager.SingleBuffer)ew.flattenerStats.get(i); + + sb.addHit(index); + } + else{ + Scan s = (Scan)(ew.scan.clone()); + s.index = index; + flatBufferTree.addPoint(s.ASLocation(),s); + } + } + public void logABS(EnemyWave ew, Point2D.Double targetLocation) { + if((VCS && ew.ABSStats == null) || bot.getOthers() == 0) + return; + + int index = (int)Math.round(ew.getFactorIndex(targetLocation)); + + if(VCS) + for(int i = 0, k = ew.ABSStats.size(); i < k; i++){ + BufferManager.SingleBuffer sb = (BufferManager.SingleBuffer)ew.ABSStats.get(i); + sb.addHit(index); + } + else{ + Scan s = (Scan)(ew.scan.clone()); + s.index = index; + ABSBufferTree.addPoint(s.ASLocation(),s); + } + } + public void logTickFlattener(EnemyWave ew, Point2D.Double targetLocation) { + if((VCS && ew.flattenerTickStats == null) || bot.getOthers() == 0) + return; + int index = (int)Math.round(ew.getFactorIndex(targetLocation)); + + if(VCS) + for(int i = 0, k = ew.flattenerTickStats.size(); i < k; i++){ + BufferManager.SingleBuffer sb = (BufferManager.SingleBuffer)ew.flattenerTickStats.get(i); + sb.addHit(index); + } + else{ + ew.scan.index = index; + tickBufferTree.addPoint(ew.scan.ASLocation(),ew.scan); + } + } + + static float sqr(float f){ + return f*f; + } + + public void onBulletHitBullet(BulletHitBulletEvent e){ + _time = bot.getTime(); + + if (!_enemyWaves.isEmpty()) { + Point2D.Double hitBulletLocation = new Point2D.Double( + e.getHitBullet().getX(), e.getHitBullet().getY()); + EnemyWave hitWave = null; + + // look through the EnemyWaves, and find one that could've hit the bullet + hitWave = getCollisionWave(hitBulletLocation,e.getHitBullet().getPower()); + + if (hitWave != null) { + if(hitWave.distanceTraveled <= hitWave.bulletVelocity*2) + hitBulletLocation = project(hitBulletLocation,e.getHitBullet().getHeadingRadians(),e.getHitBullet().getVelocity()); + logHit(hitWave, hitBulletLocation, true); + // We can remove this wave now, of course. + hitWave.bulletGone = true; + } + else + System.out.println("ERROR: DETECTED BULLET ON NONEXISTANT WAVE!"); + + Bullet b = e.getBullet(); + myBullets.remove(b); + for(int i = 0, j = _enemyWaves.size(); i < j; i++){ + EnemyWave ew = _enemyWaves.get(i); + + BulletTracker bt = null; + for(int k = 0; k < myBullets.size() && bt == null; k++) + if(myBullets.get(k).b.equals(b)) + bt = myBullets.get(k); + if(bt != null) + ew.clearShadow(getTime(),bt);//run the bullet backwards to see if it cleared anything in the past + + } + } + else + System.out.println("ERROR: DETECTED BULLET WITHOUT WAVES!"); + } + public void onHitByBullet(HitByBulletEvent e) { + _time = bot.getTime(); + // If the _enemyWaves collection is empty, we must have missed the + // detection of this wave somehow. + if (!_enemyWaves.isEmpty()) { + Bullet bullet = e.getBullet(); + Point2D.Double hitBulletLocation = new Point2D.Double( + e.getBullet().getX(), e.getBullet().getY()); + EnemyWave hitWave = null; + + // look through the EnemyWaves, and find one that could've hit us. + hitWave = getCollisionWave(_myLocation,e.getBullet().getPower()); + if (hitWave != null) { + // hitBulletLocation = + // project(hitWave.fireLocation, bullet.getHeading(), hitWave.distanceTraveled); + + logHit(hitWave, hitBulletLocation, false); + int index = (int)Math.round(hitWave.getFactorIndex(hitBulletLocation)); + if(hitWave.binCleared != null && hitWave.binCleared[index] == 0) + System.out.println("Hit by bullet in shadow"); + + // We can remove this wave now, of course. + hitWave.bulletGone = true; + if(_enemyLocation.distance(hitBulletLocation) > 200){ + double botWidth = 2*FastTrig.atan(25/(hitWave.distanceTraveled - 18)); + double hitChance = botWidth/hitWave.maxEscapeAngle(); + weightedEnemyHitrate += 1/hitChance; + } + } + else + System.out.println("ERROR: DETECTED BULLET ON NONEXISTANT WAVE!"); + } + else + System.out.println("ERROR: DETECTED BULLET WITHOUT WAVES!"); + + double power = e.getBullet().getPower(); + double damage = 4*power; + if(power > 1) + damage += 2*(power - 1); + + totalEnemyDamage += damage; + + _oppEnergy += power*3; + } + EnemyWave getCollisionWave(Point2D.Double point, double bulletPower){ + for (int x = 0; x < _enemyWaves.size(); x++) { + EnemyWave ew = (EnemyWave)_enemyWaves.get(x); + double dist = ew.distanceTraveled - point.distance(ew.fireLocation); + if (Math.abs(dist - 10) < 50 + && Math.abs(bulletVelocity(bulletPower)-ew.bulletVelocity) < 0.01) { + + return ew; + + } + } + + return null; + } + + // CREDIT: mini sized predictor from Apollon, by rozu + // http://robowiki.net?Apollon + public ArrayList predictPositions(PredictionStatus startPos, EnemyWave surfWave, double direction, double goodDist) { + Point2D.Double predictedPosition = startPos.endPoint; + long time = startPos.time; + ArrayList positions = new ArrayList(); + + double predictedVelocity = startPos.finalVelocity; + double predictedHeading = startPos.finalHeading; + double maxTurning, moveAngle, prefOffset, moveDir; + Point2D.Double eLoc = _enemyLocation; + + int counter = 0; // number of ticks in the future + boolean intercepted = false; + + do { + + double absBearing = absoluteBearing( + eMove.get((int)time)//eLoc = project(eLoc,lastScan.getHeadingRadians(), lastScan.getVelocity()) + // surfWave.fireLocation + , + predictedPosition + ); + prefOffset = Math.PI/2 - 1 + limit(200,eLoc.distance(predictedPosition),goodDist)/goodDist; + + + moveAngle = + wallSmoothing(predictedPosition, absBearing+ (direction * prefOffset), direction) + - predictedHeading; + moveDir = 1; + + if(FastTrig.cos(moveAngle) < 0) { + moveAngle += Math.PI; + moveDir = -1; + } + + moveAngle = FastTrig.normalRelativeAngle(moveAngle); + + maxTurning = (Math.PI/18) - (Math.PI/240)*Math.abs(predictedVelocity); + + predictedHeading = FastTrig.normalRelativeAngle(predictedHeading + + limit(-maxTurning, moveAngle, maxTurning)); + + double velAddition = (predictedVelocity * moveDir < 0 ? 2*moveDir : moveDir); + + + predictedVelocity = limit(-8, predictedVelocity + velAddition, 8); + + // calculate the new predicted position + predictedPosition = project(predictedPosition, predictedHeading, predictedVelocity); + + PlaceTime pt = new PlaceTime(); + pt.place = predictedPosition; + pt.time = (long)((surfWave.fireLocation.distance(pt.place) - surfWave.distanceTraveled - surfWave.bulletVelocity)/surfWave.bulletVelocity) + getTime(); + + positions.add(pt); + + counter++; + + if (startPos.endPoint.distance(predictedPosition) > (pt.time - time)*8 + 28) + intercepted = true; + + } while((!intercepted || counter < 10) && counter < 90); + + return positions; + } + + public static void filterPlaceTimes(ArrayList positions, double threshold){ + double tSq = threshold*threshold; + ArrayList newPositions = new ArrayList(positions.size()); + Point2D.Double[] posPoints = new Point2D.Double[positions.size()]; + for(int i = 0; i < positions.size(); i++){ + PlaceTime p1 = (PlaceTime)positions.get(i); + Point2D.Double p1p = p1.place; + boolean withinThreshold = false; + int minPos = Math.max(newPositions.size()-5,0); + for(int j = newPositions.size()-1; j >= minPos; j--){ + double minDistSq = p1p.distanceSq(posPoints[j]); + if(minDistSq < tSq){ + withinThreshold = true; + break; + } + } + if(!withinThreshold){ + posPoints[newPositions.size()]=p1p; + newPositions.add(p1); + } + } + positions.clear(); + positions.addAll(newPositions); + } + static float power(float k, int n){ + float end = 1; + + for(int i = 0; i < n; i++) + end *= k; + + return end; + + } + static void extractIntoBins(ArrayList buffers, float[] bins){ + + for(int i = 0,k = buffers.size(); i < k; i++){ + BufferManager.SingleBuffer sb = (BufferManager.SingleBuffer)buffers.get(i); + if(sb.bins == null || sb.binsUsed == 0) + continue; + float roll = 1 - 1 / (sb.rollingDepth + 1); + float multFactor = sb.binsUsed* + (flattenerEnabled?sb.weight:((1-roll)/(roll-power(roll,sb.binsUsed+1)))); + for(int j = sb.hits; j >= 0; j--){ + bins[sb.bins[j]] += multFactor; + multFactor *= roll; + } + if(sb.binsUsed == sb.bins.length) + for(int j = sb.binsUsed - 1; j > sb.hits; j--){ + bins[sb.bins[j]] += multFactor; + multFactor *= roll; + } + } + } + static class TimeComparator implements Comparator{ + public int compare(Object o1, Object o2){ + int t1 = ((KDTree.SearchResult)o1).payload.pointInTime; + int t2 = ((KDTree.SearchResult)o2).payload.pointInTime; + if(t1 > t2) + return -1; + if(t1 < t2) + return 1; + return 0; + } + } + static void extractIntoBins(double[] searchLocation, KDTree tree, float[] bins){ + ArrayList> cl = + tree.nearestNeighbours( + searchLocation, + (int)Math.ceil(Math.sqrt(tree.size()))); + + Collections.sort(cl,new TimeComparator()); + Iterator> it = cl.iterator(); + int i = 0; + double sumDist = 0.00000000000001; + //int max = cl.size(); + while(it.hasNext() + //& i < max + ){ + KDTree.SearchResult p = it.next(); + sumDist += p.distance; + //i++; + } + double invAvgDist = //i + cl.size()/sumDist; + + it = cl.iterator(); + double rolloff = 1; + while(it.hasNext()){ + KDTree.SearchResult p = it.next(); + rolloff *= 0.85; + double weight = rolloff*Math.exp(-0.5*p.distance*invAvgDist); + bins[p.payload.index] += weight; + } + } + public static void getBins(EnemyWave wave, float[] profile){ + wave.bestBins = new float[EnemyWave.BINS]; + if(wave.binCleared == null){ + wave.binCleared = new float[EnemyWave.BINS]; + for(int i = 0; i < EnemyWave.BINS; i++) + wave.binCleared[i] = 1; + } + if(VCS) + extractIntoBins(wave.allStats,wave.bestBins); + else + extractIntoBins(wave.scan.location(),surfBufferTree,wave.bestBins); + + heightNormalize(wave.bestBins); + + + if(flattenerEnabled & (!VCS || wave.flattenerStats != null)){ + + float[] flattenerBins = new float[EnemyWave.BINS]; + if(VCS) + extractIntoBins(wave.flattenerStats,flattenerBins); + else + extractIntoBins(wave.scan.ASLocation(),flatBufferTree,flattenerBins); + + heightNormalize(flattenerBins); + + float[] flattenerTickBins = new float[EnemyWave.BINS]; + if(VCS) + extractIntoBins(wave.flattenerTickStats,flattenerTickBins); + else + extractIntoBins(wave.scan.ASLocation(),tickBufferTree,flattenerTickBins); + heightNormalize(flattenerTickBins); + + float[] ABSBins = new float[EnemyWave.BINS]; + if(VCS) + extractIntoBins(wave.ABSStats,ABSBins); + else + extractIntoBins(wave.scan.ASLocation(),ABSBufferTree,ABSBins); + heightNormalize(ABSBins); + + for(int i = 1; i < EnemyWave.BINS; i++) + wave.bestBins[i] = wave.bestBins[i]*0.5f + flattenerBins[i]*0.35f + flattenerTickBins[i]*0.075f;// + ABSBins[i]*0.075f; + + } + //Smooth! + + + final int width = EnemyWave.BINS/2; + float[] smoothBins = new float[EnemyWave.BINS]; + for(int i = EnemyWave.BINS - 1; i > -1; i--) + if(wave.bestBins[i] != 0.0) + for(int j = EnemyWave.BINS-1; j > -1; j--) + smoothBins[j] += wave.bestBins[i]*profile[j - i + EnemyWave.BINS]; + wave.bestBins = smoothBins; + + heightNormalize(wave.bestBins); + } + + public static final float[] narrowprofile = new float[EnemyWave.BINS*2]; + public static final float[] wideprofile = new float[EnemyWave.BINS*2]; + static{ + for(int i = EnemyWave.BINS*2 - 1; i > -1; i--){ + narrowprofile[i] = 1f / (sqr((EnemyWave.BINS - i)*0.2f) + 1f); + wideprofile[i] = 1f / (sqr((EnemyWave.BINS - i)*0.1f) + 1f); + } + } + public PlaceTime getBestPoint(EnemyWave surfWave, EnemyWave nextWave, EnemyWave nnWave){ + + if(surfWave.bestBins == null){ + getBins(surfWave,wideprofile); + surfStatsChanged = true; + } + if(nextWave != null && nextWave.bestBins == null){ + getBins(nextWave,wideprofile); + surfStatsChanged = true; + } + if(nnWave != null && nnWave.bestBins == null){ + getBins(nnWave,wideprofile); + } + + if(nextWave != null && (nextWave.possPoints == null || surfStatsChanged)){ + + nextWave.weight = getWaveWeight(nextWave); + + surfStatsChanged = true; + } + + + if(surfWave.safePoints == null || surfWave.safestPoint == null || surfStatsChanged) + { + surfWave.weight = getWaveWeight(surfWave); + + double vel = bot.getVelocity(); + + eMove.predict(); + + PredictionStatus now = new PredictionStatus(); + now.finalHeading = bot.getHeadingRadians(); + now.finalVelocity = bot.getVelocity(); + now.distanceRemaining = bot.getDistanceRemaining(); + now.time = getTime(); + now.endPoint = _myLocation; + if(now.distanceRemaining < 0){ + now.finalVelocity = -now.finalVelocity; + now.distanceRemaining = -now.distanceRemaining; + now.finalHeading = FastTrig.normalAbsoluteAngle(now.finalHeading + Math.PI); + } + + if(surfWave.safePoints == null || surfStatsChanged){ + surfWave.safePoints = predictPositions(now, surfWave, lateralDirection, 650); + ArrayList reversePoints = predictPositions(now, surfWave, -lateralDirection, 650); + surfWave.safePoints.ensureCapacity(reversePoints.size() + surfWave.safePoints.size()); + for(int i = 0; i < reversePoints.size() ; i++) + surfWave.safePoints.add(0,reversePoints.get(i)); + filterPlaceTimes(surfWave.safePoints,7); + } + + + ArrayList points; + // if(nextWave == null){ + // int fireAhead =Math.max(1,(int)Math.floor(imaginaryGunHeat/getGunCoolingRate())); + // int fireTime = (int)getTime() + fireAhead; + // Point2D.Double fireLocation = _enemyLocation;//project(_enemyLocation,enemyHeading,fireAhead*enemyVelocity); + // double bulletPower = predictBulletPower(getEnergy(),_oppEnergy,((Double)_distances.get(0)).doubleValue()); + // + // EnemyWave fwave = new EnemyWave(); + // fwave.fireLocation = fireLocation; + // fwave.fireTime = fireTime; + // fwave.bulletVelocity = 20 - 3*bulletPower; + // fwave.futureWave = true; + // + // fwave.possPoints = predictPositions(fwave, 1, 650); + // + // ArrayList reverse = predictPositions(fwave, -1, 650); + // fwave.possPoints.ensureCapacity(reverse.size() + fwave.possPoints.size()); + // for(int i = 0; i < reverse.size() ; i++) + // fwave.possPoints.add(0,reverse.get(i)); + // + // fwave.weight = getWaveWeight(fwave); + // + // points = getPreciseIntersectionPredictionsFireWave(surfWave,surfWave.safePoints,now, fwave); + // } + // else + points = getPreciseIntersectionPredictions(surfWave,surfWave.safePoints,now); + + ArrayList bestNextPoints = null; + + float minDanger = Float.POSITIVE_INFINITY; + for(int i = 0, k = points.size(); i < k; i++){ + PlaceTime pt = (PlaceTime)(points.get(i)); + pt.danger = getDanger(surfWave, pt); + + if(pt.danger < minDanger ){ + surfWave.safestPoint = pt; + minDanger = pt.danger; + } + } + Collections.sort(points);//sorts according to danger + + if(nextWave != null){ + minDanger = Float.POSITIVE_INFINITY; + + MovePredictor mp = new MovePredictor(); + for(int i = 0, k = points.size(); i < k; i++){ + PlaceTime pt = (PlaceTime)(points.get(i)); + //TODO: Increase the base danger by getting a lower bound for second wave danger and increasing the base here + if(pt.danger >= minDanger) + continue;//just from 1st wave impossible to get lower than minDanger + + //TODO: use a priority queue, and do an A* search instead + //calculate cheap lower bound on second wave danger given start point and maxVel + double lowBoundSecondDanger = Double.POSITIVE_INFINITY; + //generate N points from eta*maxVel away to -eta*maxVel + double eta = (pt.place.distance(nextWave.fireLocation) - nextWave.distanceTraveled)/nextWave.bulletVelocity; + double maxDist = eta*8; + double step = Math.max(maxDist/20, 8); + double projectAngle = absoluteBearing(nextWave.fireLocation,pt.place) + Math.PI/2; + PlaceTime testPoint = new PlaceTime(); + testPoint.time = (long)eta + getTime(); + for(double pointDist = -maxDist; pointDist <= maxDist; pointDist+=step) + { + testPoint.place = project(pt.place, projectAngle, pointDist); + double nwaveApproxDanger = getDanger(nextWave, testPoint); + if(nwaveApproxDanger < lowBoundSecondDanger) + lowBoundSecondDanger = nwaveApproxDanger; + } + if (pt.danger + lowBoundSecondDanger >= minDanger) + continue;//impossible to get lower than minDanger + + if(pt.predictionStatus == null){ + mp.recycle( + _myLocation, + pt.place, + now.finalVelocity, + now.finalHeading, + now.time, + surfWave); + pt.predictionStatus = mp.predictToPreciseIntersection(); + } + ArrayList possPoints = predictPositions(pt.predictionStatus,nextWave,1,650); + ArrayList revPoints = predictPositions(pt.predictionStatus,nextWave,-1,650); + possPoints.ensureCapacity(possPoints.size() + revPoints.size()); + for(int q = 0; q < revPoints.size(); q++) + possPoints.add(0,revPoints.get(q)); + filterPlaceTimes(possPoints,7); + + float minSecondDanger = Float.POSITIVE_INFINITY; + ArrayList nextPoints = getPredictions(nextWave,possPoints,pt.predictionStatus); + PlaceTime safePt = null; + for(int j = 0, l = nextPoints.size(); j < l; j++){ + PlaceTime nextPt = (PlaceTime)nextPoints.get(j); + + float d = getDanger(nextWave,nextPt); + if(d < minSecondDanger){ + minSecondDanger = d; + safePt = nextPt; + } + // } + } + if(nextPoints.size() > 0) + // if(minSecondDanger != Float.POSITIVE_INFINITY) + pt.danger += minSecondDanger; + + + if(pt.danger < minDanger ){ + surfWave.safestPoint = pt; + nextWave.safestPoint = safePt; + minDanger = pt.danger; + bestNextPoints = nextPoints; + nextWave.possPoints = possPoints; + } + } + if(nextWave != null && nextWave.safestPoint != null && nextWave.safestPoint.predictionStatus == null){ + mp.recycle(surfWave.safestPoint.place, + nextWave.safestPoint.place, + surfWave.safestPoint.predictionStatus.finalVelocity, + surfWave.safestPoint.predictionStatus.finalHeading, + surfWave.safestPoint.time, + nextWave); + + nextWave.safestPoint.predictionStatus = mp.predictToIntersection(); + + + } + + + if(nnWave != null + && nnWave.safestPoint != null + && nnWave.safestPoint.predictionStatus != null + && nextWave != null + && nextWave.safestPoint != null + && nextWave.safestPoint.predictionStatus != null + && nnWave.possPoints != null + && nnWave.possPoints.size() > 0){ + + ArrayList possPoints = predictPositions(nextWave.safestPoint.predictionStatus,nnWave,1,650); + ArrayList revPoints = predictPositions(nextWave.safestPoint.predictionStatus,nnWave,-1,650); + possPoints.ensureCapacity(possPoints.size() + revPoints.size()); + for(int q = 0; q < revPoints.size(); q++) + possPoints.add(0,revPoints.get(q)); + filterPlaceTimes(possPoints,7); + + ArrayList nextPoints = getPredictions( + nnWave, + possPoints, + nextWave.safestPoint.predictionStatus); + + PlaceTime safePt = null; + float minnnDanger = Float.POSITIVE_INFINITY; + for(int j = 0, l = nextPoints.size(); j < l; j++){ + PlaceTime nextPt = (PlaceTime)nextPoints.get(j); + + float d = getDanger(nnWave,nextPt); + if(d < minnnDanger){ + minnnDanger =d; + safePt = nextPt; + } + } + nnWave.safestPoint = safePt; + if( safePt != null && safePt.predictionStatus == null){ + mp.recycle( + nextWave.safestPoint.place, + safePt.place, + nextWave.safestPoint.predictionStatus.finalVelocity, + nextWave.safestPoint.predictionStatus.finalHeading, + nextWave.safestPoint.time, + nnWave); + safePt.predictionStatus = mp.predictToIntersection(); + } + } + + } + //if(!(surfWave != null && nextWave == null)) + surfStatsChanged = false; + + if(painting){ + firstPointsPainting = points; + nextPointsPainting = bestNextPoints; + } + } + + return surfWave.safestPoint; + + } + + public float getWaveWeight(EnemyWave wave){ + // double tta = (wave.fireLocation.distance(_myLocation) - wave.distanceTraveled)/wave.bulletVelocity; + + // double relevance = Math.pow(0.88,tta/2); + // double relevance = tta*tta - 200*tta + 10000; + // double relevance = Math.pow(0.96,tta); + double bp = (20 - wave.bulletVelocity)/3; + + + return (float)((bp*4 + Math.max(0,bp - 1)*2)); + } + + public float getDanger(EnemyWave wave, PlaceTime pt){ + + if(!_fieldRect.contains(pt.place)) + return Float.POSITIVE_INFINITY; + + + + Point2D.Double startPlace; + + boolean precise = false; + if(pt.predictionStatus != null){ + startPlace = pt.predictionStatus.endPoint; + if(pt.predictionStatus.intersectionIndices != null) + precise = true; + } + else + startPlace = pt.place; + + double waveCenterDistHere = wave.fireLocation.distance(startPlace); + + float thisDanger; + if(precise){ + int[] intIndices = {(int)Math.round(pt.predictionStatus.intersectionIndices[0]), + (int)Math.round(pt.predictionStatus.intersectionIndices[1])}; + + thisDanger = getAverageDanger(wave.bestBins, wave.binCleared,intIndices); + double width = pt.predictionStatus.intersectionIndices[1] - pt.predictionStatus.intersectionIndices[0]; + width *= wave.maxEscapeAngle()*(1.0/EnemyWave.MIDDLE_BIN); + thisDanger *= width; + // System.out.println("Using precise!"); + } + else{ + + int index = (int)Math.round(wave.getFactorIndex(startPlace)); + double botWidthAtEnd = 40/(waveCenterDistHere - 34); + double inv_binWidth = EnemyWave.MIDDLE_BIN/wave.maxEscapeAngle(); + int botBinWidthAtEnd = (int)Math.round(botWidthAtEnd*inv_binWidth); + + thisDanger = getAverageDanger(wave.bestBins, wave.binCleared,index,botBinWidthAtEnd); + thisDanger *= botWidthAtEnd;//*botWidthAtEnd; + } + + if(wave.futureWave) + thisDanger *= 0.2; + Point2D.Double futureEloc = eMove.get((int)pt.time); + thisDanger /= Math.max(0.1,Math.sqrt(Math.min( + Math.min(futureEloc.distanceSq(startPlace), waveCenterDistHere*waveCenterDistHere), + _enemyLocation.distanceSq(startPlace)))-34); + + float tta = (float)((waveCenterDistHere - wave.distanceTraveled)/wave.bulletVelocity); + + // double relevance = Math.pow(0.88,tta/2); + float relevance = tta*tta - 200*tta + 10000; + // double relevance = Math.pow(0.96,tta); + //float relevance = (float)Math.pow(0.9,0.3*tta); + + return thisDanger*relevance*wave.weight; + + } + public ArrayList getPreciseIntersectionPredictions(EnemyWave wave, ArrayList points, PredictionStatus start){ + MovePredictor mp = new MovePredictor(); + ArrayList likelyPoints = new ArrayList(points.size()); + int maxStop = points.size() - 1; + for(; maxStop >= 0; maxStop--){ + PlaceTime guessPT = (PlaceTime)points.get(maxStop); + mp.recycle( + start.endPoint, + guessPT.place, + start.finalVelocity, + start.finalHeading, + start.time,wave); + PredictionStatus futureStatus = mp.predictToPreciseIntersection(); + // PredictionStatus futureStatus = futureStatusPreciseIntersection( + // start.endPoint, + // guessPT.place, + // start.finalVelocity, + // start.finalHeading, + // start.time,wave); + + + // guessPT = clone(guessPT); + guessPT.time = futureStatus.time; + guessPT.predictionStatus = futureStatus; + + likelyPoints.add(guessPT); + } + + return likelyPoints; + + } + public ArrayList getPredictions(EnemyWave wave, ArrayList points, PredictionStatus start){ + ArrayList likelyPoints = new ArrayList(points.size()); + MovePredictor mp = new MovePredictor(); + int maxStop = points.size() - 1; + for(; maxStop >= 0; maxStop--){ + PlaceTime guessPT = (PlaceTime)points.get(maxStop); + // PredictionStatus futureStatus = futureStatus( + // start.endPoint, + // guessPT.place, + // start.finalVelocity, + // start.finalHeading, + // start.time,wave); + mp.recycle( + start.endPoint, + guessPT.place, + start.finalVelocity, + start.finalHeading, + start.time,wave); + PredictionStatus futureStatus = mp.predictToIntersection(); + + // guessPT = clone(guessPT); + guessPT.time = futureStatus.time; + guessPT.predictionStatus = futureStatus; + likelyPoints.add(guessPT); + + if(guessPT.predictionStatus.finalVelocity == 0.0 + & guessPT.predictionStatus.distanceRemaining == 0.0) + break; + } + + int minStop = 0; + for(; minStop <= maxStop; minStop++){ + PlaceTime guessPT = (PlaceTime)points.get(minStop); + // PredictionStatus futureStatus = futureStatus( + // start.endPoint, + // guessPT.place, + // start.finalVelocity, + // start.finalHeading, + // start.time,wave); + mp.recycle( + start.endPoint, + guessPT.place, + start.finalVelocity, + start.finalHeading, + start.time,wave); + PredictionStatus futureStatus = mp.predictToIntersection(); + + // guessPT = clone(guessPT); + guessPT.time = futureStatus.time; + guessPT.predictionStatus = futureStatus; + likelyPoints.add(guessPT); + + if(guessPT.predictionStatus.finalVelocity == 0.0 + & guessPT.predictionStatus.distanceRemaining == 0.0) + break; + } + + for(int i = minStop; i <= maxStop; i++){ + PlaceTime guessPT = ((PlaceTime)points.get(i)); + guessPT.predictionStatus = null; + likelyPoints.add( + // clone( + guessPT + // ) + ); + } + + return likelyPoints; + + } + + static PlaceTime clone(PlaceTime pt){ + PlaceTime p = new PlaceTime(); + p.predictionStatus = pt.predictionStatus; + p.place = pt.place; + p.time = pt.time; + p.danger = pt.danger; + return p; + + } + + //3 optimized methods from the new robocode engine + private static double getNewVelocity(double velocity, double distance) { + if(distance < 0) + return -getNewVelocity(-velocity,-distance); + + final double goalVel = Math.min(getMaxVelocity(distance), 8); + + if(velocity >= 0) + return limit(velocity - 2, + goalVel, velocity + 1); + + return limit(velocity - 1, + goalVel, velocity + maxDecel(-velocity)); + } + + static final double getMaxVelocity(double distance) { + final double decelTime = Math.round( + //sum of 0... decelTime, solving for decelTime + //using quadratic formula, then simplified a lot + Math.sqrt(distance + 1)); + + final double decelDist = Math.max(0, (decelTime) * (decelTime-1) ); + // sum of 0..(decelTime-1) + // * Rules.DECELERATION*0.5; + + return Math.max(0,((decelTime - 1) * 2) + ((distance - decelDist) / decelTime)); + } + + private static final double maxDecel(double speed) { + return limit(1,speed*0.5 + 1, 2); + } + static double sqr(double d){ + return d*d; + } + static int sqr(int i){ + return i*i; + } + + public static void heightNormalize(float[] bins){ + float max = 0; + for(int i = 1; i < bins.length; i++) + if(bins[i] > max) + max = bins[i]; + if(max != 0){ + max = 1/max; + + for(int i = 1; i < bins.length; i++) + bins[i] *= max; + } + } + public static void areaNormalize(float[] bins){ + float total = 0; + for(int i = 1; i < bins.length; i++) + total += bins[i]; + total = 1/total; + if(total != 0){ + for(int i = 1; i < bins.length; i++) + bins[i] *= total; + } + } + public float getAverageDanger(float[] bins, float[] binsLevel, int index, int botBinWidth){ + botBinWidth = (int)limit(2, botBinWidth, EnemyWave.BINS - 1); + float totalDanger = 0; + + int minIndex = Math.max(1,index - botBinWidth/2); + int maxIndex = Math.min(EnemyWave.BINS - 1, index + botBinWidth/2) + 1; + for(int i = minIndex; i < maxIndex; i++) + totalDanger += bins[i]*binsLevel[i]; + + return totalDanger/(maxIndex - minIndex); + + } + public float getAverageDanger(float[] bins, float[] binsLevel, int[] minMaxIndexes){ + float totalDanger = 0; + + int minIndex = minMaxIndexes[0]; + int maxIndex = minMaxIndexes[1]+1; + for(int i = minIndex; i < maxIndex; i++) + totalDanger += bins[i]*binsLevel[i]; + + return totalDanger/(maxIndex - minIndex); + + } + + public void doSurfing() { + mainWave = getClosestSurfableWave(); + boolean surf = false; + if(mainWave != null){ + _enemyWaves.remove(mainWave); + secondWave = getClosestSurfableWave(); + + if(secondWave != null){ + _enemyWaves.remove(secondWave); + thirdWave = getClosestSurfableWave(); + _enemyWaves.add(secondWave); + } + + _enemyWaves.add(mainWave); + PlaceTime bestPoint = getBestPoint(mainWave, secondWave, thirdWave); + if(bestPoint != null && bestPoint.place != null){ + surf = true; + goTo(bestPoint, mainWave); + direction = -lateralDirection; + } + else{ + mainWave = secondWave = null; + } + } + else + secondWave = null; + + + if (!surf) { + { + if(_enemyLocation != null){ + + double distance = _enemyLocation.distanceSq(_myLocation); + double absBearing = absoluteBearing(_myLocation, _enemyLocation); + double headingRadians = bot.getHeadingRadians(); + double stick =limit(121,distance,160); + double goAngle, revGoAngle, revOffset; + double offset = revOffset = Math.max(Math.PI/3 + 0.021,Math.PI/2 + 1 -limit(0.4,distance/(400*400),1.2)); + int count = 50; + Point2D.Double endPoint, revEndPoint; + + while(!_fieldRect. + contains(endPoint = project(_myLocation,goAngle = absBearing + direction*(offset -= 0.02), stick)) + & count-- > 0); + + count = 50; + + while(!_fieldRect. + contains(revEndPoint = project(_myLocation,revGoAngle = absBearing - direction*(revOffset -= 0.02), stick)) + & count-- > 0); + + if(offset < revOffset){ + direction = -direction; + goAngle = revGoAngle; + } + + + bot.setAhead(50*FastTrig.cos(goAngle -= headingRadians)); + bot.setTurnRightRadians(FastTrig.tan(goAngle)); + } + } + } + + } + + private void goTo(PlaceTime pt, EnemyWave surfWave) { + Point2D.Double place = pt.place; + lastGoToPoint = place; + double distance = _myLocation.distance(place); + double dir = 1; + double angle = FastTrig.normalRelativeAngle(absoluteBearing(_myLocation, place) - bot.getHeadingRadians()); + if(-1 < distance & distance < 1 ) + angle = 0; + + if (Math.abs(angle) > Math.PI/2) { + dir = -1; + if (angle > 0) { + angle -= Math.PI; + } + else { + angle += Math.PI; + } + } + + if(pt.predictionStatus != null + && Math.abs(pt.predictionStatus.distanceRemaining) <= 0.1 + && Math.abs(pt.predictionStatus.finalVelocity) <= 0.1){ + double myVel = bot.getVelocity(); + double heading = bot.getHeadingRadians(); + if(myVel < 0){ + myVel = -myVel; + heading += Math.PI; + } + double maxTurn = Math.PI/18 - (Math.PI/240)*myVel; + heading += limit(-maxTurn,angle, maxTurn); + + double nextVel = limit(1,myVel + 1, 8); + + Point2D.Double nextLocation = project(_myLocation,heading,nextVel); + MovePredictor mp = new MovePredictor(nextLocation,pt.place,nextVel,heading,getTime() + 1,surfWave); + PredictionStatus stillOption = mp.predictToIntersection(); + + if(Math.abs(stillOption.distanceRemaining) <= 0.1){ + distance = 100; + //angle = 0; + } + } + + bot.setTurnRightRadians(angle); + bot.setAhead(distance*dir); + + } + static double decelDistance(double vel){ + + int intVel = (int)Math.ceil(vel); + switch(intVel){ + case 8: + return 6 + 4 + 2; + case 7: + return 5 + 3 + 1; + case 6: + return 4 + 2; + case 5: + return 3 + 1; + case 4: + return 2; + case 3: + return 1; + case 2: + // return 2; + case 1: + // return 1; + case 0: + return 0; + + default: + return 6 + 4 + 2; + + + } + + // double dist = 0; + // while(vel > 0){ + // vel = limit(0, vel - 2, 8); + // dist += vel; + // } + // return dist; + } + + + private double absoluteBearing(Point2D source, Point2D target) { + return FastTrig.atan2(target.getX() - source.getX(), target.getY() - source.getY()); + } + // This can be defined as an inner class if you want. + + + + +//non-iterative wallsmoothing by Simonton - to save your CPUs + public static final double HALF_PI = Math.PI / 2; + public static final double WALKING_STICK = 160; + public static final double WALL_MARGIN = 19; + public static final double S = WALL_MARGIN; + public static final double W = WALL_MARGIN; + public static final double N = 600 - WALL_MARGIN; + public static final double E = 800 - WALL_MARGIN; + + // angle = the angle you'd like to go if there weren't any walls + // oDir = 1 if you are currently orbiting the enemy clockwise + // -1 if you are currently orbiting the enemy counter-clockwise + // returns the angle you should travel to avoid walls + double wallSmoothing(Point2D.Double botLocation, double angle, double oDir) { + // if(!_fieldRect.contains(project(botLocation,angle + Math.PI*(oDir + 1),WALKING_STICK))){ + angle = smoothWest(N - botLocation.y, angle - HALF_PI, oDir) + HALF_PI; + angle = smoothWest(E - botLocation.x, angle + Math.PI, oDir) - Math.PI; + angle = smoothWest(botLocation.y - S, angle + HALF_PI, oDir) - HALF_PI; + angle = smoothWest(botLocation.x - W, angle, oDir); + + // for bots that could calculate an angle that is pointing pretty far + // into a corner, these three lines may be necessary when travelling + // counter-clockwise (since the smoothing above may have moved the + // walking stick into another wall) + angle = smoothWest(botLocation.y - S, angle + HALF_PI, oDir) - HALF_PI; + angle = smoothWest(E - botLocation.x, angle + Math.PI, oDir) - Math.PI; + angle = smoothWest(N - botLocation.y, angle - HALF_PI, oDir) + HALF_PI; + // } + return angle; + } + + // smooths agains the west wall + static double smoothWest(double dist, double angle, double oDir) { + if (dist < -WALKING_STICK * FastTrig.sin(angle)) { + return FastTrig.acos(oDir * dist / WALKING_STICK) - oDir * HALF_PI; + } + return angle; + } + + //CREDIT: MORE STUFF BY SIMONTON =) + + // eDist = the distance from you to the enemy + // eAngle = the absolute angle from you to the enemy + // oDir = 1 for the clockwise orbit distance + // -1 for the counter-clockwise orbit distance + // returns: the positive orbital distance (in radians) the enemy can travel + // before hitting a wall (possibly infinity). + static double wallDistance(Point2D.Double sourceLocation, double eDist, double eAngle, int oDir) { + return Math.min(Math.min(Math.min( + distanceWest(N - sourceLocation.getY(), eDist, eAngle - HALF_PI, oDir), + distanceWest(E - sourceLocation.getX(), eDist, eAngle + Math.PI, oDir)), + distanceWest(sourceLocation.getY() - S, eDist, eAngle + HALF_PI, oDir)), + distanceWest(sourceLocation.getX() - W, eDist, eAngle, oDir)); + } + + static double distanceWest(double toWall, double eDist, double eAngle, int oDir) { + if (eDist <= toWall) { + return Double.POSITIVE_INFINITY; + } + double wallAngle = FastTrig.acos(-oDir * toWall / eDist) + oDir * HALF_PI; + return FastTrig.normalAbsoluteAngle(oDir * (wallAngle - eAngle)); + } + + + // CREDIT: from CassiusClay, by PEZ + // - returns point length away from sourceLocation, at angle + // robowiki.net?CassiusClay + public static Point2D.Double project(Point2D.Double sourceLocation, double angle, double length) { + return new Point2D.Double(sourceLocation.x + FastTrig.sin(angle) * length, + sourceLocation.y + FastTrig.cos(angle) * length); + } + + // got this from RaikoMicro, by Jamougha, but I think it's used by many authors + // - returns the absolute angle (in radians) from source to target points + public static double absoluteBearing(Point2D.Double source, Point2D.Double target) { + return FastTrig.atan2(target.x - source.x, target.y - source.y); + } + public static int limit(int min, int value, int max) { + if(value > max) + return max; + if(value < min) + return min; + + return value; + } + public static double limit(double min, double value, double max) { + if(value > max) + return max; + if(value < min) + return min; + + return value; + } + public static float limit(float min, float value, float max) { + if(value > max) + return max; + if(value < min) + return min; + + return value; + } + + public static double bulletVelocity(double power) { + return (20D - (3D*power)); + } + + + + public void onPaint(java.awt.Graphics2D g) { + painting = true; + // if(!MC2K7) + // dgun.onPaint(g); + g.setColor(Color.red); + _time = bot.getTime(); + + for(int i = 0; i < _enemyWaves.size(); i++){ + g.setColor(Color.red); + EnemyWave w = (EnemyWave)(_enemyWaves.get(i)); + int radius = (int)(w.bulletVelocity*(getTime() - w.fireTime)); + Point2D.Double center = w.fireLocation; + if(radius - 40 < center.distance(_myLocation)){ + // g.drawOval((int)(center.x - radius ), (int)(center.y - radius), radius*2, radius*2); + if(w.bestBins != null){ + double MEA = w.maxEscapeAngle(); + double max = 0; + for(int j = 0; j < EnemyWave.BINS; j++) + max = Math.max(max,w.bestBins[j]*w.binCleared[j]); + max = 1/max; + for(int j = 0; j < EnemyWave.BINS; j++){ + + double thisDanger = w.bestBins[j]*w.binCleared[j]*max; + if(w.binCleared[j] == 0) + g.setColor(Color.black); + else + g.setColor(Color.blue); + if(thisDanger > 0.1) + g.setColor(Color.green); + if(thisDanger > 0.3) + g.setColor(Color.yellow); + if(thisDanger > 0.6) + g.setColor(Color.orange); + if(thisDanger > 0.9) + g.setColor(Color.red); + Point2D.Double p1 = project(center, w.directAngle + w.direction*( j - EnemyWave.MIDDLE_BIN)/(double)EnemyWave.MIDDLE_BIN*MEA/0.9, radius-w.bulletVelocity); + Point2D.Double p2 = project(center, w.directAngle + w.direction*(j - EnemyWave.MIDDLE_BIN)/(double)EnemyWave.MIDDLE_BIN*MEA/0.9, radius); + g.drawLine((int)(p1.x),(int)(p1.y),(int)(p2.x),(int)(p2.y)); + + + } + } + if(w.imaginary){ + g.setColor(Color.white); + g.drawString("imaginary wave in air",100,35); + g.drawString("velocity: " + w.bulletVelocity,100,25); + g.drawString("traveled distance: " + w.distanceTraveled,100,15); + } + } + } + if(mainWave != null + && mainWave.safestPoint != null + && mainWave.safestPoint.predictionStatus != null + && mainWave.safestPoint.predictionStatus.intersectionIndices != null){ + PlaceTime pt = mainWave.safestPoint; + if(pt.predictionStatus.intersectionIndices != null){ + g.setColor(Color.white); + double radius = pt.predictionStatus.endPoint.distance(mainWave.fireLocation); + Point2D.Double center = mainWave.fireLocation; + double MEA = mainWave.maxEscapeAngle(); + Point2D.Double p1 = project(center, mainWave.directAngle + mainWave.direction*( pt.predictionStatus.intersectionIndices[0] - EnemyWave.MIDDLE_BIN)/(double)EnemyWave.MIDDLE_BIN*MEA/0.9, radius); + Point2D.Double p2 = project(center, mainWave.directAngle + mainWave.direction*( pt.predictionStatus.intersectionIndices[1] - EnemyWave.MIDDLE_BIN)/(double)EnemyWave.MIDDLE_BIN*MEA/0.9, radius); + g.drawLine((int)p1.x,(int)p1.y,(int)p2.x,(int)p2.y); + g.drawLine((int)p1.x,(int)p1.y,(int)mainWave.fireLocation.x,(int)mainWave.fireLocation.y); + g.drawLine((int)p2.x,(int)p2.y,(int)mainWave.fireLocation.x,(int)mainWave.fireLocation.y); + + g.drawRect((int)pt.predictionStatus.endPoint.x - 18, (int)pt.predictionStatus.endPoint.y - 18, 36,36); + } + + } + // { g.setColor(Color.red); + // for(int i = 0; i < myBullets.size(); i++){ + // Bullet b = myBullets.get(i).b; + // Point2D.Double p1 = new Point2D.Double(b.getX(), b.getY()); + // Point2D.Double p2 = project(p1,b.getHeadingRadians(),b.getVelocity()); + // g.drawLine((int)(p1.x),(int)(p1.y),(int)(p2.x),(int)(p2.y)); + // } + // } + { + g.setColor(Color.white); + g.drawString("enemy gunheat: " + enemyGunHeat,300,15); + g.drawString("imaginary enemy gunheat" + imaginaryGunHeat,300,5); + g.drawRect((int)_myLocation.x - 18, (int)_myLocation.y - 18, 36,36); + } + + if(firstPointsPainting != null){ + + for(int i = 0; i < firstPointsPainting.size(); i++){ + g.setColor(Color.green); + PlaceTime pt = ((PlaceTime)firstPointsPainting.get(i)); + Point2D.Double goToTarget = pt.place; + if(pt.predictionStatus != null){ + goToTarget = pt.predictionStatus.endPoint; + + + + // if(pt.predictionStatus.debug) + // g.setColor(Color.red); + } + + g.drawOval((int)goToTarget.x - 2, (int)goToTarget.y - 2, 4,4); + } + } + if(lastGoToPoint != null){ + g.setColor(Color.orange); + g.drawOval((int)lastGoToPoint.x - 3, (int)lastGoToPoint.y - 3, 6,6); + g.drawOval((int)lastGoToPoint.x - 4, (int)lastGoToPoint.y - 4, 8,8); + } + if(secondWave != null && secondWave.possSafePT != null){ + g.setColor(Color.white); + g.drawOval((int)secondWave.possSafePT.place.x - 3, (int)secondWave.possSafePT.place.y - 3, 6,6); + } + if(nextPointsPainting != null){ + g.setColor(Color.pink); + for(int i = 0; i < nextPointsPainting.size(); i++){ + PlaceTime pt = ((PlaceTime)nextPointsPainting.get(i)); + Point2D.Double goToTarget; + if(pt.predictionStatus == null) + goToTarget = pt.place; + else + goToTarget = pt.predictionStatus.endPoint; + g.drawOval((int)goToTarget.x - 2, (int)goToTarget.y - 2, 4,4); + } + } + + if(lastScan != null){ + g.setColor(Color.yellow); + int bft = (int)(_enemyLocation.distance(_myLocation)/14); + if(!eMove.initialised()) + eMove.predict(); + + for(int i = 0; i < bft; i++){ + Point2D.Double p = eMove.get((int)getTime() + i); + if(p == null) + break; + g.drawOval((int)p.x - 2, (int)p.y - 2, 4,4); + + } + } + + // if(mainWave != null && mainWave.possPoints != null){ + // g.setColor(Color.red); + // for(int i = 0; i < mainWave.possPoints.size(); i++){ + // Point2D.Double goToTarget = ((PlaceTime)mainWave.possPoints.get(i)).place; + // g.drawOval((int)goToTarget.x - 2, (int)goToTarget.y - 2, 4,4); + // } + // } + // if(mainWave != null && mainWave.possSafePT != null){ + // g.setColor(Color.magenta); + // g.drawOval((int)mainWave.possSafePT.place.x - 3, (int)mainWave.possSafePT.place.y - 3, 6,6); + // + // } + // g.setColor(Color.white); + + } +} + +class Scan implements Cloneable{ + static final double + latVelWeight = 30, + advVelWeight = 15, + bftWeight = 12, + forwardWallWeight = 18, + reverseWallWeight = 7, + lastVelWeight = 4, + accelWeight = 10, + timeSinceDecelWeight = 8, + timeSinceDirChangeWeight = 8, + distLast10Weight = 8, + timeWeight1 = 1.05, + timeWeight2 = 0.18, + timeWeight3 = 0.2; + + static final double + ASlatVelWeight = 20, + ASadvVelWeight = 15, + ASbftWeight = 12, + ASforwardWallWeight = 15, + ASreverseWallWeight = 10, + ASlastVelWeight = 4, + ASaccelWeight = 15, + AStimeSinceDecelWeight = 10, + AStimeSinceDirChangeWeight = 10, + ASdistLast10Weight = 10, + AStimeWeight1 = 0.9, + AStimeWeight2 = 0.3, + AStimeWeight3 = 3; + + + + + double latVel, + advVel, + bft, + accel, + forwardWall, + reverseWall, + lastVel, + timeSinceDecel, + timeSinceDirChange, + distLast10; + int pointInTime; + int index; + + public Object clone(){ + Scan s = new Scan(); + s.latVel = latVel; + s.advVel = advVel; + s.bft = bft; + s.accel = accel; + s.forwardWall = forwardWall; + s.reverseWall = reverseWall; + s.lastVel = lastVel; + s.timeSinceDecel = timeSinceDecel; + s.timeSinceDirChange = timeSinceDirChange; + s.distLast10 = distLast10; + s.pointInTime = pointInTime; + s.index = index; + return s; + } + + + double[] location(){ + return new double[]{ + latVel/8*latVelWeight, + (0.5 + advVel/16)*advVelWeight, + bft/(900/11)*bftWeight, + 1/(1 + 2*timeSinceDirChange/bft)*timeSinceDirChangeWeight, + 1/(1+ 2*timeSinceDecel/bft)*timeSinceDecelWeight, + accel*accelWeight, + distLast10/80*distLast10Weight, + DrussMoveGT.limit(0d,forwardWall,1d)*forwardWallWeight, + DrussMoveGT.limit(0d,reverseWall,1d)*reverseWallWeight, + Math.pow(pointInTime*timeWeight1,timeWeight2)*timeWeight3 + }; + + } + double[] ASLocation(){ + return new double[]{ + latVel/8*ASlatVelWeight, + (0.5 + advVel/16)*ASadvVelWeight, + bft/(900/11)*ASbftWeight, + 1/(1 + 2*timeSinceDirChange/bft)*AStimeSinceDirChangeWeight, + 1/(1+ 2*timeSinceDecel/bft)*AStimeSinceDecelWeight, + accel*ASaccelWeight, + distLast10/80*ASdistLast10Weight, + DrussMoveGT.limit(0d,forwardWall,1d)*ASforwardWallWeight, + DrussMoveGT.limit(0d,reverseWall,1d)*ASreverseWallWeight, + Math.pow(pointInTime*AStimeWeight1,AStimeWeight2)*AStimeWeight3 + }; + + } +} + diff --git a/tools/robocode_shim/vendor/drussgt/src/jk/mega/dMove/EnemyWave.java b/tools/robocode_shim/vendor/drussgt/src/jk/mega/dMove/EnemyWave.java new file mode 100644 index 0000000..ebf6190 --- /dev/null +++ b/tools/robocode_shim/vendor/drussgt/src/jk/mega/dMove/EnemyWave.java @@ -0,0 +1,237 @@ +package jk.mega.dMove; +import java.awt.geom.*; +import java.util.*; +import robocode.*; + +import jk.precise.util.*; +import jk.mega.*; +import jk.math.FastTrig; + +public class EnemyWave { + Point2D.Double fireLocation; + long fireTime; + double bulletVelocity, directAngle, distanceTraveled; + int direction; + ArrayList allStats; + ArrayList flattenerStats; + ArrayList ABSStats; + ArrayList flattenerTickStats; + boolean flattenerLogged = false; + float[] bestBins; + float[] binCleared; + ArrayList safePoints; + PlaceTime safestPoint; + + int[][] indexes; + + boolean bulletGone = false; + boolean imaginary = false; + boolean futureWave = false; + + float weight = 0; + + Scan scan; + + //used for second-wave surfing + ArrayList possPoints; + PlaceTime possSafePT; + + public EnemyWave() { } + + static final int BINS = 171; + static final int MIDDLE_BIN = (BINS - 1)/2; + + public boolean logShadow(double time, BulletTracker bt){ + Bullet b = bt.b; + double t = 0; + Point2D.Double currentbP = new Point2D.Double(b.getX(), b.getY()); + boolean change = false; + if(binCleared == null){ + binCleared = new float[BINS]; + for(int k = 0; k < BINS; k++) + binCleared[k] = 1; + } + while(true){ + t++; + + Point2D.Double bP = project(currentbP,b.getHeadingRadians(),b.getVelocity()*(t+1)); + Point2D.Double lastbP = project(currentbP,b.getHeadingRadians(),b.getVelocity()*t); + + double en = bP.distance(fireLocation); + double len = lastbP.distance(fireLocation); + + double actDistTrav = bulletVelocity*(time - fireTime + t); + double lastDistTraveled = bulletVelocity*(time - fireTime + t-1); + if( len < lastDistTraveled | len < en ) + return change; + + if( en < actDistTrav & len > lastDistTraveled & en < len ){ + //we have intersection! + // 4 cases: + //1: closer to me + //2: closer to enemy + //3: overlaps entire wave + //4: contained within wave + + Point2D.Double p1, p2; + + if(en >= lastDistTraveled)// 1 & 4 + p1 = bP; + else{// 2 & 3 + PreciseWave wv = new PreciseWave(); + wv.fireLocation = fireLocation; + wv.distanceTraveled = lastDistTraveled; + p1 = PreciseUtils.intersection(lastbP,bP,wv); + } + if(len > actDistTrav){//1 & 3 + PreciseWave wv = new PreciseWave(); + wv.fireLocation = fireLocation; + wv.distanceTraveled = actDistTrav; + p2 = PreciseUtils.intersection(lastbP,bP,wv); + } + else // 2 & 4 + p2 = lastbP; + + double i1 = getFactorIndex(p1); + double i2 = getFactorIndex(p2); + double lowIndex = limit(0,Math.min(i1,i2),BINS); + double highIndex = limit(-1,Math.max(i1,i2),BINS-1); + + if(lowIndex == BINS | highIndex == -1) + continue; + + + int k = (int)Math.ceil(lowIndex), m = (int)Math.floor(highIndex); + for(; k <= m; k++) + binCleared[k] = 0; + if(k > 0) + binCleared[k-1] = (float)Math.max(0,binCleared[k-1] - k + lowIndex); + if(m < BINS-1) + binCleared[m+1] = (float)Math.max(0,binCleared[m+1] - highIndex + m); + + int index = bt.crossedWaves.indexOf(this); + if(index == -1) + bt.crossedWaves.add(this); + + if(bestBins != null) + change = true; + } + } + + //return change; + } + public boolean clearShadow(double time, BulletTracker bt){ + + Bullet b = bt.b; + double t = 0; + Point2D.Double currentbP = new Point2D.Double(b.getX(), b.getY()); + boolean change = false; + if(binCleared == null){ + binCleared = new float[BINS]; + for(int k = 0; k < BINS; k++) + binCleared[k] = 1; + } + + while(true){ + t++; + + Point2D.Double bP = project(currentbP,b.getHeadingRadians(),b.getVelocity()*(t+1)); + Point2D.Double lastbP = project(currentbP,b.getHeadingRadians(),b.getVelocity()*t); + + double en = bP.distance(fireLocation); + double len = lastbP.distance(fireLocation); + + double actDistTrav = bulletVelocity*(time - fireTime + t); + double lastDistTraveled = bulletVelocity*(time - fireTime + t-1); + if( len < lastDistTraveled | len < en ) + return change; + + if( en < actDistTrav & len > lastDistTraveled & en < len ){ + //we have intersection! + // 4 cases: + //1: closer to me + //2: closer to enemy + //3: overlaps entire wave + //4: contained within wave + Point2D.Double p1, p2; + + if(en >= lastDistTraveled) + p1 = bP; + else{ + PreciseWave wv = new PreciseWave(); + wv.fireLocation = fireLocation; + wv.distanceTraveled = lastDistTraveled; + p1 = PreciseUtils.intersection(lastbP,bP,wv); + } + if(len > actDistTrav){ + PreciseWave wv = new PreciseWave(); + wv.fireLocation = fireLocation; + wv.distanceTraveled = actDistTrav; + p2 = PreciseUtils.intersection(lastbP,bP,wv); + } + else + p2 = lastbP; + + double i1 = getFactorIndex(p1); + double i2 = getFactorIndex(p2); + double lowIndex = limit(0,Math.min(i1,i2),BINS); + double highIndex = limit(-1,Math.max(i1,i2),BINS-1); + + if(lowIndex == BINS || highIndex == -1) + continue; + + + int k = (int)Math.ceil(lowIndex), m = (int)Math.floor(highIndex); + for(; k <= m; k++) + binCleared[k] = 1; + if(k > 0) + binCleared[k-1] = (float)Math.min(1,binCleared[k-1] + k - lowIndex); + if(m < BINS-1) + binCleared[m+1] = (float)Math.min(1,binCleared[m+1] + highIndex - m); + if(bt != null){ + int index = bt.crossedWaves.indexOf(this); + if(index != -1){ + bt.crossedWaves.remove(index); + } + } + + if(bestBins != null) + change = true; + } + } + //return change; + } + + public double getFactorIndex(Point2D.Double targetLocation) { + double absAngle = absoluteBearing(fireLocation, targetLocation); + return getFactorIndex(absAngle); + } + public double getFactorIndex(double absoluteBearing) { + double offsetAngle = (absoluteBearing - directAngle); + double factor = FastTrig.normalRelativeAngle(offsetAngle) + / maxEscapeAngle() * direction; + + return limit(0,(0.9*factor * ((BINS - 1) / 2)) + ((BINS - 1) / 2),BINS-1); + } + + public double maxEscapeAngle() { + return FastTrig.asin(8.0/bulletVelocity); + } + + + private static double absoluteBearing(Point2D source, Point2D target) { + return FastTrig.atan2(target.getX() - source.getX(), target.getY() - source.getY()); + } + private static Point2D.Double project(Point2D.Double sourceLocation, double angle, double length) { + return new Point2D.Double(sourceLocation.x + FastTrig.sin(angle) * length, + sourceLocation.y + FastTrig.cos(angle) * length); + } + public static double limit(double min, double value, double max) { + if(value > max) + return max; + if(value < min) + return min; + + return value; + } +} \ No newline at end of file diff --git a/tools/robocode_shim/vendor/drussgt/src/jk/mega/dMove/MovePredictor.java b/tools/robocode_shim/vendor/drussgt/src/jk/mega/dMove/MovePredictor.java new file mode 100644 index 0000000..c678531 --- /dev/null +++ b/tools/robocode_shim/vendor/drussgt/src/jk/mega/dMove/MovePredictor.java @@ -0,0 +1,229 @@ +package jk.mega.dMove; +import java.awt.geom.*; +import jk.precise.util.*; +import jk.math.FastTrig; + +public class MovePredictor{ + + Point2D.Double fromLocation; + Point2D.Double toLocation; + double initialVelocity, initialHeading; + long currentTime; + EnemyWave wave; + + double bearing,velocity,distanceRemaining, heading ; + int time; + + Point2D.Double endPoint; + int counter; + double sinVal , cosVal; + boolean inline; + + public MovePredictor(){} + + public MovePredictor( + Point2D.Double fromLocation, + Point2D.Double toLocation, + double initialVelocity, + double initialHeading, + long currentTime, + EnemyWave wave){ + + recycle(fromLocation,toLocation,initialVelocity,initialHeading,currentTime,wave); + } + + public void recycle ( + Point2D.Double fromLocation, + Point2D.Double toLocation, + double initialVelocity, + double initialHeading, + long currentTime, + EnemyWave wave){ + + this.fromLocation = fromLocation; + this.toLocation = toLocation; + this.initialVelocity = initialVelocity; + this.initialHeading = initialHeading; + this.currentTime = currentTime; + this.wave = wave; + + + bearing = absoluteBearing(fromLocation,toLocation); + velocity = initialVelocity; + distanceRemaining = fromLocation.distance(toLocation);; + time = (int)(currentTime - wave.fireTime); + heading = initialHeading; + + endPoint = (Point2D.Double)fromLocation.clone(); + counter = 5 + (int)Math.ceil(endPoint.distance(wave.fireLocation)/(wave.bulletVelocity-8)) - time; + sinVal = 0; + cosVal = 0; + inline = false; + } + + + public PredictionStatus predictToIntersection(){ + + while(notIntersectedEarlyExit()){ + predict(); + } + + if(counter == 0) + System.out.println("PREVENTED PREDICTION FREEZE!!"); + + time = (int)(endPoint.distance(wave.fireLocation)/wave.bulletVelocity) + (int)wave.fireTime; + + return new PredictionStatus(endPoint,velocity,FastTrig.normalAbsoluteAngle(heading),time,distanceRemaining); + } + public PredictionStatus predictToPreciseIntersection(){ + + + while(notQuiteIntersected()){ + predict(); + } + double[] intersectionIndices = {(double)EnemyWave.BINS,0.0}; + + PreciseWave pw = new PreciseWave(); + pw.fireLocation = wave.fireLocation; + pw.bulletVelocity = wave.bulletVelocity; + + while(notIntersectedEarlyExit()){ + predict(); + updatePreciseRange(pw,intersectionIndices); + } + PredictionStatus hitStatus = + new PredictionStatus(endPoint,velocity,FastTrig.normalAbsoluteAngle(heading), + time,distanceRemaining,intersectionIndices); + + do{ + predict(); + }while(--counter != 0 && updatePreciseRange(pw,intersectionIndices) != PreciseUtils.PASSED); + + if(counter == 0) + System.out.println("PREVENTED PREDICTION FREEZE!!"); + time = (int)(endPoint.distance(wave.fireLocation)/wave.bulletVelocity) + (int)wave.fireTime; + + hitStatus.time = time; + return hitStatus; + } + int updatePreciseRange(PreciseWave pw, double[] intersectionIndices){ + pw.distanceTraveled = wave.bulletVelocity*time; + int code = PreciseUtils.intersects(endPoint,pw); + if(code == PreciseUtils.INTERSECTION){ + double[] angleRange = PreciseUtils.getIntersectionRange(endPoint,pw); + double[] indexes = {wave.getFactorIndex(angleRange[0]),wave.getFactorIndex(angleRange[1])}; + if(indexes[1] < indexes[0]){ + double temp = indexes[0]; + indexes[0] = indexes[1]; + indexes[1] = temp; + } + intersectionIndices[0] = Math.min(intersectionIndices[0],indexes[0]); + intersectionIndices[1] = Math.max(intersectionIndices[1],indexes[1]); + } + return code; + } + + + + void predict(){ + time++; + if(!inline & (distanceRemaining > 1 | Math.abs(velocity) > 0.1)) + { + double maxTurn = Math.PI/18 - Math.PI/240*Math.abs(velocity); + bearing = absoluteBearing(endPoint,toLocation); + double offset = FastTrig.normalRelativeAngle(bearing - heading); + if(-Math.PI/2 > offset | offset > Math.PI/2){ + offset = FastTrig.normalRelativeAngle(offset + Math.PI); + velocity = -velocity; + heading += Math.PI; + } + offset = limit(-maxTurn,offset,maxTurn); + heading += offset; + sinVal = FastTrig.sin(heading); + cosVal = FastTrig.cos(heading); + if(-0.0001 < offset & offset < 0.0001) + inline = true; + } + + velocity = getNewVelocity(velocity, distanceRemaining); + + endPoint.x += sinVal*velocity; + endPoint.y += cosVal*velocity; + + /*if(endPoint.x < W + | endPoint.x > E + | endPoint.y < S + | endPoint.y > N){ + + velocity = 0; + + endPoint.x -= sinVal*velocity; + endPoint.y -= cosVal*velocity; + + }*/ + + if(velocity > distanceRemaining) + inline = false; + if(inline) + distanceRemaining = Math.abs(distanceRemaining - velocity); + else + distanceRemaining = endPoint.distance(toLocation); + } + boolean notIntersectedEarlyExit(){ + return endPoint.distanceSq(wave.fireLocation) > sqr(wave.bulletVelocity*(time+1)) + & (Math.abs(distanceRemaining) > 0.1 || Math.abs(velocity) > 0.1) + & --counter != 0; + } + boolean notQuiteIntersected(){ + return endPoint.distanceSq(wave.fireLocation) > sqr(wave.bulletVelocity*(time+1) + 25.4 + 8) + & --counter != 0; + } + + //3 optimized methods from the new robocode engine + private static double getNewVelocity(double velocity, double distance) { + if(distance < 0) + return -getNewVelocity(-velocity,-distance); + + final double goalVel = Math.min(getMaxVelocity(distance), 8); + + if(velocity >= 0) + return limit(velocity - 2, + goalVel, velocity + 1); + + return limit(velocity - 1, + goalVel, velocity + maxDecel(-velocity)); + } + + static final double getMaxVelocity(double distance) { + final double decelTime = Math.round( + //sum of 0... decelTime, solving for decelTime + //using quadratic formula, then simplified a lot + Math.sqrt(distance + 1)); + + final double decelDist = Math.max(0, (decelTime) * (decelTime-1) ); + // sum of 0..(decelTime-1) + // * Rules.DECELERATION*0.5; + + return Math.max(0,((decelTime - 1) * 2) + ((distance - decelDist) / decelTime)); + } + + private static final double maxDecel(double speed) { + return limit(1,speed*0.5 + 1, 2); + } + + + + private static double limit(double min, double val, double max){ + if(val < min) + return min; + if (val > max) + return max; + return val; + } + private static double absoluteBearing(Point2D source, Point2D target) { + return FastTrig.atan2(target.getX() - source.getX(), target.getY() - source.getY()); + } + private static double sqr(double d){ + return d*d;} + +} \ No newline at end of file diff --git a/tools/robocode_shim/vendor/drussgt/src/jk/mega/dMove/PlaceTime.java b/tools/robocode_shim/vendor/drussgt/src/jk/mega/dMove/PlaceTime.java new file mode 100644 index 0000000..e6d881a --- /dev/null +++ b/tools/robocode_shim/vendor/drussgt/src/jk/mega/dMove/PlaceTime.java @@ -0,0 +1,19 @@ +package jk.mega.dMove; +import java.awt.geom.*; +import java.util.*; + + +public class PlaceTime implements Comparable{ + Point2D.Double place; + long time; + + PredictionStatus predictionStatus; + + //speed optimizations - don't try this at home, kids! + float danger; + + + public int compareTo(Object o){ + return (int)Math.signum(danger - ((PlaceTime)o).danger); + } +} \ No newline at end of file diff --git a/tools/robocode_shim/vendor/drussgt/src/jk/mega/dMove/PredictionStatus.java b/tools/robocode_shim/vendor/drussgt/src/jk/mega/dMove/PredictionStatus.java new file mode 100644 index 0000000..aa8fa1e --- /dev/null +++ b/tools/robocode_shim/vendor/drussgt/src/jk/mega/dMove/PredictionStatus.java @@ -0,0 +1,27 @@ +package jk.mega.dMove; +import java.awt.geom.*; + +public class PredictionStatus{ + public PredictionStatus(){} + public PredictionStatus(Point2D.Double endPoint,double velocity,double heading,long time,double distanceRemaining){ + this.endPoint = endPoint; + this.finalVelocity = velocity; + this.finalHeading = heading; + this.time = time; + this.distanceRemaining = distanceRemaining; + } + public PredictionStatus(Point2D.Double endPoint,double velocity,double heading,long time,double distanceRemaining,double[] indices){ + this.endPoint = endPoint; + this.finalVelocity = velocity; + this.finalHeading = heading; + this.time = time; + this.distanceRemaining = distanceRemaining; + this.intersectionIndices = indices; + } + double finalHeading, finalVelocity, distanceRemaining; + long time; + Point2D.Double endPoint; + double[] intersectionIndices; + EnemyWave fwave; + // boolean debug; +} diff --git a/tools/robocode_shim/vendor/drussgt/src/jk/melee/MeleeRadar.java b/tools/robocode_shim/vendor/drussgt/src/jk/melee/MeleeRadar.java new file mode 100644 index 0000000..75a2959 --- /dev/null +++ b/tools/robocode_shim/vendor/drussgt/src/jk/melee/MeleeRadar.java @@ -0,0 +1,94 @@ +package jk.melee; + +import java.util.*; + +import robocode.*; +import robocode.util.*; +import java.awt.geom.*; + +import jk.math.FastTrig; + +public class MeleeRadar { + + Hashtable enemies = new Hashtable(); + AdvancedRobot bot; + Point2D.Double myLocation; + public MeleeRadar(AdvancedRobot _bot){ + bot = _bot; + + enemies.clear(); + + } + public void onTick(){ + if(bot.getRadarTurnRemaining() == 0) + bot.setTurnRadarRightRadians(Double.POSITIVE_INFINITY); + + myLocation = new Point2D.Double(bot.getX(), bot.getY()); + } + + public void onScannedRobot(ScannedRobotEvent e){ + String eName = e.getName(); + + EnemyInfo eInfo; + if((eInfo = enemies.get(eName)) == null){ + enemies.put(eName,eInfo = new EnemyInfo()); + eInfo.name = eName; + } + + eInfo.lastScanTime = (int)bot.getTime(); + double otherAngle;// = getHeadingRadians() + e.getBearingRadians(); + eInfo.location = project(myLocation,otherAngle = bot.getHeadingRadians() + e.getBearingRadians(), e.getDistance()); + + + + if(bot.getOthers() <= enemies.size()){ + Enumeration all = enemies.elements(); + int oldestScan = eInfo.lastScanTime; + while(all.hasMoreElements()){ + EnemyInfo tmp = all.nextElement(); + if(tmp.lastScanTime < oldestScan){ + otherAngle = absoluteAngle(myLocation,tmp.location); + oldestScan = tmp.lastScanTime; + } + } + if(bot.getOthers() == 1 && oldestScan == eInfo.lastScanTime){ + double angle = Utils.normalRelativeAngle(otherAngle - bot.getRadarHeadingRadians()); + bot.setTurnRadarRightRadians(Math.signum(angle)*limit(0,Math.abs(angle) + (Math.PI/4 - Math.PI/8 - Math.PI/18),Math.PI/4)); + + } + else + bot.setTurnRadarRightRadians(Utils.normalRelativeAngle(otherAngle - bot.getRadarHeadingRadians())*Double.POSITIVE_INFINITY); + } + else + bot.setTurnRadarRightRadians(Double.POSITIVE_INFINITY); + + } + + static Point2D.Double project(Point2D.Double location, double angle, double distance){ + return new Point2D.Double(location.x + distance*FastTrig.sin(angle), location.y + distance*FastTrig.cos(angle)); + } + static double absoluteAngle(Point2D source, Point2D target) { + return FastTrig.atan2(target.getX() - source.getX(), target.getY() - source.getY()); + } + + + public void onRobotDeath(RobotDeathEvent e){ + + enemies.remove(e.getName()); + } + + public static double limit(double min, double value, double max) { + if(value > max) + return max; + if(value < min) + return min; + + return value; + } + + class EnemyInfo{ + String name; + int lastScanTime; + Point2D.Double location = new Point2D.Double(); + } +} diff --git a/tools/robocode_shim/vendor/drussgt/src/jk/precise/EnergyDomeWorker.java b/tools/robocode_shim/vendor/drussgt/src/jk/precise/EnergyDomeWorker.java new file mode 100644 index 0000000..4b24d44 --- /dev/null +++ b/tools/robocode_shim/vendor/drussgt/src/jk/precise/EnergyDomeWorker.java @@ -0,0 +1,463 @@ +package jk.precise; +import robocode.*; +import robocode.util.*; +import java.awt.geom.*; +import jk.precise.util.*; +import java.util.*; + +import jk.math.FastTrig; + +public class EnergyDomeWorker +{ + final static int OPTIONS = 12; + static int[] optionScores = new int[OPTIONS]; + static int[] offsetCounts = new int[OPTIONS]; + static double[] offsets = new double[OPTIONS]; + static double[] dirOffsets = new double[OPTIONS]; + + double lastEnemyEnergy = 100; + Point2D.Double lastEnemyLocation; + ArrayList myLocations = new ArrayList(); + ArrayList enemyLocations = new ArrayList(); + ArrayList enemyHeadings = new ArrayList(); + ArrayList enemyVelocities = new ArrayList(); + double lastBearing; + double firePower; + double moveAmount; + long nextFireTime; + ArrayList enemyWaves = new ArrayList(); + double direction=1; + static double unmatchedEnemyDamage; + static double enemyDamage; + static double myDamage; + + + boolean move; + boolean aim; + boolean turn; + boolean fire; + double moveVal; + double aimAngle; + double turnAngle; + + boolean idealPosition; + Point2D.Double goalPoint; + static final double WALL_THRESHOLD = 200; + Rectangle2D.Double safeField; + + AdvancedRobot bot; + Point2D.Double myLocation; + + int bullets; + double avgBulletPower; + //double enemyEnergy = 100; + + public EnergyDomeWorker(AdvancedRobot bot){ + + this.bot = bot; + + nextFireTime = bot.getTime() + (long)Math.ceil(bot.getGunHeat()/bot.getGunCoolingRate()); + //setAdjustRadarForGunTurn(true); + //setAdjustRadarForRobotTurn(true); -- redundant + //setAdjustGunForRobotTurn(true); + if(bot.getRoundNum() > 0) + System.out.println("Enemy Gun VG scores: \n" + Arrays.toString(optionScores)); + // while(true){ + // turnRadarRight(Double.POSITIVE_INFINITY); + // } + myLocation = new Point2D.Double(bot.getX(), bot.getY()); + + safeField = new Rectangle2D.Double(WALL_THRESHOLD,WALL_THRESHOLD, + bot.getBattleFieldWidth() - 2*WALL_THRESHOLD,bot.getBattleFieldHeight() - 2*WALL_THRESHOLD); + + // int code = safeField.outcode(myLocation); + goalPoint = (Point2D.Double)myLocation.clone(); + if(safeField.contains(myLocation) || bot.getRoundNum() == 0) + idealPosition = true; + else{ + goalPoint.x = limit(WALL_THRESHOLD,goalPoint.x,bot.getBattleFieldWidth()-WALL_THRESHOLD); + goalPoint.y = limit(WALL_THRESHOLD,goalPoint.y,bot.getBattleFieldHeight()-WALL_THRESHOLD); + goTo(goalPoint); + } + + } + + public void onScannedRobot(ScannedRobotEvent e) { + + double latVel = bot.getVelocity()*Math.sin(e.getBearingRadians()); + if(latVel < 0) + direction = -1; + if(latVel > 0) + direction = 1; + + myLocation = new Point2D.Double(bot.getX(), bot.getY()); + double absBearing=e.getBearingRadians() + (bot.getHeadingRadians()); + double eDistance = e.getDistance(); + double deltaE = (lastEnemyEnergy - (lastEnemyEnergy = e.getEnergy())); + Point2D.Double enemyLocation = project(myLocation, absBearing, eDistance); + myLocations.add(0,myLocation); + enemyLocations.add(0,enemyLocation); + enemyHeadings.add(0,e.getHeadingRadians()); + enemyVelocities.add(0,e.getVelocity()); + + if(!idealPosition){ + double safeStop = Math.abs(bot.getVelocity())/2 + 3; + + if(bot.getRoundNum() == 0) + safeStop += 300;//build some history + + if( (nextFireTime - bot.getTime()) > safeStop){ + goalPoint = (Point2D.Double)myLocation.clone(); + goalPoint.x = limit(WALL_THRESHOLD,goalPoint.x,bot.getBattleFieldWidth()-WALL_THRESHOLD); + goalPoint.y = limit(WALL_THRESHOLD,goalPoint.y,bot.getBattleFieldHeight()-WALL_THRESHOLD); + goTo(goalPoint); + } + else{ + //goTo(myLocation); + bot.setAhead(0); + //idealPosition = true; + } + } + + if(bot.getTime() >= nextFireTime && lastEnemyLocation != null && (Math.min(lastEnemyEnergy,0.0999) < deltaE && deltaE < 3.001)){ + idealPosition = true; + bullets++; + if(bullets == 1) + avgBulletPower = deltaE; + else + avgBulletPower = 0.1*deltaE + 0.9*avgBulletPower; + //System.out.println("Bullet seen!"); + nextFireTime = bot.getTime() + (long)Math.ceil(Rules.getGunHeat(deltaE)/bot.getGunCoolingRate()); + double enemyBulletVelocity = Rules.getBulletSpeed(deltaE); + + double[] options = new double[OPTIONS]; + options[0] = absoluteBearing(enemyLocations.get(2),myLocations.get(2)); + options[1] = absoluteBearing(enemyLocations.get(2),myLocations.get(2)) + + enemyHeadings.get(1) - enemyHeadings.get(2); + options[2] = absoluteBearing(enemyLocations.get(1),myLocations.get(2)); + Point2D.Double predictedNext = project(enemyLocations.get(2),enemyHeadings.get(2),enemyVelocities.get(2)); + options[3] = absoluteBearing(predictedNext,myLocations.get(2)); + //System.out.println("Predicted difference: " + predictedNext.distance(enemyLocations.get(1))); + for(int i = 0; i < OPTIONS/3; i++){ + options[i + OPTIONS/3] = options[i] + offsets[i]; + options[i + 2*OPTIONS/3] = options[i] + direction*dirOffsets[i]; + } + + int maxIndex = 0; + for(int i = 0; i < OPTIONS; i++) + if(optionScores[i] > optionScores[maxIndex]) + maxIndex = i; + // System.out.println("Max index: " + maxIndex); + double bulletBearing = options[maxIndex]; + double[] moveOptions = {-0.4,0.0,0.4}; + double[] moveWeights; + if(bullets%2 == 0) + moveWeights = new double[]{0.5,0.2,1}; + else + moveWeights = new double[]{1,0.2,0.5}; + if(Math.abs(enemyVelocities.get(1)*Math.sin(enemyHeadings.get(1) - bulletBearing)) > 0.1 && maxIndex%(OPTIONS/3) < 2) + moveOptions = new double[]{0d}; + double maxDiff = 0; + for(int j = 0; j < moveOptions.length; j++){ + Point2D.Double fireLoc = project(myLocation,bot.getHeadingRadians(),moveOptions[j]); + double fireBearing = absoluteBearing(fireLoc,lastEnemyLocation); + double diff = Math.abs(Utils.normalRelativeAngle(fireBearing + Math.PI - bulletBearing)); + if(diff*moveWeights[j] > maxDiff){ + moveAmount = moveOptions[j]; + maxDiff = diff*moveWeights[j]; + } + } + //options[4] = absoluteBearing(enemyLocations.get(1),project(myLocations.get(2),getHeadingRadians(),moveAmount*0.5)); + + Point2D.Double fireLoc = project(myLocation,bot.getHeadingRadians(),moveAmount); + + double maxWidth = 0; + double bestAngle = absoluteBearing(fireLoc,enemyLocations.get(1)); + double bestPower = 0.1; + long hitTime = 0; + double maxPower = Math.min(deltaE-0.01,deltaE*(bot.getEnergy()-10)/e.getEnergy()); + // enemyEnergy = e.getEnergy(); + + for(int i = 7; i < 20; i++){ + double bulletPower = 0.1 + Math.max(0,(maxPower-0.1)*0.05*i); + // if(deltaE > 0.1) + // bulletPower += 0.01; + double myBulletVelocity = Rules.getBulletSpeed(bulletPower); + Point2D.Double bLoc = lastEnemyLocation; + double mDist = 0; + double eFireTime = -1; + double mFireTime = 1; + double t = 0; + while(true){ + t+= 1; + bLoc = project(lastEnemyLocation,bulletBearing,(t-eFireTime)*enemyBulletVelocity); + double bDistSq = bLoc.distanceSq(fireLoc); + mDist = (t - mFireTime)*myBulletVelocity; + if(mDist*mDist >= bDistSq || t > 100) + break; + } + + Point2D.Double bP = bLoc; + Point2D.Double lastbP = project(bP,bulletBearing,-enemyBulletVelocity); + + double en = bP.distance(fireLoc); + double len = lastbP.distance(fireLoc); + + double actDistTrav = mDist; + double lastDistTraveled = actDistTrav - myBulletVelocity; + + if(!( en < actDistTrav && len > lastDistTraveled && en < len )){ + System.out.println("Prediction error!"); + continue; + } + Point2D.Double p1, p2; + if(en >= lastDistTraveled) + p1 = bP; + else{ + PreciseWave wv = new PreciseWave(); + wv.fireLocation = fireLoc; + wv.distanceTraveled = lastDistTraveled; + p1 = PreciseUtils.intersection(lastbP,bP,wv); + } + if(len > actDistTrav){ + PreciseWave wv = new PreciseWave(); + wv.fireLocation = fireLoc; + wv.distanceTraveled = actDistTrav; + p2 = PreciseUtils.intersection(lastbP,bP,wv); + } + else + p2 = lastbP; + + + double d1 = absoluteBearing(fireLoc,p1); + double d2 = absoluteBearing(fireLoc,p2); + + //double pDist = p1.distance(p2); + + Point2D.Double midPoint = new Point2D.Double(0.5*(p1.x+p2.x) , 0.5*(p1.y+p2.y)); + + Rectangle2D.Double me = new Rectangle2D.Double(myLocation.x - 18.1, myLocation.y - 18.1, 36.2, 36.2); + + double diff = Utils.normalRelativeAngle(d1-d2); + double fireAngle = d1 - 0.5*diff; + double width = Math.abs(diff); + if(width > maxWidth && !me.contains(p2)){ + maxWidth = width; + bestAngle = fireAngle; + bestPower = bulletPower; + hitTime = (long)t; + } + } + + aim = true; + aimAngle = bestAngle; + + firePower = bestPower; + move = true; + moveVal = moveAmount; + + DetectWave dw = new DetectWave(); + dw.fireLocation = enemyLocations.get(1); + dw.fireTime = bot.getTime() - 2; + dw.bulletBearings = options; + dw.bearingAttempts = new boolean[OPTIONS]; + dw.bearingAttempts[maxIndex] = true; + dw.bulletVelocity = enemyBulletVelocity; + dw.interceptTime = hitTime; + dw.direction = direction; + enemyWaves.add(dw); + + } + + + if(!move && bot.getDistanceRemaining() == 0 && !aim && bot.getGunTurnRemaining() == 0 && !fire && firePower > 0){ + + fire = true; + move = true; + moveVal = -moveAmount; + + } + updateWaves(); + + if(firePower == 0 && !aim){ + aim = true; + aimAngle = absBearing; + + if(e.getEnergy() < 0.1 && e.getVelocity() == 0 &&enemyVelocities.size() > 1 && bot.getTime() > nextFireTime + 3 && + enemyVelocities.get(1) == 0 && enemyWaves.size() == 0 && bot.getEnergy() > 1 + e.getEnergy() + ){ + fire = true; + firePower = 0.1; + } + else + if( bot.getDistanceRemaining() == 0 && !move && !turn){ + turn = true; + turnAngle = absBearing + Math.PI/2; + + } + } + + if(lastEnemyLocation != null) + lastBearing = absoluteBearing(lastEnemyLocation,myLocation); + lastEnemyLocation = enemyLocation; + + if(nextFireTime < bot.getTime() - 100 && lastEnemyEnergy >= bot.getEnergy()-1){ + enemyDamage ++; + unmatchedEnemyDamage ++; + } + } + + public void goTo(Point2D.Double destination){ + + double distance = myLocation.distance(destination); + double angle; + if(-1 < distance && distance < 1 ){ + angle = 0; + distance = 0; + } + else + angle = FastTrig.normalRelativeAngle(absoluteBearing(myLocation, destination) - bot.getHeadingRadians()); + + if (Math.abs(angle) > Math.PI/2) { + distance = -distance; + if (angle > 0) { + angle -= Math.PI; + } + else { + angle += Math.PI; + } + } + + + bot.setTurnRightRadians(angle); + bot.setAhead(distance); + } + public void applyActions(){ + if(fire){ + bot.setFire(firePower); + firePower = 0; + fire = false; + } + + if(aim){ + bot.setTurnGunRightRadians(Utils.normalRelativeAngle(aimAngle - bot.getGunHeadingRadians())); + aim = false; + } + + if(move){ + bot.setAhead(moveVal); + move = false; + } + + if(turn){ + bot.setTurnRightRadians(Math.tan(turnAngle - bot.getHeadingRadians())); + turn = false; + } + + } + + void updateWaves(){ + Iterator it = enemyWaves.iterator(); + long time = bot.getTime(); + while(it.hasNext()){ + DetectWave dw = it.next(); + dw.distanceTraveled = dw.bulletVelocity*(time - dw.fireTime); + if(dw.distanceTraveled - 18 > dw.fireLocation.distance(myLocations.get(0))) + it.remove(); + } + } + boolean logBullet(Bullet b){ + double heading = b.getHeadingRadians(); + Iterator it = enemyWaves.iterator(); + long time = bot.getTime(); + while(it.hasNext()){ + DetectWave dw = it.next(); + dw.distanceTraveled = dw.bulletVelocity*(time - dw.fireTime); + Point2D.Double bloc = new Point2D.Double(b.getX(),b.getY()); + if(Math.abs(dw.distanceTraveled - dw.fireLocation.distance(bloc) - dw.bulletVelocity) < 1.1*dw.bulletVelocity){ + boolean matched = false; + + for(int i = 0; i < OPTIONS; i++){ + double diff = (Utils.normalRelativeAngle(heading - dw.bulletBearings[i])); + if(Math.abs(diff) < 0.00001){ + optionScores[i]++; + matched = true; + } + if( i < OPTIONS/3){ + offsets[i] = (offsets[i]*offsetCounts[i] + diff)/(offsetCounts[i]+1); + dirOffsets[i] = (dirOffsets[i]*offsetCounts[i] + dw.direction*diff)/(offsetCounts[i]+1); + offsetCounts[i]++; + } + } + it.remove(); + return matched; + } + } + + System.out.println("No bullet detected"); + return false; + } + public void onHitByBullet(HitByBulletEvent e){ + + lastEnemyEnergy += 20 - (e.getVelocity()); + boolean matched = logBullet(e.getBullet()); + double damage = Rules.getBulletDamage(e.getBullet().getPower()); + enemyDamage += damage; + if(!matched ){ + unmatchedEnemyDamage += damage; + } + } + + public boolean aboveScore(double goal){ + double Q = goal*0.01; + double x = (2100 + myDamage)*(1-Q)/Q; + + int maxIndex = 0; + for(int i = 0; i < OPTIONS; i++) + if(optionScores[i] > optionScores[maxIndex]) + maxIndex = i; + + if((bot.getRoundNum() > 0 && optionScores[maxIndex] < bullets*0.6) + || + (bullets > 10 && lastEnemyEnergy/avgBulletPower > bot.getEnergy()/0.11) + || + (enemyLocations.size() > 0 && nextFireTime < bot.getTime() + 5 && enemyLocations.get(0).distance(myLocations.get(0)) < 80) + ) + x -= 100; + + return (enemyDamage <= x); + } + public void onBulletHitBullet(BulletHitBulletEvent e){ + logBullet(e.getHitBullet()); + } + public void onBulletHit(BulletHitEvent e){ + lastEnemyEnergy -= Rules.getBulletDamage(e.getBullet().getPower()); + myDamage += Rules.getBulletDamage(e.getBullet().getPower()); + } + static Point2D.Double project(Point2D.Double location, double angle, double distance){ + return new Point2D.Double(location.x + distance*Math.sin(angle), location.y + distance*Math.cos(angle)); + } + private double absoluteBearing(Point2D source, Point2D target) { + return Math.atan2(target.getX() - source.getX(), target.getY() - source.getY()); + } + public static double limit(double min, double value, double max) { + if(value > max) + return max; + if(value < min) + return min; + + return value; + } + + class DetectWave extends PreciseWave{ + + long fireTime; + double direction; + + double[] bulletBearings; + boolean[] bearingAttempts; + + long interceptTime; + + } +} \ No newline at end of file diff --git a/tools/robocode_shim/vendor/drussgt/src/jk/precise/util/PreciseUtils.java b/tools/robocode_shim/vendor/drussgt/src/jk/precise/util/PreciseUtils.java new file mode 100644 index 0000000..c92f2d1 --- /dev/null +++ b/tools/robocode_shim/vendor/drussgt/src/jk/precise/util/PreciseUtils.java @@ -0,0 +1,155 @@ +package jk.precise.util; +import java.awt.geom.*; +import java.util.*; +import jk.math.FastTrig; +public class PreciseUtils{ + public static final int INTERSECTION = 3, PASSED = 1, NOT_REACHED = 2; + + +//high speed test to determine if the full method should be run this tick + public static int intersects(Point2D.Double botLocation, PreciseWave wave){ + double[] distSq = new double[]{ + wave.fireLocation.distanceSq(botLocation.x - 18, botLocation.y + 18), + wave.fireLocation.distanceSq(botLocation.x + 18, botLocation.y + 18), + wave.fireLocation.distanceSq(botLocation.x + 18, botLocation.y - 18), + wave.fireLocation.distanceSq(botLocation.x - 18, botLocation.y - 18)}; + + + int score = 0; + double compDistSq = sqr(wave.distanceTraveled); + if ( compDistSq < distSq[0] & compDistSq < distSq[1] & compDistSq < distSq[2] & compDistSq < distSq[3]) + return NOT_REACHED; + + compDistSq = sqr(wave.distanceTraveled - wave.bulletVelocity); + if( compDistSq > distSq[0] & compDistSq > distSq[1] & compDistSq > distSq[2] & compDistSq > distSq[3]) + return PASSED; + + return INTERSECTION; + } + public static double[] getIntersectionRange(Point2D.Double botLocation, PreciseWave wave){ + double[] yBounds = new double[]{botLocation.y - 18, botLocation.y + 18}; + double[] xBounds = new double[]{botLocation.x - 18, botLocation.x + 18}; + + double[] radii = new double[]{wave.distanceTraveled, wave.distanceTraveled - wave.bulletVelocity}; + + ArrayList intersects = new ArrayList(); + for(int i = 0; i < 2; i++) + for(int j = 0; j < 2; j++){ + Point2D.Double[] testPoints = vertIntersect(wave.fireLocation.x, wave.fireLocation.y, radii[i], xBounds[j]); + for(int k = 0; k < testPoints.length; k++) + if(inBounds(testPoints[k].y, yBounds)) + intersects.add(testPoints[k]); + } + + for(int i = 0; i < 2; i++) + for(int j = 0; j < 2; j++){ + Point2D.Double[] testPoints = horizIntersect(wave.fireLocation.x, wave.fireLocation.y, radii[i], yBounds[j]); + for(int k = 0; k < testPoints.length; k++) + if(inBounds(testPoints[k].x, xBounds)) + intersects.add(testPoints[k]); + } + for(int i = 0; i < 2; i++) + for(int j = 0; j < 2; j++){ + Point2D.Double testCorner = new Point2D.Double(xBounds[i], yBounds[j]); + double distSq = testCorner.distanceSq(wave.fireLocation); + if(distSq <= sqr(radii[0]) && distSq > sqr(radii[1])) + intersects.add(testCorner); + } + double antiClockAngle = 1; + double clockAngle = -1; + Point2D.Double antiClock = null,clock = null; + double absBearing = angle(wave.fireLocation, botLocation); + + for(int i = 0, k = intersects.size(); i clockAngle){ + clockAngle = angDiff; + clock = p; + } + if(angDiff < antiClockAngle){ + antiClockAngle = angDiff; + antiClock = p; + } + } + // return new Point2D.Double[]{antiClock,clock}; + return new double[]{fastAbsoluteAngle(antiClockAngle + absBearing), fastAbsoluteAngle(clockAngle + absBearing)}; + } + public static Point2D.Double intersection(Point2D.Double l1, Point2D.Double l2, PreciseWave w){ + double xd = l2.x - l1.x; + double yd = l2.y - l1.y; + double a = sqr(xd) + sqr(yd); + double b = 2*(xd*(l1.x - w.fireLocation.x) + yd*(l1.y - w.fireLocation.y)); + double c = sqr(l1.x - w.fireLocation.x) + sqr(l1.y - w.fireLocation.y) - sqr(w.distanceTraveled); + double det = b*b - 4*a*c; + if(det < 0) + throw new IllegalArgumentException(); + det = Math.sqrt(det); + double t = (-b + det)/(2*a); + if(0 <= t && t <= 1) + return new Point2D.Double(l1.x + xd*t, l1.y + yd*t); + t = (-b - det)/(2*a); + if(0 <= t && t <= 1) + return new Point2D.Double(l1.x + xd*t, l1.y + yd*t); + + throw new IllegalArgumentException("t is out of range [0;1]: " + t); + } + + + + + + static boolean inBounds(double q ,double[] bounds){ + return bounds[0] <= q && q <= bounds[1] ; + } + + //assumes between -PI*2 and PI*2 + public static double fastRelativeAngle(double angle) { + return FastTrig.normalRelativeAngle(angle); + } + + //assumes between -PI*2 and PI*4 + public static double fastAbsoluteAngle(double angle){ + return FastTrig.normalAbsoluteAngle(angle); + } + + static Point2D.Double[] vertIntersect(double centerX, double centerY, double r, double intersectX){ + double deltaX = centerX - intersectX; + double sqrtVal = r*r - deltaX*deltaX; + if(sqrtVal < 0) + return new Point2D.Double[]{}; + + // if(sqrtVal == 0) + // return new Point2D.Double[]{ + // new Point2D.Double(intersectX, centerY)}; + + sqrtVal = Math.sqrt(sqrtVal); + return new Point2D.Double[]{ + new Point2D.Double(intersectX, centerY + sqrtVal), + new Point2D.Double(intersectX, centerY - sqrtVal)}; + } + static Point2D.Double[] horizIntersect(double centerX, double centerY, double r, double intersectY){ + double deltaY = centerY - intersectY; + double sqrtVal = r*r - deltaY*deltaY; + if(sqrtVal < 0) + return new Point2D.Double[]{}; + + // if(sqrtVal == 0) + // return new Point2D.Double[]{ + // new Point2D.Double(centerX, intersectY)}; + + sqrtVal = Math.sqrt(sqrtVal); + return new Point2D.Double[]{ + new Point2D.Double(centerX + sqrtVal, intersectY), + new Point2D.Double(centerX - sqrtVal, intersectY)}; + } + + public static final double sqr(double d){ + return d*d;} + + public static double angle(Point2D.Double source, Point2D.Double target) { + return FastTrig.atan2(target.x - source.x, target.y - source.y); + } + + +} diff --git a/tools/robocode_shim/vendor/drussgt/src/jk/precise/util/PreciseWave.java b/tools/robocode_shim/vendor/drussgt/src/jk/precise/util/PreciseWave.java new file mode 100644 index 0000000..57c0701 --- /dev/null +++ b/tools/robocode_shim/vendor/drussgt/src/jk/precise/util/PreciseWave.java @@ -0,0 +1,7 @@ + package jk.precise.util; + import java.awt.geom.*; + public class PreciseWave{ + public double distanceTraveled; + public double bulletVelocity; + public Point2D.Double fireLocation; + } \ No newline at end of file diff --git a/tools/robocode_shim/vendor/drussgt/src/jk/tree/KDTree.java b/tools/robocode_shim/vendor/drussgt/src/jk/tree/KDTree.java new file mode 100644 index 0000000..8c2fe60 --- /dev/null +++ b/tools/robocode_shim/vendor/drussgt/src/jk/tree/KDTree.java @@ -0,0 +1,618 @@ +package jk.tree; +/* + ** KDTree.java by Julian Kent + ** + ** Licenced under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License + ** + ** Licence summary: + ** Under this licence you are free to: + ** Share : copy and redistribute the material in any medium or format + ** Adapt : remix, transform, and build upon the material + ** The licensor cannot revoke these freedoms as long as you follow the license terms. + ** + ** Under the following terms: + ** Attribution: + ** You must give appropriate credit, provide a link to the license, and indicate + ** if changes were made. You may do so in any reasonable manner, but not in any + ** way that suggests the licensor endorses you or your use. + ** NonCommercial: + ** You may not use the material for commercial purposes. + ** ShareAlike: + ** If you remix, transform, or build upon the material, you must distribute your + ** contributions under the same license as the original. + ** No additional restrictions: + ** You may not apply legal terms or technological measures that legally restrict + ** others from doing anything the license permits. + ** + ** See full licencing details here: http://creativecommons.org/licenses/by-nc-sa/3.0/ + ** + ** For additional licencing rights please contact jkflying@gmail.com + ** + */ + + + +import java.util.ArrayList; +import java.util.Arrays; + +public abstract class KDTree { + + // use a big bucketSize so that we have less node bounds (for more cache + // hits) and better splits + private static final int _bucketSize = 50; + + private final int _dimensions; + private int _nodes; + private final Node root; + private final ArrayList nodeList = new ArrayList(); + + // prevent GC from having to collect _bucketSize*dimensions*8 bytes each + // time a leaf splits + private double[] mem_recycle; + + // the starting values for bounding boxes, for easy access + private final double[] bounds_template; + + // one big self-expanding array to keep all the node bounding boxes so that + // they stay in cache + // node bounds available at: + // low: 2 * _dimensions * node.index + 2 * dim + // high: 2 * _dimensions * node.index + 2 * dim + 1 + private final ContiguousDoubleArrayList nodeMinMaxBounds; + + private KDTree(int dimensions) { + _dimensions = dimensions; + + // initialise this big so that it ends up in 'old' memory + nodeMinMaxBounds = new ContiguousDoubleArrayList(512 * 1024 / 8 + 2 * _dimensions); + mem_recycle = new double[_bucketSize * dimensions]; + + bounds_template = new double[2 * _dimensions]; + Arrays.fill(bounds_template, Double.NEGATIVE_INFINITY); + for (int i = 0, max = 2 * _dimensions; i < max; i += 2) + bounds_template[i] = Double.POSITIVE_INFINITY; + + // and.... start! + root = new Node(); + } + + public int nodes() { + return _nodes; + } + + public int size() { + return root.entries; + } + + public int addPoint(double[] location, T payload) { + + Node addNode = root; + // Do a Depth First Search to find the Node where 'location' should be + // stored + while (addNode.pointLocations == null) { + addNode.expandBounds(location); + if (location[addNode.splitDim] < addNode.splitVal) + addNode = nodeList.get(addNode.lessIndex); + else + addNode = nodeList.get(addNode.moreIndex); + } + addNode.expandBounds(location); + + int nodeSize = addNode.add(location, payload); + + if (nodeSize % _bucketSize == 0) + // try splitting again once every time the node passes a _bucketSize + // multiple + // in case it is full of points of the same location and won't split + addNode.split(); + + return root.entries; + } + + public ArrayList> nearestNeighbours(double[] searchLocation, int K) { + + K = Math.min(K, size()); + + ArrayList> returnResults = new ArrayList>(K); + + if (K > 0) { + IntStack stack = new IntStack(); + PrioQueue results = new PrioQueue(K, true); + + stack.push(root.index); + + int added = 0; + + while (stack.size() > 0) { + int nodeIndex = stack.pop(); + if (added < K || results.peekPrio() > pointRectDist(nodeIndex, searchLocation)) { + Node node = nodeList.get(nodeIndex); + if (node.pointLocations == null) + node.search(searchLocation, stack); + else + added += node.search(searchLocation, results); + } + } + + double[] priorities = results.priorities; + Object[] elements = results.elements; + for (int i = 0; i < K; i++) { // forward (closest first) + SearchResult s = new SearchResult(priorities[i], (T) elements[i]); + returnResults.add(s); + } + } + return returnResults; + } + + public ArrayList ballSearch(double[] searchLocation, double radius) { + IntStack stack = new IntStack(); + ArrayList results = new ArrayList(); + + stack.push(root.index); + + while (stack.size() > 0) { + int nodeIndex = stack.pop(); + if (radius > pointRectDist(nodeIndex, searchLocation)) { + Node node = nodeList.get(nodeIndex); + if (node.pointLocations == null) + stack.push(node.moreIndex).push(node.lessIndex); + else + node.searchBall(searchLocation, radius, results); + } + } + return results; + } + + public ArrayList rectSearch(double[] mins, double[] maxs) { + IntStack stack = new IntStack(); + ArrayList results = new ArrayList(); + + stack.push(root.index); + + while (stack.size() > 0) { + int nodeIndex = stack.pop(); + if (overlaps(mins, maxs, nodeIndex)) { + Node node = nodeList.get(nodeIndex); + if (node.pointLocations == null) + stack.push(node.moreIndex).push(node.lessIndex); + else + node.searchRect(mins, maxs, results); + } + } + return results; + + } + + abstract double pointRectDist(int offset, final double[] location); + + abstract double pointDist(double[] arr, double[] location, int index); + + boolean contains(double[] arr, double[] mins, double[] maxs, int index) { + + int offset = (index + 1) * mins.length; + + for (int i = mins.length; i-- > 0;) { + double d = arr[--offset]; + if (mins[i] > d | d > maxs[i]) + return false; + } + return true; + } + + boolean overlaps(double[] mins, double[] maxs, int offset) { + offset *= (2 * maxs.length); + final double[] array = nodeMinMaxBounds.array; + for (int i = 0; i < maxs.length; i++, offset += 2) { + double bmin = array[offset], bmax = array[offset + 1]; + if (mins[i] > bmax | maxs[i] < bmin) + return false; + } + + return true; + } + + public static class Euclidean extends KDTree { + public Euclidean(int dims) { + super(dims); + } + + double pointRectDist(int offset, final double[] location) { + offset *= (2 * super._dimensions); + double distance = 0; + final double[] array = super.nodeMinMaxBounds.array; + for (int i = 0; i < location.length; i++, offset += 2) { + + double diff = 0; + double bv = array[offset]; + double lv = location[i]; + if (bv > lv) + diff = bv - lv; + else { + bv = array[offset + 1]; + if (lv > bv) + diff = lv - bv; + } + distance += sqr(diff); + } + return distance; + } + + double pointDist(double[] arr, double[] location, int index) { + double distance = 0; + int offset = (index + 1) * super._dimensions; + + for (int i = super._dimensions; i-- > 0;) { + distance += sqr(arr[--offset] - location[i]); + } + return distance; + } + + } + + public static class Manhattan extends KDTree { + public Manhattan(int dims) { + super(dims); + } + + double pointRectDist(int offset, final double[] location) { + offset *= (2 * super._dimensions); + double distance = 0; + final double[] array = super.nodeMinMaxBounds.array; + for (int i = 0; i < location.length; i++, offset += 2) { + + double diff = 0; + double bv = array[offset]; + double lv = location[i]; + if (bv > lv) + diff = bv - lv; + else { + bv = array[offset + 1]; + if (lv > bv) + diff = lv - bv; + } + distance += (diff); + } + return distance; + } + + double pointDist(double[] arr, double[] location, int index) { + double distance = 0; + int offset = (index + 1) * super._dimensions; + + for (int i = super._dimensions; i-- > 0;) { + distance += Math.abs(arr[--offset] - location[i]); + } + return distance; + } + } + + public static class WeightedManhattan extends KDTree { + private double[] weights; + + public WeightedManhattan(int dims) { + super(dims); + } + + public void setWeights(double[] newWeights) { + weights = newWeights; + } + + double pointRectDist(int offset, final double[] location) { + offset *= (2 * super._dimensions); + double distance = 0; + final double[] array = super.nodeMinMaxBounds.array; + for (int i = 0; i < location.length; i++, offset += 2) { + + double diff = 0; + double bv = array[offset]; + double lv = location[i]; + if (bv > lv) + diff = bv - lv; + else { + bv = array[offset + 1]; + if (lv > bv) + diff = lv - bv; + } + distance += (diff) * weights[i]; + } + return distance; + } + + double pointDist(double[] arr, double[] location, int index) { + double distance = 0; + int offset = (index + 1) * super._dimensions; + + for (int i = super._dimensions; i-- > 0;) { + distance += Math.abs(arr[--offset] - location[i]) * weights[i]; + } + return distance; + } + } + + public static class SearchResult { + public double distance; + public S payload; + + SearchResult(double dist, S load) { + distance = dist; + payload = load; + } + } + + private class Node { + + // for accessing bounding box data + // - if trees weren't so unbalanced might be better to use an implicit + // heap? + int index; + + // keep track of size of subtree + int entries; + + // leaf + ContiguousDoubleArrayList pointLocations; + ArrayList pointPayloads = new ArrayList(_bucketSize); + + // stem + // Node less, more; + int lessIndex, moreIndex; + int splitDim; + double splitVal; + + Node() { + this(new double[_bucketSize * _dimensions]); + } + + Node(double[] pointMemory) { + pointLocations = new ContiguousDoubleArrayList(pointMemory); + index = _nodes++; + nodeList.add(this); + nodeMinMaxBounds.add(bounds_template); + } + + void search(double[] searchLocation, IntStack stack) { + if (searchLocation[splitDim] < splitVal) + stack.push(moreIndex).push(lessIndex); // less will be popped + // first + else + stack.push(lessIndex).push(moreIndex); // more will be popped + // first + } + + // returns number of points added to results + int search(double[] searchLocation, PrioQueue results) { + int updated = 0; + for (int j = entries; j-- > 0;) { + double distance = pointDist(pointLocations.array, searchLocation, j); + if (results.peekPrio() > distance) { + updated++; + results.addNoGrow(pointPayloads.get(j), distance); + } + } + return updated; + } + + void searchBall(double[] searchLocation, double radius, ArrayList results) { + + for (int j = entries; j-- > 0;) { + double distance = pointDist(pointLocations.array, searchLocation, j); + if (radius >= distance) { + results.add(pointPayloads.get(j)); + } + } + } + + void searchRect(double[] mins, double[] maxs, ArrayList results) { + + for (int j = entries; j-- > 0;) + if (contains(pointLocations.array, mins, maxs, j)) + results.add(pointPayloads.get(j)); + + } + + void expandBounds(double[] location) { + entries++; + int mio = index * 2 * _dimensions; + for (int i = 0; i < _dimensions; i++) { + nodeMinMaxBounds.array[mio] = Math.min(nodeMinMaxBounds.array[mio], location[i]); + mio++; + nodeMinMaxBounds.array[mio] = Math.max(nodeMinMaxBounds.array[mio], location[i]); + mio++; + } + } + + int add(double[] location, T load) { + pointLocations.add(location); + pointPayloads.add(load); + return entries; + } + + void split() { + int offset = index * 2 * _dimensions; + + double diff = 0; + for (int i = 0; i < _dimensions; i++) { + double min = nodeMinMaxBounds.array[offset]; + double max = nodeMinMaxBounds.array[offset + 1]; + if (max - min > diff) { + double mean = 0; + for (int j = 0; j < entries; j++) + mean += pointLocations.array[i + _dimensions * j]; + + mean = mean / entries; + double varianceSum = 0; + + for (int j = 0; j < entries; j++) + varianceSum += sqr(mean - pointLocations.array[i + _dimensions * j]); + + if (varianceSum > diff * entries) { + diff = varianceSum / entries; + splitVal = mean; + + splitDim = i; + } + } + offset += 2; + } + + // kill all the nasties + if (splitVal == Double.POSITIVE_INFINITY) + splitVal = Double.MAX_VALUE; + else if (splitVal == Double.NEGATIVE_INFINITY) + splitVal = Double.MIN_VALUE; + else if (splitVal == nodeMinMaxBounds.array[index * 2 * _dimensions + 2 * splitDim + 1]) + splitVal = nodeMinMaxBounds.array[index * 2 * _dimensions + 2 * splitDim]; + + Node less = new Node(mem_recycle); // recycle that memory! + Node more = new Node(); + lessIndex = less.index; + moreIndex = more.index; + + // reduce garbage by factor of _bucketSize by recycling this array + double[] pointLocation = new double[_dimensions]; + for (int i = 0; i < entries; i++) { + System.arraycopy(pointLocations.array, i * _dimensions, pointLocation, 0, _dimensions); + T load = pointPayloads.get(i); + + if (pointLocation[splitDim] < splitVal) { + less.expandBounds(pointLocation); + less.add(pointLocation, load); + } + else { + more.expandBounds(pointLocation); + more.add(pointLocation, load); + } + } + if (less.entries * more.entries == 0) { + // one of them was 0, so the split was worthless. throw it away. + _nodes -= 2; // recall that bounds memory + nodeList.remove(moreIndex); + nodeList.remove(lessIndex); + } + else { + + // we won't be needing that now, so keep it for the next split + // to reduce garbage + mem_recycle = pointLocations.array; + + pointLocations = null; + + pointPayloads.clear(); + pointPayloads = null; + } + } + + } + + // NB! This Priority Queue keeps things with the LOWEST priority. + // If you want highest priority items kept, negate your values + private static class PrioQueue { + + Object[] elements; + double[] priorities; + private double minPrio; + private int size; + + PrioQueue(int size, boolean prefill) { + elements = new Object[size]; + priorities = new double[size]; + Arrays.fill(priorities, Double.POSITIVE_INFINITY); + if (prefill) { + minPrio = Double.POSITIVE_INFINITY; + this.size = size; + } + } + + // uses O(log(n)) comparisons and one big shift of size O(N) + // and is MUCH simpler than a heap --> faster on small sets, faster JIT + + void addNoGrow(S value, double priority) { + int index = searchFor(priority); + int nextIndex = index + 1; + int length = size - nextIndex; + System.arraycopy(elements, index, elements, nextIndex, length); + System.arraycopy(priorities, index, priorities, nextIndex, length); + elements[index] = value; + priorities[index] = priority; + + minPrio = priorities[size - 1]; + } + + int searchFor(double priority) { + int i = size - 1; + int j = 0; + while (i >= j) { + int index = (i + j) >>> 1; + if (priorities[index] < priority) + j = index + 1; + else + i = index - 1; + } + return j; + } + + double peekPrio() { + return minPrio; + } + } + + private static class ContiguousDoubleArrayList { + double[] array; + int size; + + ContiguousDoubleArrayList(int size) { + this(new double[size]); + } + + ContiguousDoubleArrayList(double[] data) { + array = data; + } + + ContiguousDoubleArrayList add(double[] da) { + if (size + da.length > array.length) + array = Arrays.copyOf(array, (array.length + da.length) * 2); + + System.arraycopy(da, 0, array, size, da.length); + size += da.length; + return this; + } + } + + private static class IntStack { + int[] array; + int size; + + IntStack() { + this(64); + } + + IntStack(int size) { + this(new int[size]); + } + + IntStack(int[] data) { + array = data; + } + + IntStack push(int i) { + if (size >= array.length) + array = Arrays.copyOf(array, (array.length + 1) * 2); + + array[size++] = i; + return this; + } + + int pop() { + return array[--size]; + } + + int size() { + return size; + } + } + + static final double sqr(double d) { + return d * d; + } + +} \ No newline at end of file diff --git a/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar b/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar new file mode 100755 index 0000000..ada2e58 Binary files /dev/null and b/tools/robocode_shim/vendor/robocode-tankroyale-bot-api-1.0.2.jar differ diff --git a/tools/robocode_shim/vendor/robocode.jar b/tools/robocode_shim/vendor/robocode.jar new file mode 100644 index 0000000..c73e0ae Binary files /dev/null and b/tools/robocode_shim/vendor/robocode.jar differ