Created
January 27, 2013 01:02
-
-
Save hrldcpr/4645623 to your computer and use it in GitHub Desktop.
convection on http://syzygy.st
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (var v = 0; v < 2*N; v++) { | |
for (var u = -N; u < N; u++) { | |
var w = getCube(u, v); | |
if (w > 0 && w < tick) { // there's a cube and it's not one we just created | |
setCube(u, v, 0); // remove it | |
if (u < N && v > 0) { | |
if (Math.random() < 0.5) // 50% of the time | |
setCube(u + 1, v - 1, tick); // directly above | |
if (Math.random() < 0.25) // 25% of the time | |
setCube(u + 1, v - 2, tick); // above-left | |
if (Math.random() < 0.25) // 25% of the time | |
setCube(u + 2, v - 1, tick); // above-right | |
if (Math.random() < 0.25) // 25% of the time | |
setCube(u + 2, v - 2, tick); // above-above | |
} | |
} | |
} | |
} | |
tick++; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment