import { CellGrid } from '../structures'; import Agent from './Agent'; import { Color } from '../numbers'; /** * Derive a value from a function of the cell's current state * instead of storing it as a constant. */ export declare function Dynamic(f: (cell: T) => V): (target: T, propertyKey: string) => void; export type CellConstructor = { /** * The [x,y] location of the cell in the grid beginning at [0,0]. */ location: [number, number]; color?: Color; strokeColor?: Color; energy?: number; }; /** * A cell in a grid. The basic unit of space for a model. * May be used as-is or extended to include additional properties. * * The default cell has a `location`, `color`, and `energy`. Only the `location` is required. * The default color is white and the default energy is 0. * * Additionally, a cell has a set of `tenantAgents` which are agents that occupy the cell * at the current time step. */ export default class Cell { location: [number, number]; tenantAgents: Set; color: Color; strokeColor: Color; energy: number; constructor(opts: CellConstructor); /** * Gives the distance between this Cell and another Cell or Agent. */ distanceTo(world: CellGrid, other: T, options?: { metric?: 'euclidean' | 'manhattan'; }): number; /** * Gets all Cells within a given square radius. */ getNeighborsInRadius(world: CellGrid, options?: { includeSelf?: boolean; radius?: number; }): Array; /** * Diffuses a property to neighboring cells. * The property function should return a number for each cell. * The cell diffuses equal shares of `rate` percentage of the property to each neighbor. */ diffuse(world: CellGrid, property: (cell: T) => number, setter: (cell: T, value: number) => void, rate: number, range?: number): void; /** * Performs a 2D convolution on the cell's neighbors using the given kernel. * The kernel is a 3x3 matrix of numbers. * The property function should return a number for each cell. * */ getNeighborConvolution(world: CellGrid, kernel: number[][], property: (cell: T) => number): number; /** * Gets the four neighbors of the cell. * Optionally includes the four diagonal neighbors and this cell. */ getNeighbors(world: CellGrid, options?: { includeDiagonals?: boolean; includeSelf?: boolean; }): Array; toJSON(): object; }