update last board, new rules
This commit is contained in:
@ -91,6 +91,28 @@ function conwayRules(cell, neighbors) {
|
||||
return cell;
|
||||
}
|
||||
|
||||
// variation on the game of life's rules,
|
||||
// where the "three live neighbors" rule is ignored
|
||||
function threebornRules(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
|
||||
return cell;
|
||||
}
|
||||
|
||||
// variation on the game of life's rules,
|
||||
// where the loneliness rule is ignored
|
||||
function lonelinessRules(cell, neighbors) {
|
||||
// overpopulation rule
|
||||
if (cell === 1 && neighbors > 3) return 0;
|
||||
// born when three live neighbors rule
|
||||
if (cell === 0 && neighbors === 3) return 1;
|
||||
// the cell remains the same if none apply
|
||||
return cell;
|
||||
}
|
||||
|
||||
// variation on the game of life's rules,
|
||||
// where the overpopulation rule is ignored
|
||||
function overpopulationRules(cell, neighbors) {
|
||||
@ -160,6 +182,8 @@ export {
|
||||
create1dStateOneCell,
|
||||
conwayRules,
|
||||
overpopulationRules,
|
||||
lonelinessRules,
|
||||
threebornRules,
|
||||
evolve1d,
|
||||
evolve2d,
|
||||
};
|
||||
|
||||
@ -104,6 +104,18 @@ const preset2dRules = [
|
||||
description:
|
||||
"Variation on Conway's Game of Life *without* the overpopulation rule",
|
||||
},
|
||||
{
|
||||
id: "loneliness",
|
||||
name: "Loneliness variation",
|
||||
description:
|
||||
"Variation on Conway's Game of Life *without* the loneliness rule",
|
||||
},
|
||||
{
|
||||
id: "threeborn",
|
||||
name: "Three lives variation",
|
||||
description:
|
||||
"Variation on Conway's Game of Life *without* the 'three live neighbors' rule",
|
||||
},
|
||||
];
|
||||
|
||||
export { presetRuleset, initialStates, preset2dRules };
|
||||
|
||||
Reference in New Issue
Block a user