A comprehensive agent-based modeling framework with built-in p5.js visualization
npm install agentjs-core



A comprehensive agent-based modeling framework with built-in p5.js visualization, designed for social impact research and education.
Created in partnership with Apne Aap Women Worldwide, AgentJS enables educational tools that illuminate trafficking dynamics and demonstrate pathways to empowerment, supporting the vision of "a world where no child is bought or sold."
- ๐ค Multi-Agent Systems - BaseAgent, MovingAgent, NetworkAgent with extensible properties
- ๐ Flexible Environments - Continuous space and grid-based environments with spatial indexing
- ๐ Social Networks - Dynamic network formation, influence propagation, and community detection
- ๐ Data Analysis - Real-time metrics collection, statistical analysis, and export capabilities
- ๐จ Rich Visualizations - p5.js integration with customizable agent rendering and animations
- โก Performance Optimized - Spatial indexing, object pooling, and efficient algorithms
- ๐ฑ Cross-Platform - Works in browsers, Node.js, and modern bundlers
- ๐ฌ Educational Focus - Designed for social impact research and complex systems education
- ๐ง ML Integration - Built-in support for machine learning models and behavior trees
``bash`
npm install @agentjs/core p5
`typescript
import { BaseAgent, ContinuousSpace, AgentManager, Visualizer } from '@agentjs/core';
import p5 from 'p5';
// Create environment and agents
const environment = new ContinuousSpace({
width: 800,
height: 600,
boundaryType: 'periodic'
});
const agentManager = new AgentManager();
// Create agents with custom properties
for (let i = 0; i < 50; i++) {
const agent = new BaseAgent(agent-${i}, {
autonomy: Math.random() * 100,
resources: Math.random() * 100,
type: 'community_member'
});
agentManager.addAgent(agent);
environment.addAgent(agent, {
x: Math.random() * 800,
y: Math.random() * 600
});
}
// Set up visualization
const sketch = (p: p5) => {
p.setup = () => {
p.createCanvas(800, 600);
};
p.draw = () => {
p.background(240);
// Step simulation
agentManager.stepAll();
// Visualize agents
const agents = agentManager.getAllAgents();
agents.forEach(agent => {
const pos = agent.getPosition();
const autonomy = agent.getProperty('autonomy') as number;
p.fill(255 - autonomy 2.55, autonomy 2.55, 100);
p.circle(pos.x, pos.y, 10);
});
};
};
new p5(sketch);
`
`typescript
import { NetworkAgent, NetworkManager, ConnectionType } from '@agentjs/core';
// Create network manager
const networkManager = new NetworkManager();
// Create network agents
const agent1 = new NetworkAgent('person1', { trust: 80, vulnerability: 30 }, networkManager);
const agent2 = new NetworkAgent('person2', { trust: 60, vulnerability: 70 }, networkManager);
// Form supportive connection
networkManager.addConnection(
agent1.id,
agent2.id,
ConnectionType.SUPPORTIVE,
0.8 // connection strength
);
// Analyze network
const analysis = networkManager.getNetworkAnalysis();
console.log(Network has ${analysis.nodeCount} nodes and ${analysis.edgeCount} connections);`
```
@agentjs/core
โโโ core/
โ โโโ agents/ # Agent classes and behaviors
โ โโโ environment/ # Spatial environments
โ โโโ scheduling/ # Agent activation patterns
โ โโโ interactions/ # Agent interactions and networks
โโโ visualization/ # p5.js rendering system
โโโ analysis/ # Data collection and statistics
โโโ examples/ # Interactive demos and ML models
โโโ utils/ # Utility functions
Current Version: 1.0.0
This framework is actively developed as part of the EmptyAddress Network Autonomy Game project for social impact research and education.
โ
Core agent system (BaseAgent, MovingAgent, NetworkAgent) with property management
โ
Environment systems (ContinuousSpace, Grid2D) with spatial indexing
โ
Scheduling systems (RandomScheduler, SequentialScheduler)
โ
Network system (NetworkManager) with social influence and analysis
โ
Interaction engine for agent-to-agent interactions
โ
Behavior trees for complex agent behaviors
โ
Performance benchmarking and optimization
โ
Visualization system with p5.js integration, animations, and effects
โ
Machine learning model integration with TensorFlow.js
โ
TypeScript configuration with strict type checking
โ
Build system with Vite and comprehensive exports
โ
Comprehensive test suite validating all features
๐ง Interactive demonstration examples
๐ง Documentation website and tutorials
๐ง Advanced ML model training examples
This project is developed as part of the EmptyAddress educational initiative. Please see our contribution guidelines for details on how to participate.
MIT License - see LICENSE file for details.
- Apne Aap Women Worldwide for partnership and guidance
- p5.js Community for visualization framework
- Agent-Based Modeling Community for research foundations
---
Educational Impact: Every technical decision in this framework supports learning about trafficking dynamics, community empowerment, and social network effects in vulnerable populations.