Martin Gardner's Racetrack

This is computer simulation of Martin Gardner's Racetrack game.

Racetrack is a paper and pencil game that simulates a car race, played by two or more players. The game is played on a squared sheet of paper, with a pencil line tracking each car's movement. The rules for moving represent a car with a certain inertia and physical limits on traction, and the resulting line is reminiscent of how real racing cars move. The game requires players to slow down before bends in the track, and requires some foresight and planning for successful play. The game is popular as an educational tool teaching vectors.

In this implementation, autonomous cars race around a grid defined by a track drawn on a canvas. The cars are controlled by a function that uses information about the track to accelerate in either the x or y direction (or both) at each turn.

Below are some demonstrations of racetracks with some sample racer implementations. The code for this simulator can be found on GitHub.

You can create your own racer directly on CodePen.