Hosting a Connect6 Coding Competition

This article is about hosting a coding competition. If you want to participate, you will find all information you will need. The goal of this competition is a grand finale where everyone gets to fight.

Game rules

The game that’s played is called Connect6. These are the rules:

  • Players and stones: There are two players. Black plays first, and White second. Each player plays with an appropriate color of stones.
  • Game board: Connect6 is played on a square board made up of orthogonal lines, with each intersection capable of holding one stone. Our board will be 19×19.
  • Game moves: Black plays first, putting one black stone on one intersection. Subsequently, White and Black take turns, placing two stones on two different unoccupied spaces each turn.
  • Winner: The player who is the first to get six or more stones in a row (horizontally, vertically, or diagonally) wins.

We need to limit the response time so games won’t run forever. The server tells the KI in the beginning how much time a turn can take. However if only a portion of the time is needed the remaining time will be added to your next turn. Take a look at the protocol.

Every client runs in a docker container limited to 1 thread and 1GB RAM. The KI can consume these resources at will.

Development

To submit a KI you will be assigned to your own private repository. Your master/main branch will be checked out and build for test matches. The following programming languages/build tools will be supported:

  • Python 3.9
  • C++/C/(C)Make
  • Rust/Cargo
  • Java/Ant
  • C# (.NET Core/5)
  • GOLang

The KI can use different approaches on calculating the best move. However bear in mind you will run on a CPU!

Also we expect you to develop your own code and not use huge libraries which defeat the purpose of this competition.

For all competitions you should also provide some console parameters which we need to configure your KI.
-p which configures the port the your KI connects to
-i which configures the IP the KI connects to
-k provides you the login key your KI uses to connect to the server

Matchmaking

To have a fair competition everyone plays against everyone else. The winning KI will be awarded three point, a draw will result in one point each, and a looser will gain zero points. A disqualified KI will loose one point 🙁

The KI can be disqualified due to four reasons

  • The automatic build / execution on Linux fails
  • Sending malformed messages
  • Exceeding the time limit
  • Disconnecting before the game ends

Protocol

Because multiple teams will develop their own project we need to make some commitments to a standard of communication. All communication between the server and your client will be done using basic TCP traffic (no http, no rest api). During the game the server is the single point of truth to eliminate cheating.

The first byte of a message is the ID. Also keep in mind all network traffic is MSB (most significant bit) and big endian.

Client connects to serverContentsID
Client makes login to server8bit: login key provided by transferred parameters0
Server answers with game information8bit: color (black: 0, white: 1)1
Server send turn request32bit: (updated) remaining computation time (in ms)2
Client send turn answer8bit: x1 (0…18)
8bit: y1 (0…18)
8bit: x2 (0…18)
8bit: y2 (0…18)
3
Server broadcasts turn answer8bit: x1 (0…18)
8bit: y1 (0…18)
8bit: x2 (0…18)
8bit: y2 (0…18)
8bit: color (black: 0, white: 1)
4
Server broadcasts game end8bit: winner color (black: 0, white: 1, draw: 2)5

After the message with ID 5 is received the client must disconnect and terminate.

Take a look at this example of a message with ID 4:

IDX (16)Y (8)X2 (17)Y2 (9)Color (white)
0000 01000001 00000000 10000001 00010000 10010000 0001

Or at this example of a message with ID 2 and 525.262s:

IDUpper time byteUpper mid time byteLower mid time byteLower time byte
0000 00100000 00000000 10000000 00111100 1110

Final Countdown

The coding challenge will end on 31.07.2021 12:00! Right after that the great competition will be hosted (so changes made after that will not affect your end result!). Also this time your master/main branch will be checkout out and build.

WordPress Appliance - Powered by TurnKey Linux