overpopulation rules
This commit is contained in:
@ -21,6 +21,7 @@
|
||||
create2dState,
|
||||
createBoard,
|
||||
conwayRules,
|
||||
overpopulationRules,
|
||||
evolve2d,
|
||||
} from "../modules/automata.js";
|
||||
import { getRandomInt, sleep } from "../modules/common.js";
|
||||
@ -34,6 +35,10 @@
|
||||
workCanvas: null,
|
||||
workCtx: null,
|
||||
ctx: null,
|
||||
available2dRules: {
|
||||
conway: conwayRules,
|
||||
overpopulation: overpopulationRules,
|
||||
},
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@ -51,6 +56,7 @@
|
||||
boardWidth: "boardWidth",
|
||||
boardHeight: "boardHeight",
|
||||
picture: "picture",
|
||||
selected2dRules: "selected2dRules",
|
||||
}),
|
||||
...mapWritableState(globalStore, {
|
||||
lastBoard: "lastBoard",
|
||||
@ -134,7 +140,10 @@
|
||||
if (!this.canDraw) return;
|
||||
const draw2dNext = async (b) => {
|
||||
if (!this.canDraw) return;
|
||||
const newBoard = evolve2d(b, conwayRules);
|
||||
const newBoard = evolve2d(
|
||||
b,
|
||||
this.available2dRules[this.selected2dRules.id]
|
||||
);
|
||||
this.drawCanvas(b, this.cellProperties);
|
||||
await sleep(this.refreshRate);
|
||||
draw2dNext(newBoard);
|
||||
|
||||
Reference in New Issue
Block a user