Bot Environment
Some aspects of the bot's behavior can be configured using environment variables. These variables should be set in the .env file located in the root of your bot's directory (python/.env for Python bots and java/.env for Java bots).
TIP
Refer to the example.env file for the default configuration. Copy-paste it to your own .env file inside your chosen scaffold directory and modify it as you see fit.
CONQUERHACK_HOST
Specifies the host on which the bot should listen for incoming connections from the OpenFront client.
If this variable is not set, the bot will listen on all available network interfaces (0.0.0.0).
CONQUERHACK_PORT
Specifies the port on which the bot should listen for incoming connections from the OpenFront client.
If this variable is not set, the bot defaults to listening on port 12345.
CONQUERHACK_LOG
Specifies the logging configuration for the bot. The value of this variable determines which logging categories are enabled or disabled.
See the documentation for the configure_from_env function in the Logger API reference for more details on how this variable is interpreted and how to use it to configure logging for your bot.
CONQUERHACK_GAME_SPEED_MULTIPLIER
It can prove useful to speed up the game when testing your bot. This configuration option tells your bot how fast the game will run compared to normal.
Make sure to use the same value for both your bot and the OpenFront client.
For example, a multiplier of 2 means the game runs twice as fast (turn interval is 50ms instead of 100ms).
For tournament games, this will be set to 3. You should set it to 1 (normal speed) if you want to play the game manually, otherwise the game might be too fast for you to react.
This variable can then be used in your bot's code to adapt how long it waits between two game loops, for example:
# This variable allows you to know the current game speed multiplier
# This variable already exists in the Python scaffold's main.py
GAME_SPEEDUP = get_env_int("CONQUERHACK_GAME_SPEED_MULTIPLIER", 1)
@controller.on_loop
async def game_loop(controller: Controller):
while True:
await asyncio.sleep(2.0/GAME_SPEEDUP) # Wait for 2 seconds (game time, adapted to game speed)public class Main {
// This variable allows you to know the current game speed multiplier
private static final int GAME_SPEEDUP = Utils.getEnvInt("CONQUERHACK_GAME_SPEED_MULTIPLIER", 1);
private static void gameLoop(@NotNull Controller controller) {
while (true) {
Thread.sleep(2000/GAME_SPEEDUP); // Wait for 2 seconds (game time, adapted to game speed)
}
}
}