# Infinite Race

*Infinite Race* is a mathematical racing game. Two players compete to move their piece the greatest distance along the number line by choosing how the dice will fall. However, the rolls must fit a distribution perfectly, so the player’s luck must revert to the mean. The strategy is to select a sequence of moves which allows one player to break free of the pack.

# Setup

Each player specifies an infinite sequence of moves at the beginning of play, where the move depends on the time step (a non-negative integer) and no other inputs. A move may be zero. For the binary version of the game, a move may either be zero or one step forward. The moves must fit the game version’s statistical distribution perfectly, although the player chooses the interval for when the conformance will be tested. For the binary version of the game, the distribution is uniform and expects an equal number of no moves (zeros) and forward moves (ones). The player’s chosen interval is known as the period.

# Movement

Players move simultaneously. If both players are moving to the same destination (integral position on the number line), one of the players may be bumped back. The player that was initially behind the other player will cause the other player to be bumped back one position. If both players were at equal positions initially, neither player is bumped back.

For example, player A is at position 3 and player B is at position 4. Player A is moving forward three positions while B is moving forward two; this means both will end up at position 6. Since A started at a position before B, A will bump back B. Thus, the end position for A will be 6 and 5 for B.

# Winning

Winning a race requires escaping the sinusoidal back-and-forth between both players. If a player manages to create a lead greater than their period, they win. In calculus terms, if we compute the quotient of each player’s position, as the time step proceeds to infinite, the quotient will either go to infinity or zero, while a non-winning race will go to one.

# Simulator

I’ve written an in-browser game simulator.

The simulator is written as a Rust library, compiled into WASM, and then run in the browser wrapped in a little bit of vanilla JavaScript.

Why? I anticipate using and expanding the Rust library into other non-WASM environments, but WASM allows me to re-use the code inside the browser. Rust has one of the best code re-use stories of any major language and the type system and language design provide obstacles against sloppy coding.