coding world cup

Write AIs to play football

This project is maintained by richard shepherd nick pollard

Creating your AI

AIs run as separate processes

Each AI runs as a separate process from the main game engine. The game engine communicates with the AIs by sending them JSON messages through stdin, and by receiving replies from the AI via stdout. This means that AIs can be written in any language. When a game starts, the AI process for each team is spawned by the game engine, and is killed when the game ends.

The AIs folder

AIs live in the AIs folder. Each one should be in its own sub-folder, which should be named 'AI_[name]'. The folder should contain:

  • The executable code for the AI.
  • A 'CommandLine.txt' file indicating how to run the code.
  • The first element of 'CommandLine.txt' should be an executable either in the AI's folder or on the path. Any other elemtns are passed to the executable as command-line parameters.

    For example, the BootAndShoot sample is a C# executable with no command-line parameters. So its CommandLine.txt is just:

    BootAndShoot.exe

    The RandomMovement sample needs to be run using node.js, so its CommandLine.txt looks like:

    node RandomMovement.js

    Note: At the moment the game engine is rather fussy about the command-line, and it must not have any whitespace (including a newline) after the text.

    Listen, process, respond loop

    The main loop in your AI should be:

  • Wait for a JSON message on stdin from the game-engine.
  • Decode and process the message.
  • Respond to the message via stdout, if the message was a request (see below).
  • Loop.
  • There are two message types that your AI will receive: events and requests. Events provide updated information and do not need a response. Requests need a response (though you can in some cases provide a basic 'empty' response). See the API reference for more details of the different messages and response formats.

    Running your AI

    The file 'app.js' in the root-folder of the game-engine controls which AIs will be playing. Edit these lines to choose which AIs are playing:

    
        var ai1 = aiManager.getAIWrapperFromName('RandomMovement');
        var ai2 = aiManager.getAIWrapperFromName('BootAndShoot');
        
    The AI name should be the name of its folder without the 'AI_' prefix.

    Submitting your AI

    To submit your API, please send a zipped copy of your AI folder along with the source code, to richard.s.shepherd@gmail.com. Any executable files should be compiled for Windows. Please also indicate any frameworks (such as Java or Python) that are required, and the versions needed.