UNPKG

agentscape

Version:

Agentscape is a library for creating agent-based simulations. It provides a simple API for defining agents and their behavior, and for defining the environment in which the agents interact. Agentscape is designed to be flexible and extensible, allowing

29 lines 882 B
import { createNoise2D } from 'simplex-noise'; export default class NoiseGenerator { /** * Generates noise with a uniform distribution. */ static uniform(rng, min = 0, max = 1) { return rng.uniformFloat(0, 1) * (max - min) + min; } /** * Generates noise with a Gaussian distribution. */ static gaussian(rng, mean = 0, stdDev = 1) { const c = rng.normalFloat(mean, stdDev); return c * stdDev + mean; } /** * Generates completely random values with no correlation between successive outputs. */ static white(rng, stdDev = 1) { return (rng.uniformFloat(0, 1) * 2 - 1) * stdDev; } /** * Generates 2D Simplex noise with output [-1, 1]. */ static simplex(rng) { return createNoise2D(() => rng.uniformFloat(0, 1)); } } //# sourceMappingURL=NoiseGenerator.js.map