Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Biham–Middleton–Levine traffic model simulation in JavaScript
JavaScript
branch: master
Failed to load latest commit information.
js Added Stats do demos:
.gitignore Initial commit
LICENSE.md Example backgrounds, license
README.md Updating preview links
index.html Added Stats do demos:
index_bg.html Added Stats do demos:

README.md

BMLTrafficJS

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 (as a background, Webkit only)

See it in action (using canvas)

Warning: might create flashing images

Here's a list of interesing examples using different rules:

Something went wrong with that request. Please try again.