UNPKG

agentjs-core

Version:

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

117 lines 3.22 kB
/** * CommonBehaviors - Reusable behavior tree nodes for agents */ import { BehaviorNode, ActionNode, ConditionNode, BehaviorContext } from './BehaviorTree'; import type { Environment } from '../environment/Environment'; import type { Position } from '../../types/core'; /** * Movement behaviors */ export declare class MovementBehaviors { /** * Move towards a target position */ static moveToPosition(targetPosition: Position, speed?: number): ActionNode; /** * Wander randomly */ static wander(speed?: number): ActionNode; /** * Flee from a position */ static fleeFrom(dangerPosition: Position, speed?: number): ActionNode; } /** * Property conditions */ export declare class PropertyConditions { /** * Check if property is above threshold */ static propertyAbove(property: string, threshold: number): ConditionNode; /** * Check if property is below threshold */ static propertyBelow(property: string, threshold: number): ConditionNode; /** * Check if property equals value */ static propertyEquals(property: string, value: any): ConditionNode; /** * Check if has property */ static hasProperty(property: string): ConditionNode; } /** * Resource management behaviors */ export declare class ResourceBehaviors { /** * Consume resource */ static consumeResource(resource: string, amount: number): ActionNode; /** * Gather resource */ static gatherResource(resource: string, amount: number): ActionNode; /** * Transfer resource to another agent */ static transferResource(resource: string, _targetAgentId: string, amount: number): ActionNode; } /** * Social behaviors */ export declare class SocialBehaviors { /** * Seek nearby agents */ static seekNearbyAgents(environment: Environment, radius?: number): ActionNode; /** * Interact with nearest agent */ static interactWithNearest(): ActionNode; } /** * Utility-based decision making */ export declare class UtilityBehaviors { /** * Select action based on utility scores */ static utilitySelect(actions: Array<{ name: string; utility: (context: BehaviorContext) => number; behavior: BehaviorNode; }>): BehaviorNode; /** * Energy utility function */ static energyUtility(weight?: number): (context: BehaviorContext) => number; /** * Social utility function */ static socialUtility(weight?: number): (context: BehaviorContext) => number; } /** * Create common behavior patterns */ export declare class BehaviorPatterns { /** * Create a foraging behavior */ static createForagingBehavior(environment: Environment): BehaviorNode; /** * Create a social behavior */ static createSocialBehavior(environment: Environment): BehaviorNode; /** * Create a flee behavior */ static createFleeBehavior(dangerThreshold?: number): BehaviorNode; /** * Create a balanced agent behavior */ static createBalancedBehavior(environment: Environment): BehaviorNode; } //# sourceMappingURL=CommonBehaviors.d.ts.map