Biham–Middleton–Levine traffic model simulation in JavaScript using canvas. It incorporates RC4 pseudo-random number generation to provide consistent visualisations for the same seed.
From Wikipedia:
The Biham–Middleton–Levine traffic model is a self-organizing cellular automaton traffic flow model. It consists of a number of cars represented by points on a lattice with a random starting position, where each car may be one of two types: those that only move downwards (shown as blue in this article), and those that only move towards the right (shown as red in this article). The two types of cars take turns to move. During each turn, all the cars for the corresponding type advance by one step if they are not blocked by another car.
What's interesting is the fact that even though the simulation only follows two simple rules (blue goes down, red goes right) this is sufficient to create impressive, self-organizing structures and animations.
What's even more interesting is that if you change the rule (which can be defined as a 27 digit ternary number) you can create other interesting animations. This means that the algorithm can work on 7625597484986 (over 7 trillion) different rules. Obviously most of these rules will create noise, but quite a few of them create beautiful or interesting outcomes.
See it in action (using canvas)
Warning: might create flashing images
Here's a list of interesing examples using different rules:
- Default (density 40, rule 3922832263383)
- "Bleeding" squares (density: 1, rule 6633271871019)
- Shifting glaciers (density 56, rule 2945069840504)
- Giant smoke clouds (either of the colours takes over depending on the seed, density 85, rule 1465563147788)
- Burning forest (density 42, rule 18782875399)
- Thin clouds moving (density 39, rule 3783717266644)
- Patchy pattern (density 26, rule 6492595613908)
- Disease spreading (density 41, rule 2422537391442)
- Funny looking clouds (density 44, rule 3632664672427)