You may have seen the
Box Car 2D game of auto racing machines generated using a genetic algorithm. The game runs on the Flash platform and uses the box2d physics engine. You can watch quite decent racing cars from shapeless freaks after a few dozen generations. The game has existed for several years, and its fans are competing in the development of new "breeds" of machines on different types of tracks. Recently, a clone of this game called
Genetic Cars , written in HTML5 and JavaScript, has appeared online. Although it still lacks much (for example, a machine editor), some things are much better done than in the original. For example, it is possible to observe the arrival of all the machines at the same time. And most importantly - you can poke around in the source!

The JavaScript version was written from scratch by
Raphael Matsunaga . In addition to open source and the simultaneous arrival of all machines in his version there is an opportunity to disable rendering - in this case, only physics is calculated, and evolution goes several times faster. Unlike Box Car D2, the behavior of the machines is not completely deterministic - the same machine on the same track may show slightly different results, so sometimes a new generation shows a worse result than the previous one. However, the pseudo-randomly generated trace based on the string that the user can specify is always the same for the same string, so there is an opportunity to compete.
Genetic Cars also has a slightly smaller initial genetic diversity - all cars have two wheels. Total car genome consists of 14 genes - much less than in Box Car 2D. 8 of them regulate the length of each vertex of the “body”, and 3 for each wheel - location, size and weight.
')
While I was writing this article, in the background window of Chromium on the track, generated on the basis of the string “habrahabr.ru”, three dozen generations of machines had to compete. Record result - 178.87 meters.