UNPKG

malwoden

Version:

![alt text](./coverage/badge-lines.svg) ![alt text](./coverage/badge-statements.svg) ![alt text](./coverage/badge-functions.svg) ![alt text](./coverage/badge-branches.svg)

51 lines (50 loc) 1.66 kB
import { IRNG } from "../rand"; import { ConnectData } from "./util"; import { Builder } from "./builder"; interface CellularAutomataOptions<T> { width: number; height: number; wallValue: T; floorValue: T; rng?: IRNG; } /** Used to create CellularAutomata Maps. */ export declare class CellularAutomataBuilder<T> extends Builder<T> { private aliveValue; private deadValue; private rng; /** * Creates a Cellular Automata Map Generator * * @param config.width The width of the map. * @param config.height The height of the map. * @param config.aliveValue The value to use for alive tiles * @param config.deadValue The value to use for dead tiles */ constructor(options: CellularAutomataOptions<T>); /** * Randomly sets each cell to either alive or dead. * * @param isAliveChance The chance for a cell to be set to the 'alive' value. */ randomize(isAliveChance?: number): void; private countAliveNeighbors; /** * Runs a number of simulation steps. * Each step generally "smooths" the map. * * @param stepCount The number of steps to run. */ doSimulationStep(stepCount?: number): void; /** * Connects areas of the map to ensure they are all connected. * * For instance, if you're using an alive value of 1 for walls, * then this can connect the dead value of 0 to ensure all * squares on the map are accessable. * * @param value The value to connect (default this.deadValue) */ connect(value?: T): ConnectData; } export {};