Skip to content

Official Implementation: Survival of the Useful: Evolutionary Boids as a Sandbox for Agent Societies.

License

Notifications You must be signed in to change notification settings

QiRebecca/boids-evolution

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Boids Evolution v1.0 - Simple Cognitive Boids

An ultra-minimal implementation of emergent intelligence through 3 simple boids rules applied to tool creation and usage. This system demonstrates how local interactions between agents can create emergent specialization, collaboration, and tool ecosystems.

🎯 Core Innovation: 3 Boids Rules → Emergent Tool Collaboration

The key breakthrough: Agents follow just 3 simple local rules yet emergent complex tool ecosystems arise naturally.

The 3 Boids Rules

1. SEPARATION:  Avoid building exact same tools as neighbors (creates niches)
2. ALIGNMENT:   Copy successful neighbors' strategies (spreads good patterns)  
3. COHESION:    Use neighbors' tools when possible (creates collaboration)

Example Emergent Behavior:

  • Agent A builds data_tool_v1 → Agent B sees this → applies SEPARATION → builds logic_tool_v1
  • Agent C sees A is successful → applies ALIGNMENT → also builds data tools
  • Agent B uses A's data tool → applies COHESION → creates collaboration
  • Result: Natural specialization and tool ecosystem without central coordination!

🚀 Quick Start

Prerequisites

  • Python 3.8+
  • No external dependencies needed!

Installation

  1. Clone and run:
git clone <your-repo-url>
cd boids-evolution
python3 main_simple.py
  1. Try different configurations:
# Default: 3 agents, triangle topology, 20 steps
python3 main_simple.py

# More agents and steps
python3 main_simple.py --agents 5 --steps 50

# Different network topologies
python3 main_simple.py --topology line --agents 4
python3 main_simple.py --topology star --agents 6

🎮 Usage Examples

Simple Boids Simulations

# Default simulation
python3 main_simple.py

# More agents for richer dynamics
python3 main_simple.py --agents 6 --steps 30

# Different topologies create different behaviors
python3 main_simple.py --topology line --agents 5
python3 main_simple.py --topology star --agents 4

# Export results for analysis
python3 main_simple.py --export results.json --quiet

Command Line Options

--agents N      Number of agents (default: 3)
--steps N       Simulation steps (default: 20) 
--topology T    Network topology: triangle/line/star (default: triangle)
--quiet         Minimal output mode
--export FILE   Export results to JSON file

🛠️ How Simple Boids Works

1. Local Observation

Each agent observes only its immediate neighbors:

Agent_01 observes: Agent_02 has [data_tool_v1], Agent_03 has [logic_tool_v1]

2. Apply 3 Boids Rules

Agent calculates preferences based on the rules:

SEPARATION: Agent_02 has data tool → reduce preference for building data tools
ALIGNMENT: Agent_02 seems successful → increase preference for their recent actions  
COHESION: Neighbors have tools → increase preference for using their tools

3. Weighted Action Selection

Rules are combined with genetic weights:

final_preference = (
    separation_preference * 0.4 +
    alignment_preference * 0.3 +
    cohesion_preference * 0.3
)

4. Emergent Patterns

  • Specialization: Agents naturally focus on different tool types
  • Collaboration: Agents use each other's tools
  • Diversity: All 4 tool types emerge without coordination

🎨 Visualization Features

1. Real-time Agent Communication

💬 Agent_01 says:
┌──────────────────────────────────────────────────────────┐
│ Propose tool: Matrix_Calculator - Handles 2D matrix ops │
│ like multiplication, inversion for ML applications       │
└──────────────────────────────────────────────────────────┘

2. Tool Marketplace Status

🛠️  Tool Marketplace Summary:
  📋 Active proposals: 3
  🔨 In development: 1  
  ✅ Completed tools: 2

🔥 Hot discussions:
  • Universal_Data_Parser: 2.5 support
  • Matrix_Calculator: 1.0 support
  • API_Connector: 3.0 support

3. Energy Distribution

🔨 Tool building: +10 (built Matrix_Calculator)
💬 Communication: +3 (supported 2 proposals)  
💰 Tool utility: +15 (your Data_Parser used in 3 new tools)

4. Agent Reputation Tracking

⭐ Agent_02 Reputation: 23 points
   📋 Proposals: 2 (×3 points each)
   🔨 Builds: 3 (×5 points each)  
   👍 Supports: 8 (×1 point each)

🔬 Research Implications

This implementation validates breakthrough concepts in collaborative AI:

1. Emergent Tool Ecosystems

  • Collaborative creation: Tools emerge from community needs, not individual planning
  • Specialization: Some agents become "architects" (proposers), others "builders" (implementers)
  • Natural selection: Only tools with community support get built

2. "Survival Through Usefulness" Economics

  • Utility rewards: Tool creators prosper when their tools enable others to build MORE tools
  • Sustainable incentives: Creating foundational tools provides ongoing energy income
  • Ecosystem growth: Each new tool expands possibilities for future tools

3. Communication-Driven Development

  • Social coordination: Agents convince each other what tools are worth building
  • Distributed planning: No central authority, yet coherent tool ecosystem emerges
  • Peer review: Community support acts as quality filter

4. Scalable Collaborative Intelligence

  • Modular architecture: New tools seamlessly integrate into existing ecosystem
  • Incremental complexity: Simple tools become building blocks for sophisticated systems
  • Network effects: More agents = more diverse tools = more building possibilities

🎯 Core Principles Demonstrated

Talk → Act → Reward Enhanced for Tool Building

The marketplace amplifies the basic loop:

  1. Talk: Agents propose tool ideas and convince others of their value
  2. Act: Agents support promising proposals and build accepted tools
  3. Reward: Energy flows to proposers, supporters, and builders
  4. Utility: Long-term energy when tools become building blocks for others

Communication-Driven Collaboration

  • Proposal discussions: Agents "sell" their tool ideas to gain support
  • Collaborative building: Multiple agents can work on complex tools
  • Knowledge sharing: Tool descriptions and dependencies guide ecosystem growth
  • Peer validation: Community support ensures tools meet real needs

🛣️ Future Extensions

From this v0.0 foundation, natural progressions include:

v0.1: Advanced Tool Development

  • LLM-generated code: Agents write sophisticated tool implementations using AI
  • Tool testing: Automatic validation and unit testing of agent-created tools
  • Version control: Tools evolve through community improvements
  • Dependency management: Automatic resolution of tool requirements

v0.2: Tool Economy

  • Energy markets: Agents trade energy for exclusive tool access
  • Tool licensing: Creators set usage prices and licensing terms
  • Quality metrics: Community ratings and performance benchmarks
  • Tool fusion: Combining multiple tools into new hybrid capabilities

v0.3: Evolutionary Dynamics

  • Tool mutation: Variations and improvements on existing tools
  • Competitive building: Multiple implementations of the same concept
  • Ecosystem niches: Specialized tools for specific domains emerge
  • Survival pressure: Unused tools eventually disappear

v0.4: Multi-Agent Organizations

  • Tool guilds: Groups of agents specializing in specific domains
  • Collaborative projects: Large tools built by agent teams
  • Knowledge transfer: Agents teaching each other building techniques
  • Cultural evolution: Building patterns and practices spread through society

📊 Example Session Output

🐦 Simple Boids Simulation Starting
   Agents: 3 | Topology: triangle
   Steps: 10
   Rules: Separation + Alignment + Cohesion

📊 Step 1:
   ⚡ Agent_01: tried to use tool (none available) (total tools: 0)
   📊 Agent_02: built data_tool_v1_Agent_02 (total tools: 1)
   🔧 Agent_03: built utility_tool_v1_Agent_03 (total tools: 1)

📊 Step 2:
   🔧 Agent_01: built utility_tool_v1_Agent_01 (total tools: 1)
   🧠 Agent_02: built logic_tool_v1_Agent_02 (total tools: 2)
   ⚡ Agent_03: used logic_tool_v1_Agent_02 (total tools: 1)

📊 Step 3:
   🔗 Agent_01: built connector_tool_v1_Agent_01 (total tools: 2)
   ⚡ Agent_02: used utility_tool_v1_Agent_01 (total tools: 2)
   🔗 Agent_03: built connector_tool_v1_Agent_03 (total tools: 2)

🧬 BOIDS EMERGENCE ANALYSIS:
   📊 Total Tools Created: 21
   🎯 Tool Type Distribution: {'utility': 6, 'connector': 8, 'logic': 3, 'data': 4}
   🤖 Agent Specializations: {'Agent_01': 'connector', 'Agent_02': 'data', 'Agent_03': 'connector'}
   ✨ SPECIALIZATION EMERGED! 2 different niches
   🎨 DIVERSITY EMERGED! 4 tool types created
   🤝 COLLABORATION EMERGED! 7 tool usage events

🧪 Technical Architecture

Core Components

  • SimpleBoid: Ultra-minimal agent with 3 boids rules
  • SimpleBoidsNetwork: Network topology management and simulation orchestration
  • Local Observation: Agents only see immediate neighbors (no global state)
  • Weighted Action Selection: Genetic weights control rule influence

Simple Boids Workflow

  1. Local Observation: Agent observes neighbor tools and recent actions
  2. Rule Application: Apply separation, alignment, cohesion rules independently
  3. Weighted Combination: Combine rule preferences using genetic weights
  4. Action Execution: Build specific tool type or use neighbor tool
  5. Pattern Emergence: Specialization and collaboration emerge naturally

File Structure

boids-evolution/
├── src/
│   ├── simple_boids_agent.py     # Ultra-minimal boids agent
│   ├── simple_boids_network.py   # Network topology and simulation
│   ├── enhanced_agent.py         # Legacy marketplace agent
│   └── [other legacy files]      # Original marketplace implementation
├── main_simple.py                # Simple boids entry point
├── main.py                       # Legacy marketplace entry point
└── personal_tools/               # Legacy tool storage

💡 Key Insights

1. Communication Drives Innovation

Agents discussing tool needs leads to better-targeted tool development than individual planning.

2. Collaborative Building Scales

Complex tools emerge naturally when simple tools can be combined and built upon.

3. Utility Rewards Create Sustainability

Tool creators have ongoing incentives to build foundational tools others need.

4. Emergent Specialization

Without explicit programming, agents develop roles as architects, builders, and integrators.

5. Social Validation Works

Community support filtering ensures only valuable tools get built.

🎉 Try It Yourself!

# Start the simple boids simulation
python3 main_simple.py

# Try different configurations
python3 main_simple.py --agents 5 --steps 30 --topology star

# Watch 3 simple rules create emergent specialization!

Experience how 3 simple local rules can create complex collaborative patterns without any central coordination. 🚀


🔄 Legacy Marketplace Version

The original marketplace implementation is still available:

python main.py --demo --agents 3 --rounds 5  # Requires Azure OpenAI setup

About

Official Implementation: Survival of the Useful: Evolutionary Boids as a Sandbox for Agent Societies.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 92.9%
  • TeX 5.0%
  • Shell 1.4%
  • HTML 0.7%