Skip to content

MaciekBaron/BMLTrafficJS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 (using canvas)

Warning: might create flashing images

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

About

Biham–Middleton–Levine traffic model simulation in JavaScript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published