UNPKG

agentjs-core

Version:

A comprehensive agent-based modeling framework with built-in p5.js visualization

80 lines 2.18 kB
import { MLBehaviorModel, MLAgentState, AgentAction } from '../interfaces'; /** * Generic flocking behavior ML model * Works for birds, fish, crowds, or any swarm behavior */ export declare class FlockingMLModel implements MLBehaviorModel { private model?; private inputFeatures; private outputActions; private isLoaded; private separationWeight; private alignmentWeight; private cohesionWeight; private maxSpeed; constructor(); predict(state: MLAgentState): Promise<AgentAction>; /** * ML-based prediction */ private predictWithML; /** * Rule-based flocking prediction (fallback and training data generation) */ private predictWithRules; /** * Calculate separation force (avoid crowding neighbors) */ private calculateSeparation; /** * Calculate alignment force (steer towards average heading of neighbors) */ private calculateAlignment; /** * Calculate cohesion force (steer towards center of neighbors) */ private calculateCohesion; /** * Calculate boundary avoidance force */ private calculateBoundaryAvoidance; /** * Encode agent state for ML model input */ private encodeFlockingState; /** * Decode ML output to agent action */ private decodeFlockingAction; load(modelPath: string): Promise<void>; getRequiredInputs(): string[]; getOutputActions(): string[]; dispose(): void; /** * Configure flocking behavior parameters */ configure(options: { separationWeight?: number; alignmentWeight?: number; cohesionWeight?: number; maxSpeed?: number; }): void; /** * Generate training data for this model */ generateTrainingData(scenarios: Array<{ agentCount: number; bounds: { width: number; height: number; }; }>, stepsPerScenario?: number): Array<{ input: number[]; output: number[]; }>; /** * Generate mock agent state for training data */ private generateMockState; } //# sourceMappingURL=FlockingMLModel.d.ts.map