Other resources

You might need to upload other resources such as text files, csv or whatever your creativity will bring you to create.

Once you upload your game on CodinGame, your project will not have the same file system as the one you use on your computer. In order to read your files, you must place them in the src/main/resources folder and use Java's ClassLoader:

Levels & Leagues

In a multiplayer game, you have the possibility to create several levels (also named leagues). A new level allows you to set a different configuration and different rules (you can get the league level in the Referee with the Game Manager).

When the game will be released your levels will become leagues. The players will need to beat your Boss in the leaderboard to access the next league.

To create multiple levels, you need to make new folders named level<number> in the config directory. Their <number> must be positive and will be used to display your leagues in the right order. Each level can be configured like the config directory, which allow you to have different statements, stubs, etc.

If you want to use the same configuration in several levels, you do not need to copy your files in every directory. If a file is missing in a level folder, it will inherit from config automatically when uploading your game.

You can change the identifier of your game for the online IDE's cache by adding an export to config.js:

exportconst gameName = 'MyGame';

This doesn't have any effect in the local test page. It is used to store the viewer options, such as player speed, selected by the user.

Statement

Place a file named statement_en.html in the config/ directory and it will be used for as the statement of your game.

For a game with multiple leagues, you may place a file named statement_en.html.tpl in the config/ directory and it will be used as a basis for the statement of each league when you click the export button.

Within the .tpl file, you may place special comment blocks to indicate whether a block of html should be included for any specified league.

Optionally, you can tranlate your statements in French using statement_fr.html files.

Example

This statement_en.html.tpl:

<!-- LEAGUES level1 level2 level3 --><div><p> Always included </p><!-- BEGIN level1 --><p> Included in first league </p><!-- END --><!-- BEGIN level2 --><p> Included in second league </p><!-- END --><!-- BEGIN level1 level2 --><p> Included both first and second league </p><!-- END --></div>

Will result in these three statements for a three-league game:

First league in config/level1/statement_en.html:

<div><p> Always included </p><p> Included in first league </p><p> Included both first and second league </p></div>

Second league in config/level2/statement_en.html:

<div><p> Always included </p><p> Included in second league </p><p> Included both first and second league </p></div>

Third league in config/level3/statement_en.html:

<div><p> Always included </p></div>

Activating game logs

You can view the data that the Referee and the Players send each other by editing the built-in logger's settings.
To do this, open log4j2.properties in src/test/ressources and replace rootLogger.level = warn with rootLogger.level = info.
Additionally, if you would like to see the output of the different modules, you can use:
rootLogger.level = trace.

Multiplayer Game Configuration

Bosses

Multiplayer games require bosses to battle against. They will be your opponent by default in the CodinGame IDE and players will need to beat them in the leaderboard to reach the next league (if present).

Your Boss can be coded in any of the languages supported by CodinGame. Make sure you use the right extension using the following table:

Supported Languages

Language

Extensions

Clojure

.clj, .cljs

Swift

.swift

Rust

.rs

Dart

.dart

Pascal

.pas, .p

Groovy

.groovy

Lua

.lua

C++

.cpp

OCaml

.ml, .mli

ObjectiveC

.m, .mm

Scala

.scala

Java

.java

Javascript

.js, .jsm, .jsx

Python3

.py3

PHP

.php, .php3, .php4, .php5, .phps, .phpt

Kotlin

.kt

Bash

.sh

Go

.go

C

.c

Haskell

.hs

Perl

.pl, .pm

Ruby

.rb, .ru

Python

.py

F#

.fs

VB.NET

.vbs, .vb

C#

.cs

Your Boss should be coded as if it could be used in the IDE. It is suggested that you start coding your AI on the base of the code generated by your stub.

Welcome popup

Welcome popups can be used in Multiplayer games with multiple leagues. They will be displayed when a player is promoted to the next league.

Place a file named welcome_en.html in every config/level<number> directory you want the popup to be used in.

You can display images using <img src="your_image.jpg"/>. The image files must be located in the same directory.

Optionally, you can tranlate your popups in French using welcome_fr.html files.

Solo Game Configuration

Test case file

You will need to create test case files to run your Solo game.

Your test cases must be named test<number>.json and placed in the config directory. Their <number> determine the order they will be listed in the CodinGame IDE. Here is an example:

testIn: The content of your test case. It can contain multiple lines separated with \n.

isTest: If true, this test will be visible and used as a regular test case.

isValidator: If true, this test will be used to validate the player's code. You can use this to avoid hardcoded solutions and calculate Optimization games scores.

Optimization Game Configuration

Optimization games are Solo games with additional configuration.

First, you will need to add a criteria and a sorting_order property in config.ini.

The criteria corresponds to the label of the player's score. For example, it can be Points, Fuel or Distance.

The sorting_order determines the ranking order. Its value must be either asc or desc. If the player whose Fuel quantity is higher should be first, choose desc. If the goal is to win the game with the least Distance, choose asc.

You can also choose to translate your criteria in French by using the optional properties criteria_en and criteria_fr.

This configuration can be done through a form when exporting the game, if the file config.ini is missing or misconfigured.

Once this configuration is done, you will need to send your player's score with the Game Manager