Skip to content

Playing with your bot

Sometimes, for testing, you might want to join the game where your bot is as another player to interact with it directly and see how it reacts.

In this guide, we will learn how to do that and play with your bot in the same game.

WARNING

Before following the steps below, ensure your openfront/.env configuration file sets ENABLE_MANUAL_INPUTS to 1:

ENABLE_MANUAL_INPUTS=1

Otherwise, you won't be able to play the game manually because your inputs (clicks, keyboard) will be ignored. See the reference for ENABLE_MANUAL_INPUTS.

  1. Start the game server locally (see Run the game locally). Do not start your bot yet.

  2. Open two different tabs side-by-side at http://localhost:9000 and wait for the main menu to load in both.

    For the following steps, this guide assumes the left tab is where you play manually, and the right tab is where your bot will be. You can choose the opposite if you want.

  3. In the left tab, click Disable ConquerHack. This tells the browser tab "you are not controlled by a bot, you are controlled by me". The button label should change to Enable ConquerHack upon clicking.

  4. In the left tab, click Create Lobby and configure the game you want to play in.

    For testing, it can prove useful to make a very simple lobby with:

    • A custom ConquerHack map (e.g. Rolex)
    • Zero bots (Bots: Disabled)
    • Donate troops enabled (so you can give troops to your bot for faster testing)
    • Mini map enabled (so the game does not take up too much resource when running locally)

    You may want to enable random spawn, but it can be more efficient to disable it and manually spawn both your player and your bot close to each other for faster interactions.

  5. Once the lobby is configured as you want, copy the invite URL.

  6. We will now start the bot. The steps will be the same as usual, with one difference: when you run the actual bot, set LOBBY_ID to the URL you just copied:

    bash
    # For Python bots
    LOBBY_ID="http://localhost:9000/#join=ckNr8fCd" python3 main.py
    
    # For Java bots
    LOBBY_ID="http://localhost:9000/#join=ckNr8fCd" java -jar target/conquerhack-bot-1.0-SNAPSHOT.jar

    This makes the bot join your private lobby instead of the default public lobby.

  7. Wait for the bot to join the game.

    Once it has joined, click the Start Game button.

  8. During the spawn phase, do not forget to spawn both your own player and your bot using each of the two tabs. You can spawn them close to each other for faster interactions.

You can then play the game in the left tab while your bot is playing in the right tab. You can interact with it, send it messages, attack it, see how it reacts.

WARNING

Make sure both browser tabs are open side-by-side and displayed at all times.

If one of the browser tabs is not displayed or is put in the background by the OS/browser for some reason, it runs in efficiency mode and the game pauses. When you get back to that tab, it will run the game from when it stopped, sped up, to catch up the actual game.

To avoid this, keep both tabs open and displayed side-by-side while playing.