Skip to content

Instantly share code, notes, and snippets.

@hrldcpr
Created January 27, 2013 01:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hrldcpr/4645623 to your computer and use it in GitHub Desktop.
Save hrldcpr/4645623 to your computer and use it in GitHub Desktop.
convection on http://syzygy.st
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