This simulation shows a variation of a Linear Congruential Generator (LCG) - A popular mathematical algorithm that generates numbers which appear to be random.

#### How It Works

Each cell's value is calculated by adding its own value with the value of the next adjacent cell. Once a cell's value has been calculated, the simulation will move on to the next cell in the grid. If the cell is the final cell in the grid, its new value will be calculated by adding its own value with the previous cell's value.

When a cell is calculated, a modulus is used to ensure that cells are constrained to a maximum value. This works by using the modulo operator (%) which returns the remainder after dividing by the modulus. This prevents values from becoming too large, and it also plays an essential role in this algorithm for generating random looking numbers.

#### Generating Random Values

The grid will start very orderly, with the cells all having the same value. As the animation progresses, the values will become more chaotic and disorganised. Eventually, after many iterations, the grid will return back to its original state (where all of the cells have the same value), and the cycle will repeat.

The number of iterations it takes to return to its original state is known as the period of the algorithm.

#### How random is *random*?

My particular implementation is not very good at generating pseudo-random numbers. You may notice that "0" rarely appears amongst the cells - you are more likely to see positive (non-zero) values. This happens because the algorithm will only generate 0 if the cell and adjacent cell adds up exactly to the value of the modulus, which is very unlikely to happen.

Regardless, the same concepts used in this algorithm are used widely in the real world. From games, which use pseudo-randomness to procedurally generate worlds to more advanced cryptographic applications.