0.2.0 • Published 3 years ago
@mark-halls/game-of-life-data v0.2.0
Game of Life Data
A simple library of functions for generating and consuming game of life data.
Getting Started
Generate a random set of game of life xy coordinates.
import { create, next } from "@mark-halls/game-of-life-data";
// specify the dimensions of our starting data and how many points we want
const gameSettings = {
xMin: 0,
xMax: 100,
yMin: 0,
yMax: 100,
density: 0.3, //a number between 0 and 1, 0.3 is 30% coverage
};
const coords = create(gameSettings);
Get the next set of cell coordinates using game of life rules
const newCoords = next(coords);
Seeding a game
You can also create a seeded game for reproducible grids
import { createSeeded, next } from "@mark-halls/game-of-life-data";
const gameSettings = { ... };
const seed = "Any String";
const coords = createSeeded(gameSettings, seed);