agentjs-core
Version:
A comprehensive agent-based modeling framework with built-in p5.js visualization
115 lines • 3.13 kB
TypeScript
/**
* MovingAgent - Agent with velocity and movement mechanics
*/
import { BaseAgent } from './BaseAgent';
import type { AgentId, Position, AgentProperties } from '../../types/core';
/** Velocity vector interface */
export interface Velocity {
readonly vx: number;
readonly vy: number;
}
/** Movement configuration */
export interface MovementConfig {
readonly maxSpeed: number;
readonly acceleration: number;
readonly friction: number;
readonly bounceOnBoundary: boolean;
}
/**
* MovingAgent - Agent with velocity-based movement
*
* Features:
* - Velocity vector (vx, vy) for realistic movement
* - Speed limits and acceleration control
* - Boundary collision detection and response
* - Momentum and friction simulation
*
* Educational Context: Represents community members who
* move through the environment with realistic physics,
* such as people walking, vehicles, or flowing resources.
*/
export declare class MovingAgent extends BaseAgent {
/** Current velocity vector */
protected velocity: Velocity;
/** Movement configuration */
protected movementConfig: MovementConfig;
/** Previous position for collision detection */
protected previousPosition: Position;
constructor(id?: string | AgentId, initialProperties?: AgentProperties, initialPosition?: Position, movementConfig?: Partial<MovementConfig>);
/**
* Update agent position based on velocity
*/
step(): void;
/**
* Set velocity directly
*/
setVelocity(vx: number, vy: number): void;
/**
* Get current velocity
*/
getVelocity(): Velocity;
/**
* Add force to velocity (acceleration)
*/
addForce(fx: number, fy: number): void;
/**
* Apply impulse (instant velocity change)
*/
applyImpulse(ix: number, iy: number): void;
/**
* Stop agent movement
*/
stop(): void;
/**
* Set target speed in current direction
*/
setSpeed(speed: number): void;
/**
* Get current speed (magnitude of velocity)
*/
getSpeed(): number;
/**
* Get movement direction in radians
*/
getDirection(): number;
/**
* Move towards a target position
*/
moveToward(target: Position, force?: number): void;
/**
* Move away from a position
*/
moveAway(from: Position, force?: number): void;
/**
* Apply random movement (wandering behavior)
*/
wander(strength?: number): void;
/**
* Get movement configuration
*/
getMovementConfig(): MovementConfig;
/**
* Update movement configuration
*/
updateMovementConfig(config: Partial<MovementConfig>): void;
/**
* Check if agent is moving
*/
isMoving(): boolean;
/**
* Handle boundary collision with environment
*/
handleBoundaryCollision(bounds: {
width: number;
height: number;
}): void;
/**
* Apply friction to velocity
*/
private applyFriction;
/**
* Limit velocity to maximum speed
*/
private limitSpeed;
}
//# sourceMappingURL=MovingAgent.d.ts.map