Basic Implementation

Your project should include the class Player and the class Referee.
Your Referee class may then inject (using Guice) a singleton of SoloGameManager or MultiplayerGameManager (corresponding to the type of game you want to create) parameterized by your Player class.
Your Player class should extend AbstractSoloPlayer or AbstractMultiplayerPlayer.

Multiplayer Game Features

In a Multiplayer game, you will need to use the MultiplayerGameManager implementation parameterized with your Player.

Game parameters

The Multiplayer Game Manager gives you access to Game parameters. These are used to vary your game and allow configuration in the CodinGame IDE Options. The game parameters is a Properties object you can get with getGameParameters().

By default, the game parameters contain a randomized seed.

Active Players

All the players are active at the beginning of a battle. If they lose or timeout, you can choose to deactivate() them. They will no longer be in the list of players obtained with getActivePlayers().

End Game

You may want to end the game before the maximum number of turns is reached. You can use endGame() whenever one of the players meets the victory condition.

Solo Game Features

In a Solo game, you will need to use the SoloGameManager implementation parameterized with your Player.

Test cases

Your game will need at least one test case. See Test case files for more details on their creation.

The Solo Game Manager provides you the test case input with getTestCase().

End Game

In Solo games, you do not compete against other players. Therefore, you will need to decide when a player wins or loses. To do that, you have two methods:

gameManager.winGame();

and

gameManager.loseGame();

Score calculation

Once the game is published, players can submit their code to acquire a score. This score is the percentage of validators that the player has successfully passed.
Validators are a specific kind of test case. Make sure you configure them correctly.

Optimization Game Features

An Optimization game is a Solo game with a criteria score, such as Points, or Fuel as well as the normal validator score.

To configure the optimization criteria, you'll need to track in yourself in the game's code and send it as metadata with the GameRunner's putMetadata() method. More information here on the configuration of an optimization game.

Once your game is correctly configured, we advise you set the criteria score at the end of the game as below:

@OverridepublicvoidonEnd(){
// I set my criteria "Fuel" to what's left of the player's fuel
gameManager.putMetadata("Fuel", remainingFuel);
}

Rank calculation

When a player submits code in an optimization game, they are assigned:

An ordinary score: the percentage of validators successfully passed.

A total critera score: the sum of the criteria scores from each validator.

The player's rank is determiend firstly by their score, then by their total criteria score. This means a very optimized solution that fails a single validator will rank lower than a poorly optimized solution that achieves 100%.

In case of a draw in both score and total criteria score, the ranking is arbitrary.