User:Dllu/BML

Here's some C++ code for dealing with the Biham-Middleton-Levine traffic model. Note: this code was only used to generate the pictures in the said article, and not the videos. I used MATLAB for the videos instead. That said, this code is far faster (about 10x faster) and more elegant.

Just like how Rule 184 consists of a one-dimensional array of cells, each containing a binary value (0 or 1), the BML Traffic Model consists of a two-dimensional array of cells, each containing a trinary value (0, 1, or 2). Hence the "secret sauce" in the code, which really isn't that secret. It just looks cool.

Also,  only works in Windows. Just delete that line if you want to compile it in something else.

The code shown here should output some bitmap images. Enjoy! Please suggest any improvements in the talk page.

A more interactive real-time Processing version is available at Open Processing.

Known bugs or issues

 * If the mobility is 1, sometimes it disappears in the mobility graph.
 * The mobility graph is a scatter plot - consequently the dots are not joined and may look faint.

Real-time Processing version
A version has been ported to Processing. Click here.

Future improvements

 * Terminate program immediately when it reaches global jam or free flow (I did this with my MATLAB script) so that it doesn't waste time doing nothing.