Practicing Artificial Intelligence Programming


Artificial Intelligence programming is probably one of the most thrilling aspects of coding, though the field still remains relatively confidential. If you wish to practice AI coding, it is complicated to find suitable online frameworks. CodinGame tackles the issue on providing an easy-to-use and adapted development environment, with everything useful to discover - and improve - your AI coding skills.

A simple definition of artificial intelligence by Scholkoff, R.J. (1990) is "A field of study that seeks to explain and emulate intelligent behaviour in term of computational processes". There are a lots of different fields where AIs are useful such as robotics, machine learning, computer vision, etc.


One common technical approach to AI is the concept of rational agent. An agent is a program that evolves in a specific environment, can perceive through sensors and act through actors. It takes decisions with its knowledge of the environment, rationally.

Simple representation of how an agent works


Each environment has its own characteristics. The most common are:

Known vs Unknown: whether or not you know something about how the environment will react. Example: a newborn child evolves in an unknown environment, he has to discover it before (that's why he tests absolutely everything).

Accessible vs Inaccessible: agents have access or not to all environment variables that could be used for decision. Example: when you play poker you don't know the other players’ cards, unless you're are a cheater or Rain Man. It's an inaccessible environment.

Deterministic vs Non-deterministic: the behaviour of the environment is defined logically vs statistically. When you play chess, you are sure that an action will have a given consequence (deterministic). For a moving robot, you're not absolutely sure of the behaviour of the motors (non-deterministic).

Static vs Dynamic: whether or not the environment is changing while agent is taking a decision. For a self driving car, someone can appear on the road while the car is thinking about what to do next. It's a dynamic environment.

Discrete vs Continuous: finite vs infinite number of actions possible for an agent.

It's really important when designing an agent to know what kind of environment you are dealing with. It will guide you and help you avoid common mistakes. Be sure to understand your environement at 100% before writing a single line of code.

CodinGame & A.I.

We believe that we learn better by practicing a lot (and even better, when practice is fun). However, the process of creating an AI agent is complicated because you have to program the environment first. You have to handle all communications between the environment and the agents (actors and sensors). You have to develop all possible behaviours of the environment. Like all rules of a chess game for example. And if you want something cool to share, you have to develop a graphical representation of the environment. It quickly becomes a hard and complex task.

We have designed a system that enables developers to focus on the intelligent part of an agent. The main goal is to simplify the process of moving from learning to practice.

 PokerChip Race Multiplayer Game

The CodinGame agent

Actors and sensors are simulated with standard output and input stream. An agent can modify the environment by printing some actions to the standard output stream. The agent can access all its sensors by reading on the standard input stream.

Here’s an agent’s Python default code on CodinGame:
import sys, math

# read global information about the environment on sensors

LX, LY, TX, TY = [int(i) for i in raw_input().split()]

while 1:   #infinite loop of sense / act
   E = int(raw_input()) # Read new information on the environment on sensors before making a decision
   # Intelligent (or not) processing

   print "SE" # Act on the environment with actors (here move to south east)

We tried to remove the programming language barriers by offering over 20 programming languages on the platform.

The CodinGame environment

We have created an abstract system which is able to handle all possible kinds of environment. Though it, we create the environment for you and we handle its behaviour. You have access to a complete description on how the environment reacts. We also handle all communications between the environment and the agents. To compare your agent's performance, we created multiplayer games with leaderboards that allow you to benchmark your AI's performance and to be automatically ranked according to other players' AIs performances. To visualize the environment, we have developped a graphical representation for each environment. Our goal is to make debugging easier and coding really exciting!

 Platinum Rift Multiplayer Game


On, we have 2 main categories of games:
  • Solo games: 1 agent in a given environment
  • Multiplayer games: 1 or more agents (multi-agents) and others players to beat.

Solo games:
  • Power of Thor: known, accessible, deterministic, static, discrete
  • Mars lander Level 1: known, accessible, deterministic, static, continuous
  • The Last Crusade - Level 3: known, inaccessible, deterministic, static, discrete

Multiplayer games:
  • The Great Escape: known, accessible, deterministic, static, discrete, one agent
  • Platinum Rift 2: known, inaccessible, deterministic, static, discrete, multiple agents
  • Platinum Rift: known, accessible, deterministic, static, discrete, multiple agents
  • Poker Chip Race: known, accessible, deterministic, dynamic, continuous, multiple agents
  • Games of Drones: known, accessible, deterministic, static, continuous, multiple agents
  • Tron Battle: known, accessible, deterministic, static, discrete, one agents


We would like to create more of these games to cover all kind of environments (non-deterministic, unknown, ...), therefore, we are open to any new ideas: please help us be inspired!

We are also thinking about a learning platform where you could both learn and practice AI in the same place. Would you personally be interested in learning AI this way?

To learn more about AI and how to develop a great agent:


  1. Great write up!

    One AI to rule them all ;)

  2. Marvelous games, great job!

    What's next, a MMOG ? :-)

    1. Why not? Would be great and we are thinking about it for the future (current identified problem: it would require too much CPU time)

  3. This comment has been removed by the author.

  4. CodinGame is a wonderful site. I'm having a lot of fun programing some basic AI agents. I think it's a good idea to provide instructional areas in the site, where people could read about basic AI concepts, main algorithms etc. The site would be even better.

  5. I really want badly to join u one day :D

  6. Wow. Look really good. Thank you for this awesome website