BattleRunner

Entry point for running Tank Royale battles programmatically.

Create an instance using the create factory function, then call runBattle to execute a battle. The runner is AutoCloseable and should be used with Kotlin use {} or Java try-with-resources to release the embedded server and bot processes.

Kotlin:

BattleRunner.create { embeddedServer() }.use { runner ->
val results = runner.runBattle(
setup = BattleSetup.classic { numberOfRounds = 5 },
bots = listOf(BotEntry.of("/path/to/MyBot"), BotEntry.of("/path/to/EnemyBot"))
)
println("Winner: ${results.results.first().name}")
}

Java:

try (var runner = BattleRunner.create(b -> b.embeddedServer())) {
var results = runner.runBattle(
BattleSetup.classic(s -> s.setNumberOfRounds(5)),
List.of(BotEntry.of("/path/to/MyBot"), BotEntry.of("/path/to/EnemyBot"))
);
System.out.println("Winner: " + results.getResults().get(0).getName());
}

Types

Link copied to clipboard
class Builder

DSL builder for configuring a BattleRunner.

Link copied to clipboard
object Companion
Link copied to clipboard
data class Config(val serverMode: BattleRunner.ServerMode, val intentDiagnosticsEnabled: Boolean, val recordingPath: Path?, val captureServerOutput: Boolean, val botConnectTimeoutMs: Long, val requiredBehaviorVersion: Int? = null)

Immutable configuration produced by Builder.

Link copied to clipboard
sealed class ServerMode

Describes how the server is acquired for this runner instance.

Properties

Link copied to clipboard
Link copied to clipboard
val intentDiagnostics: IntentStore?

Returns the intent diagnostics store for querying captured bot intents. Only available when intent diagnostics are enabled via Builder.enableIntentDiagnostics.

Functions

Link copied to clipboard
open override fun close()

Terminates all managed resources (bot processes, intent proxy, WebSocket connections, embedded server).

Link copied to clipboard

Starts a battle, blocks until all rounds complete, and returns structured results.

Link copied to clipboard

Starts a battle asynchronously and returns a BattleHandle for event observation and battle control.