Battle Runner
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
DSL builder for configuring a BattleRunner.
Describes how the server is acquired for this runner instance.
Properties
Returns the intent diagnostics store for querying captured bot intents. Only available when intent diagnostics are enabled via Builder.enableIntentDiagnostics.
Functions
Starts a battle, blocks until all rounds complete, and returns structured results.
Starts a battle asynchronously and returns a BattleHandle for event observation and battle control.