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
27 lines (26 loc) • 1.05 kB
TypeScript
import { AgentSet, CellGrid } from '../structures';
import Vector2 from '../numbers/Vector2';
import Agent, { type AgentConstructor } from './Agent';
import Cell from './Cell';
export interface ParticleConstructor extends AgentConstructor {
initialVelocity: [number, number];
mass?: number;
}
export default abstract class Particle extends Agent {
acceleration: Vector2;
velocity: Vector2;
mass: number;
constructor(opts: ParticleConstructor);
get kineticEnergy(): number;
get momentum(): Vector2;
/**
* Applies an acceleration to the particle proportionate to the net gravitational attraction of all other particles in the given set.
*/
resolveGravitation<T extends Particle>(world: CellGrid<Cell>, particles: AgentSet<T>): void;
resolveCollisions<U extends Cell, T extends Particle>(world: CellGrid<U>, particles: AgentSet<T>, options?: {
particle?: boolean;
}): void;
private resolveParticleCollision;
private resolveBoundaryCollision;
private resolveGravitationPair;
}