Sha256: d437c62dfc0aa47e1bd473b3dbbfe73f1f29e1c28f07d28c4c31837a0f66809f
Contents?: true
Size: 754 Bytes
Versions: 1
Compression:
Stored size: 754 Bytes
Contents
Life = function (cells) { var self = this; this.cells = cells; function willLive(r, c) { var adj = self.cells.getAdjacency(r, c); switch (adj.liveCount()) { case 2: // no change return self.cells.get(r, c).alive(); case 3: // always live return true; default: // alwaysDie return false; } } this.step = function () { for (var r = 0 ; r < this.cells.rowCount() ; r++) { for (var c = 0 ; c < this.cells.columnCount() ; c++) { this.cells.get(r, c).willSurvive = willLive(r, c); } } for (var r = 0 ; r < this.cells.rowCount() ; r++) { for (var c = 0 ; c < this.cells.columnCount() ; c++) { this.cells.get(r, c).advance(); } } }; }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shenandoah-0.2.0 | features/example_projects/base/lib/life.js |