high life rule
This commit is contained in:
@ -91,6 +91,21 @@ function conwayRules(cell, neighbors) {
|
||||
return cell;
|
||||
}
|
||||
|
||||
// variation of the game of life where a
|
||||
// cell comes to live if 6 neigbor cells are alive
|
||||
function highLifeRules(cell, neighbors) {
|
||||
// loneliness rule
|
||||
if (cell === 1 && neighbors < 2) return 0;
|
||||
// overpopulation rule
|
||||
if (cell === 1 && neighbors > 3) return 0;
|
||||
// born when three live neighbors rule
|
||||
if (cell === 0 && neighbors === 2) return 1;
|
||||
// highlife rules
|
||||
if ((cell === 0 && neighbors === 3) || neighbors === 6) return 1;
|
||||
// the cell remains the same if none apply
|
||||
return cell;
|
||||
}
|
||||
|
||||
// variation on the game of life's rules,
|
||||
// where the "three live neighbors" rule is ignored
|
||||
function threebornRules(cell, neighbors) {
|
||||
@ -184,6 +199,7 @@ export {
|
||||
overpopulationRules,
|
||||
lonelinessRules,
|
||||
threebornRules,
|
||||
highLifeRules,
|
||||
evolve1d,
|
||||
evolve2d,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user