Class SwarmBuilder
java.lang.Object
com.tnsai.coordination.groups.swarm.SwarmBuilder
Builder for creating Swarm instances.
Usage Example
Swarm swarm = Swarm.builder()
.name("Explorer Swarm")
.behavior(SwarmBehavior.EXPLORATION)
.intelligence(SwarmIntelligence.antColony(0.5, 0.3))
.neighborDetection(NeighborDetection.random())
.neighborRadius(5)
.pheromoneDecay(0.15)
.add(agent1, agent2, agent3)
.build();
-
Method Summary
Modifier and TypeMethodDescriptionadd(com.tnsai.agents.Agent agent) Adds a member to the swarm.add(com.tnsai.agents.Agent... agents) Adds multiple members to the swarm.Adds multiple members to the swarm.autoStart(boolean autoStart) Sets whether to auto-start after build.behavior(SwarmBehavior behavior) Sets the swarm behavior.build()Builds the Swarm.description(String description) Sets the swarm description.Sets the swarm ID.intelligence(SwarmIntelligence intelligence) Sets the swarm intelligence algorithm.Sets the swarm name.neighborDetection(NeighborDetection detection) Sets the neighbor detection strategy.neighborRadius(int radius) Sets the neighbor radius.pheromoneDecay(double decay) Sets the pheromone decay rate.policy(com.tnsai.agents.groups.GroupPolicy policy) Sets the group policy.
-
Method Details
-
id
Sets the swarm ID.- Parameters:
id- swarm ID- Returns:
- this builder
-
name
Sets the swarm name.- Parameters:
name- swarm name- Returns:
- this builder
-
description
Sets the swarm description.- Parameters:
description- swarm description- Returns:
- this builder
-
behavior
Sets the swarm behavior.- Parameters:
behavior- behavior type- Returns:
- this builder
-
intelligence
Sets the swarm intelligence algorithm.- Parameters:
intelligence- intelligence strategy- Returns:
- this builder
-
neighborDetection
Sets the neighbor detection strategy.- Parameters:
detection- detection strategy- Returns:
- this builder
-
neighborRadius
Sets the neighbor radius.- Parameters:
radius- detection radius- Returns:
- this builder
-
pheromoneDecay
Sets the pheromone decay rate.- Parameters:
decay- decay rate (0.0 to 1.0)- Returns:
- this builder
-
policy
Sets the group policy.- Parameters:
policy- policy- Returns:
- this builder
-
add
Adds a member to the swarm.- Parameters:
agent- agent to add- Returns:
- this builder
-
add
Adds multiple members to the swarm.- Parameters:
agents- agents to add- Returns:
- this builder
-
addAll
Adds multiple members to the swarm.- Parameters:
agents- agents to add- Returns:
- this builder
-
autoStart
Sets whether to auto-start after build.- Parameters:
autoStart- auto-start flag- Returns:
- this builder
-
build
Builds the Swarm.- Returns:
- new Swarm instance
-