agentjs-core
Version:
A comprehensive agent-based modeling framework with built-in p5.js visualization
125 lines • 3.05 kB
TypeScript
import { Agent } from '../core/agents/Agent';
import { AgentId, AgentProperties } from '../types/core';
import { MLBehaviorModel, AgentAction } from './interfaces';
/**
* ML-enhanced agent that uses machine learning models for decision making
*/
export declare class MLAgent extends Agent {
private behaviorModel?;
private predictionHistory;
private maxHistoryLength;
private fallbackEnabled;
private performanceMetrics;
constructor(id?: AgentId, properties?: AgentProperties);
/**
* Load a behavior model for this agent
* @param model ML behavior model to use
*/
loadBehaviorModel(model: MLBehaviorModel): Promise<void>;
/**
* Remove the current behavior model
*/
removeBehaviorModel(): void;
/**
* Main step function with ML prediction
*/
step(): Promise<void>;
/**
* Execute step using ML model
*/
private stepWithML;
/**
* Execute step without ML (fallback behavior)
*/
private stepWithoutML;
/**
* Get current state for ML prediction
*/
private getCurrentState;
/**
* Execute a predicted action
*/
private executeAction;
/**
* Execute movement action
*/
private executeMovement;
/**
* Execute interaction action
*/
private executeInteraction;
/**
* Execute property change action
*/
private executePropertyChange;
/**
* Execute custom action (for domain-specific extensions)
*/
private executeCustomAction;
/**
* Add action to prediction history
*/
private addToHistory;
/**
* Update performance metrics
*/
private updatePerformanceMetrics;
/**
* Get neighbors from environment
*/
private getNeighbors;
/**
* Calculate local agent density
*/
private getLocalDensity;
/**
* Calculate distances to environment boundaries
*/
private getBoundaryDistances;
/**
* Get confidence of last prediction
*/
private getLastPredictionConfidence;
/**
* Calculate error rate
*/
private getErrorRate;
/**
* Get performance metrics
*/
getPerformanceMetrics(): {
errorRate: number;
historyLength: number;
hasModel: boolean;
mlEnabled: boolean;
predictionCount: number;
avgPredictionTime: number;
errorCount: number;
lastPredictionTime: number;
};
/**
* Get prediction history
*/
getPredictionHistory(): AgentAction[];
/**
* Clear prediction history
*/
clearHistory(): void;
/**
* Enable or disable fallback behavior
*/
setFallbackEnabled(enabled: boolean): void;
/**
* Check if agent is using ML predictions
*/
isUsingML(): boolean;
/**
* Check if agent is in fallback mode
*/
isInFallbackMode(): boolean;
/**
* Override destroy to clean up ML resources
*/
destroy(): void;
}
//# sourceMappingURL=MLAgent.d.ts.map