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

30 lines (20 loc) 743 B
import { test as base, expect } from 'vitest' import RandomGenerator from './RandomGenerator' interface TestFixture { rng: RandomGenerator } const test = base.extend<TestFixture>({ rng: new RandomGenerator(1234) }) test('It should generate random floats between 0 and 1', ({ rng }) => { const result = rng.uniformFloat(0, 1) expect(result).toBeGreaterThanOrEqual(0) expect(result).toBeLessThanOrEqual(1) expect(Number.isInteger(result)).toBe(false) }) test('It should generate random integers between min and max', ({ rng }) => { const result = rng.uniformInt(0, 10) expect(result).toBeGreaterThanOrEqual(0) expect(result).toBeLessThanOrEqual(10) expect(Number.isInteger(result)).toBe(true) })