Examples

Explore real-world examples of organizational patterns and multi-agent coordination.

Hierarchy Pattern

Hierarchy

Corporate organization with CEO delegating to departments and employees.

1use agentropic_patterns::hierarchy::*;
2
3 // Define the organizational hierarchy
4 let org = Hierarchy::new()
5 .with_root(CeoAgent::new("Alice"))
6 .add_child("Alice", DepartmentAgent::new("Engineering"))
7 .add_child("Alice", DepartmentAgent::new("Sales"))
8 .add_child("Engineering", EmployeeAgent::new("Bob"))
9 .add_child("Engineering", EmployeeAgent::new("Charlie"));
10
11 // CEO broadcasts a directive
12 org.broadcast_down(Directive::new("Q4 Goals")).await?;
13
14 // Employees report up the chain
15 org.report_up("Bob", Report::new("Feature shipped")).await?;

Swarm Pattern

Swarm

Drone coordination with emergent behavior and local communication.

1use agentropic_patterns::swarm::*;
2
3 // Create a swarm of drone agents
4 let swarm = Swarm::new(SwarmConfig {
5 size: 50,
6 neighborhood_radius: 10.0,
7 alignment_weight: 1.0,
8 cohesion_weight: 1.0,
9 separation_weight: 1.5,
10 });
11
12 // Spawn drones with position
13 for i in 0..50 {
14 swarm.spawn(DroneAgent::new(random_position())).await?;
15 }
16
17 // Drones automatically coordinate via local rules
18 swarm.start().await?;

Market Pattern

Market

Auction system with buyers, sellers, and price discovery.

1use agentropic_patterns::market::*;
2
3 let market = Market::new(AuctionRules::english());
4
5 // Register participants
6 market.register_seller(SellerAgent::new("Alice", item)).await?;
7 market.register_buyer(BuyerAgent::new("Bob", budget: 1000)).await?;
8 market.register_buyer(BuyerAgent::new("Charlie", budget: 1500)).await?;
9
10 // Run the auction
11 let result = market.run_auction(Duration::from_secs(60)).await?;
12 println!("Winner: {} at price {}", result.winner, result.price);

Coalition Pattern

Coalition

Dynamic team formation based on capabilities and goals.

1use agentropic_patterns::coalition::*;
2
3 // Agents with different capabilities
4 let agents = vec![
5 Agent::new("Alice").with_skills(["rust", "ml"]),
6 Agent::new("Bob").with_skills(["python", "data"]),
7 Agent::new("Charlie").with_skills(["devops", "k8s"]),
8 ];
9
10 // Form coalition for a task
11 let task = Task::new("Deploy ML Model")
12 .requires(["ml", "devops"]);
13
14 let coalition = CoalitionFormation::greedy()
15 .form(&agents, &task).await?;
16
17 println!("Coalition: {:?}", coalition.members());

Blackboard Pattern

Blackboard

Shared knowledge space for collaborative problem solving.

1use agentropic_patterns::blackboard::*;
2
3 let blackboard = Blackboard::new();
4
5 // Specialist agents contribute knowledge
6 let hypothesis_agent = HypothesisAgent::new();
7 let analyzer_agent = AnalyzerAgent::new();
8 let validator_agent = ValidatorAgent::new();
9
10 // Agents react to blackboard changes
11 blackboard.on_change(|entry| {
12 match entry.level {
13 Level::Raw => hypothesis_agent.process(entry),
14 Level::Hypothesis => analyzer_agent.analyze(entry),
15 Level::Analysis => validator_agent.validate(entry),
16 }
17 });
18
19 blackboard.post(RawData::new(sensor_reading)).await?;