Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions bots/java/CliSmokeBot/CliSmokeBot.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@echo off
setlocal
set BOT_API_VERSION=1.1.0
if "%RUMBLE_JAVA_CACHE%"=="" set RUMBLE_JAVA_CACHE=%USERPROFILE%\.cache\rumble-bots-java
if not exist "%RUMBLE_JAVA_CACHE%" mkdir "%RUMBLE_JAVA_CACHE%"
set JAR=%RUMBLE_JAVA_CACHE%\robocode-tankroyale-bot-api-%BOT_API_VERSION%.jar
if not exist "%JAR%" curl -fsSL -o "%JAR%" "https://repo1.maven.org/maven2/dev/robocode/tankroyale/robocode-tankroyale-bot-api/%BOT_API_VERSION%/robocode-tankroyale-bot-api-%BOT_API_VERSION%.jar"
java -cp "%JAR%" "%~dp0src\CliSmokeBot.java" %*
10 changes: 10 additions & 0 deletions bots/java/CliSmokeBot/CliSmokeBot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "CliSmokeBot",
"version": "1.0.0",
"authors": ["Mathew Nelson", "Flemming N. Larsen"],
"description": "A copy of the MyFirstBot sample bot, sent only to test sending a bot from the Rumble command line.",
"platform": "JVM",
"programmingLang": "Java 17",
"gameTypes": ["1v1"],
"license": "Apache-2.0"
}
13 changes: 13 additions & 0 deletions bots/java/CliSmokeBot/CliSmokeBot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env sh
set -eu
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
BOT_API_VERSION=1.1.0
CACHE_DIR="${RUMBLE_JAVA_CACHE:-$HOME/.cache/rumble-bots-java}"
JAR="$CACHE_DIR/robocode-tankroyale-bot-api-$BOT_API_VERSION.jar"
if [ ! -f "$JAR" ]; then
mkdir -p "$CACHE_DIR"
TMP="$JAR.$$.tmp"
curl -fsSL -o "$TMP" "https://repo1.maven.org/maven2/dev/robocode/tankroyale/robocode-tankroyale-bot-api/$BOT_API_VERSION/robocode-tankroyale-bot-api-$BOT_API_VERSION.jar"
mv "$TMP" "$JAR"
fi
exec java -cp "$JAR" "$SCRIPT_DIR/src/CliSmokeBot.java" "$@"
46 changes: 46 additions & 0 deletions bots/java/CliSmokeBot/src/CliSmokeBot.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import dev.robocode.tankroyale.botapi.*;
import dev.robocode.tankroyale.botapi.events.*;

// ------------------------------------------------------------------
// CliSmokeBot
// ------------------------------------------------------------------
// A sample bot originally made for Robocode by Mathew Nelson.
//
// Probably the first bot you will learn about.
// Moves in a seesaw motion and spins the gun around at each end.
// ------------------------------------------------------------------
public class CliSmokeBot extends Bot {

// The main method starts our bot
public static void main(String[] args) {
new CliSmokeBot().start();
}

// Called when a new round is started -> initialize and do some movement
@Override
public void run() {
// Repeat while the bot is running
while (isRunning()) {
forward(100);
turnGunLeft(360);
back(100);
turnGunLeft(360);
}
}

// We saw another bot -> fire!
@Override
public void onScannedBot(ScannedBotEvent e) {
fire(1);
}

// We were hit by a bullet -> turn perpendicular to the bullet
@Override
public void onHitByBullet(HitByBulletEvent e) {
// Calculate the bearing to the direction of the bullet
var bearing = calcBearing(e.getBullet().getDirection());

// Turn 90 degrees to the bullet direction based on the bearing
turnRight(90 - bearing);
}
}
Loading