Source-linked AI summary
Multi-Agent Systems Powered by Large Language Models: Applications in Swarm Intelligence
Cristian Jimenez-Romero, Alper Yegenoglu, Christian Blum
TL;DR
This paper explores whether LLMs can help model emergent behavior in multi-agent simulations. It applies structured prompts to ant foraging and knowledge-driven prompts to bird flocking, finding that LLM-driven agents can support swarm-like behavior and perform comparably to rule-based agents, with some differences in local-cue interpretation.
Problem
The study asks whether LLM decision-making and pattern-generation capabilities can help model emergent behavior in agent-based simulations.
Source: §1.1 · p. 2Method
The paper uses structured rule-based prompts for ant foraging and principle-based, knowledge-driven prompts for bird flocking in multi-agent simulations.
Source: §6 · p. 21Results
LLM-driven agents supported ant foraging and bird alignment and performed comparably to rule-based counterparts, though they sometimes interpreted and prioritized local cues differently.
Source: §6 · p. 21Takeaways & Limitations
LLMs can serve as an alternative or complement to traditional rule-based logic for effective swarm-like dynamics in ant-foraging and bird-flocking simulations.
Source: §7 · p. 22Remote LLM interactions at each simulation iteration require significantly more computation time than simple NetLogo rules, and GPT-4o API use incurs token-based costs.
Source: §6 · p. 22
Abstract
from arXiv · showhide
This work examines the integration of large language models (LLMs) into multi-agent simulations by replacing the hard-coded programs of agents with LLM-driven prompts. The proposed approach is showcased in the context of two examples of complex systems from the field of swarm intelligence: ant colony foraging and bird flocking. Central to this study is a toolchain that integrates LLMs with the NetLogo simulation platform, leveraging its Python extension to enable communication with GPT-4o via the OpenAI API. This toolchain facilitates prompt-driven behavior generation, allowing agents to respond adaptively to environmental data. For both example applications mentioned above, we employ both structured, rule-based prompts and autonomous, knowledge-driven prompts. Our work demonstrates how this toolchain enables LLMs to study self-organizing processes and induce emergent behaviors within multi-agent environments, paving the way for new approaches to exploring intelligent systems and modeling swarm intelligence inspired by natural phenomena. We provide the code, including simulation files and data at https://github.com/crjimene/swarm_gpt.
1 Introduction
The paper explores how LLMs can guide agents in agent-based simulations to model emergent behavior, using structured prompts for ant foraging and principle-based prompts for bird flocking. It presents a NetLogo toolchain and situates these approaches among broader work on LLMs and complex systems.
1.1 From Rule-Based to LLM-Driven Agents: A New Paradigm in ABMS
- In ABMS, agents make localized decisions and interact with their environment, while multi-agent systems can exhibit global behavior emerging from those interactions.The paper extends these concepts by allowing agents to be LLM-steered, rule-based, or a mixture of both.Source: §1.1 · pp. 1–2
1.2 Motivation
- The study asks whether LLM decision-making and pattern-generation capabilities can help model emergent behavior in agent-based simulations.It presents a NetLogo toolchain and contrasts detailed structured prompts for ant foraging with less structured, principle-based prompts for bird flocking.Source: §1.1 · p. 2, §1.2 · p. 2
1.3 Research Objectives
- The research objectives include assessing prompt approaches in ant foraging and bird flocking and presenting a toolchain for modeling swarm behavior.The bird-flocking objective identifies the model as inspired by Reynolds’ “Boids”.Source: §1.3 · pp. 2–3
1.4 Background and Related Work
- Related work spans LLM-driven agents in social simulations, robotics, and UAV control, while this study focuses on prompt specificity in emergent multi-agent behavior.The paper frames its two methodologies as structured rule-based prompts and generalized prompts that draw on broader model knowledge.Source: §1.4 · pp. 3–4
2 Methods
The study examines structured rule-based and knowledge-driven prompts in two social-insect-inspired simulations. Its NetLogo toolchain sends environmental context to GPT-4o and converts the model’s responses into agent actions that feed back into the simulation.
2 Methods
- The experiments use structured rule-based prompts in one scenario and principle-based, knowledge-driven prompts in another, with the LLM generating actions from environmental inputs.Structured prompts specify conditions and responses; knowledge-driven prompts use broader concepts such as alignment, cohesion, and separation.Source: §2 · p. 4
2.1 Toolchain for LLM-Driven Multi-Agent Simulations with NetLogo
- NetLogo encodes real-time environmental states into prompts and uses its Python extension to communicate with GPT-4o through the OpenAI API.The LLM returns structured output that is decoded into executable NetLogo actions; those actions update the environment for the next iteration.Source: §2.1 · p. 5
- GPT-4o interprets the encoded context to suggest actions aligned with either explicit rules or general behavioral principles.The toolchain’s stated workflow also includes translating the model output into NetLogo-compatible instructions before execution.Source: §2.1 · p. 5
3 Experiment 1: Ant Colony Foraging Simulation
The ant-foraging experiment uses stateless LLM-guided ants in a NetLogo environment with food sources, a nest, and pheromone and nest-scent cues. Initial trials found that general instructions did not produce organized foraging, motivating more explicit prompt rules.
3 Experiment 1: Ant Colony Foraging Simulation
- The simulation uses stateless ants in a two-dimensional foraging area, where they find food and return it to a central nest using environmental cues.GPT-4o receives real-time inputs through structured prompts; temperature is set to 0.0, though responses may still occasionally deviate from specified rules.Source: §3 · p. 5
3.1.1 Prompt Design
- The zero-shot prompt gives ants explicit rules for following pheromone trails, picking up food, and releasing pheromones, with each interaction independent of prior conversation context.The final prompt was refined through trial and error to clarify the environment and expected actions.Source: §3.1.1 · p. 6
3.1.2 Tuning Process
- The tuning process began with a general task description to test whether ants could forage without detailed guidance, then used iterative prompt refinement to address ambiguities.The language model’s feedback helped identify misunderstandings in the prompts.Source: §3.1.2 · p. 6
Iteration 1
- In the initial trial, ants inconsistently followed pheromone and nest-scent gradients, sometimes released pheromones unexpectedly, and moved randomly rather than foraging in an organized way.The prompt lacked guidance for interpreting and prioritizing environmental cues, indicating a need for clearer action rules.Source: Iteration 1 · p. 7
Iteration 2
Adding a priority for nest scent when carrying food did not resolve conflicting cue responses or weak exploration. Explicitly stating agent status improved food-handling actions, but navigation and exploration remained inconsistent.
Iteration 2
- Prioritizing nest scent for ants carrying food did not eliminate gradient-following inconsistencies or conflicting responses when cues had similar strengths.Ants without food or sensed pheromones still tended to remain near the nest rather than explore effectively.Source: Iteration 2 · p. 8
Iteration 3
- Even with state information supplied, ants continued to explore poorly when not carrying food and inconsistently follow pheromone trails or nest scent.The authors identify clearer cue-response and movement guidance as remaining needs.Source: Iteration 3 · p. 8
- Explicitly stating whether ants were at the nest or carrying food improved execution of actions such as picking up and dropping food.The prompt change addressed possible lack of awareness of current state, but did not resolve navigation inconsistencies.Source: Iteration 3 · p. 8
Iteration 4
Across Iterations 4–6, prompt changes improved cue-guided navigation and pheromone trails, but ants continued to explore inefficiently when scent cues were absent. Directional environmental descriptions improved gradient following, while pheromone deposition strengthened trails used by other ants.
Iteration 4
- Directing ants without food toward the highest pheromone concentration improved food finding, but gradient-following inconsistencies and weak exploration without cues persisted.The analysis distinguishes ants’ carrying and non-carrying states as improving foraging when environmental cues were available.Source: Iteration 4 · pp. 8–9
Iteration 5
- Presenting pheromone and nest-scent gradients as directions rather than quantities improved consistent cue following, while exploration without scents remained limited.Ants often stayed near the nest when no sensory cues were present.Source: Iteration 5 · p. 9
Iteration 6
- Instructing ants to release pheromones while carrying food strengthened trails and helped other ants locate food, but scent-free exploration remained limited.The analysis links pheromone deposition during food transport and improved gradient following with greater colony cooperation and foraging success.Source: Iteration 6 · pp. 9–10
Iteration 7
Iteration 7 clarified when ants should use nest scent, reducing unnecessary returns while leaving cue-free exploration unresolved. Iteration 8 added proactive movement in scent-free conditions, improving exploration, though rotation bias remained.
Iteration 7
- Restricting nest-scent navigation to ants carrying food prevented unnecessary returns and improved foraging efficiency, although exploration without cues remained limited.Previously, some ants prioritized nest scent even when not carrying food.Source: Iteration 7 · p. 10
Iteration 8
- Directing ants without food or pheromone cues to move away from the nest and rotate randomly improved exploration and food discovery, but rotation bias remained.Ants ventured farther from the nest and discovered food in fewer simulation steps; a noticeable rotation bias persisted, particularly near the nest.Source: Iteration 8 · p. 10
Iteration 9
Iteration 9 expanded ants’ rotation choices to include random movement, producing more varied exploration. The prompt-deployment process supplies environmental information to the LLM and turns its response into actionable simulation commands.
Iteration 9
- Adding “random” as a rotation option produced more varied exploration, with ants moving farther from the nest and searching wider areas for food.When selected by the LLM, “random” delegates the direction choice to NetLogo, which randomly chooses left or right.Source: Iteration 9 · pp. 10–11
3.1.3 Prompt Deployment
- At each simulation step, NetLogo provides current environmental information, and the LLM returns a Python dictionary of agent actions.The example prompt specifies movement, rotation, food pickup, pheromone release, and food dropping; the prompt exchange uses the OpenAI API’s chat.completions mechanism.Source: §3.1.3 · p. 11
- The deployment prompt includes nest presence, nest-scent direction, pheromone availability, local food concentration, and carrying status.The example response includes action fields for picking up food and dropping pheromones.Source: §3.1.3 · p. 11
3.2 System Monitoring
System monitoring assesses ant navigation and foraging through food-return timing, trail use, and nest-scent navigation when carrying food.
3.2 System Monitoring
- Monitoring measures the time ants take to find food and return it to the nest.These timings track food-finding and food-return performance.Source: §3.2 · p. 12
- Monitoring tracks how consistently ants use pheromone trails to navigate.Source: §3.2 · p. 12
- Monitoring measures the accuracy of nest-scent following when ants are carrying food.Source: §3.2 · p. 12
4 Experiment 2: Bird Flocking Simulation
The bird-flocking experiment used LLMs prompted with flocking principles to choose headings from nearby birds’ positions and headings. Iterative prompt changes culminated in larger, more stable flocks comparable to NetLogo’s rule-based model, though earlier iterations showed formatting and heading-calculation problems.
4.1.1 Prompt Design
- Bird agents used zero-shot prompts to apply separation, alignment, and cohesion to nearby flockmates’ positions and headings.The LLM interpreted environmental data to adjust headings, maintain distance, and keep the group cohesive.Source: §4.1.1 · p. 12, §4 · p. 12
4.1.2 Tuning Process
- NetLogo’s compass convention was essential for consistent heading calculations: 0° points north, 90° east, 180° south, and 270° west.The model runs in two-dimensional airspace and implements the Boids model.Source: §4.1.2 · p. 12, §4 · p. 12
Iteration 1
- Initial prompts often produced unparsable responses, and even parsed headings were inconsistent, preventing flocking from emerging.Restricting responses to JSON improved reliability, but flocking remained inconsistent and alignment and coherence were weak.Source: Iteration 1 · p. 13, Iteration 2 · p. 13
Iteration 3
- After the compass convention was specified, larger clusters formed, but some birds still moved randomly; requested reasoning produced correct headings where numerical-only answers had errors.The authors identified a structured reasoning process as necessary for accurate heading calculations.Source: Iteration 3 · p. 14
Iteration 4
- Adding a rationale key improved heading consistency and flocking, but counterclockwise turns still sometimes went in the wrong direction.The authors added shortest-rotation guidance to address these errors.Source: Iteration 4 · p. 14, Iteration 5 · p. 14
Iteration 5
- The shortest-path directive produced larger, more stable flocks with performance comparable to the original rule-based NetLogo model.The change also improved alignment between LLM-based and rule-based agents and led to more coherent flocking.Source: Iteration 5 · p. 14
4.1.3 Prompt Deployment
- At each step, NetLogo supplied current environmental data to the LLM, which returned the agent’s action in JSON.The system prompt defined task rules, while the user prompt provided real-time data.Source: §4.1.3 · p. 15
4.2 Monitoring Behavior
- Behavior monitoring focused on inter-agent separation, alignment with nearby birds’ average heading, and cohesion toward the flock’s center of mass.The text identifies these as metrics for observing behavior and performance.Source: §4.2 · p. 16
5 Results
The ant and bird simulations compare LLM-guided agents with rule-based agents, including mixed populations. Ant results favor the Hybrid model in total food collected, while flocking results describe differences in heading, spacing, collisions, and neighbors.
5.1 Experiment 1: Ant Foraging with Structured Rule-Based Prompting
- The ant comparison used 10 ants, three food patches, 1,000 simulation steps, and five runs per model, measuring total food gathered.The tested variants were the original NetLogo model, all-LLM ants, and a half-rule-based, half-LLM Hybrid.Source: §5.1 · p. 16
5.1.1 Food collection behavior
- Hybrid collected approximately 95 food units (standard deviation 12), versus approximately 85 units for both NetLogo and LLM by 1,000 steps.Hybrid began returning food at around 20 simulation steps, compared with about 40 for NetLogo and LLM.Source: Figure 3 · p. 16, §5.1.1 · p. 16
- NetLogo ants generally returned food in fewer steps than LLM-guided ants, while LLM ants showed consistent behavior for food patches 1 and 2.Patch 1 is closest to the nest and patch 3 farthest away.Source: Figure 4 · p. 17, §5.1.1 · p. 17
- Hybrid ants consistently found food patches 1 and 2, whereas LLM and NetLogo searches varied; one NetLogo ant took 720 steps at patch 2.Patch 1 searches also included more outliers, attributed to initial exploration before finding food.Source: §5.1.1 · p. 17, Figure 5 · p. 18
5.2 Experiment 2: Bird Flocking Simulation with Knowledge-driven Prompts
- The flocking comparison used 30 birds for 800 steps across five runs, with Hybrid replacing five rule-based birds with LLM-guided birds.Effectiveness was assessed using distances and angular disparities between birds.Source: §5.2 · pp. 17–18
5.2.1 Flocking behavior
- Hybrid’s rule-based and LLM-guided birds showed similar heading-difference evolution, while original NetLogo birds had somewhat lower differences.The authors anticipated convergence between variants in longer runs.Source: §5.2.1 · p. 18, Figure 7 · p. 19
- LLM-guided birds tended to stay at flock peripheries, farther from the center, and avoided collisions more than rule-based birds.The authors hypothesized that this conservative behavior may perturb flocking dynamics; they also offered a possible distance-representation interpretation.Source: §5.2.1 · pp. 19–20
- Rule-based birds had the most neighbors and LLM-guided birds the fewest, with neighbors defined by distance 1 < d ≤ 5 and heading difference h ≤ 15.Collisions were excluded from the neighbor count.Source: §5.2.1 · pp. 20–21, Figure 10 · p. 21
6 Discussion
Across ant foraging and bird flocking, LLM-guided agents produced swarm-like behavior comparable to rule-based agents, while differing in how they interpreted local cues. Outcomes depended on iterative prompt refinement, and the approach carries computational-time and API-cost drawbacks.
- LLM-driven agents performed comparably to fully rule-based counterparts across ant foraging and bird flocking, but sometimes interpreted and prioritized local cues differently.Source: §6 · p. 21
- Iterative prompt tuning brought LLM-guided ants close to the standard NetLogo model by clarifying exploration when signals were absent and nest-scent priority while carrying food.Source: §6 · p. 21
- Hybrid ant colonies often outperformed both uniform groups, though longer simulations were recommended to clarify the mechanisms behind this apparent advantage.Source: §6 · p. 21
- After prompt refinements, bird flocks became more cohesive, while LLM-driven birds stayed slightly farther from the flock center and had fewer collisions than rule-based birds.Source: §6 · pp. 21–22
- Stateless LLM decisions worked in both scenarios but required complete context at each step; missing details such as pheromone intensity or heading conventions could produce ambiguous or incorrect actions.Source: §6 · p. 22
- Small prompt changes, including rotation angles or handling conflicting signals, could significantly alter emergent group-level patterns.Source: §6 · p. 22
- Remote LLM calls at every simulation iteration take significantly more computation time than simple NetLogo rules, and GPT-4o API use incurs token-based costs.The authors suggest a smaller locally hosted model after training and fine-tuning as a possible way to reduce these costs.Source: §6 · p. 22
7 Conclusion
Across two classic multi-agent models, LLMs served as alternatives or complements to rule-based logic for producing swarm-like dynamics. Ant foraging and bird flocking results depended on carefully tuned prompts, with hybrid ant colonies outperforming uniform groups and LLM-guided birds forming coherent flocks.
- Applying LLMs to ant foraging and bird flocking showed they can serve as alternatives or complements to rule-based logic in achieving effective swarm-like dynamics.Source: §7 · p. 22
- Hybrid ant colonies combining LLM-guided and rule-based ants outperformed uniform groups, while LLM-guided ants gathered food at rates comparable to the standard NetLogo model when instructions were carefully designed.Source: §7 · p. 22
- LLM-driven birds followed separation, alignment, and cohesion principles to form cohesive flocks, although heading convergence sometimes lagged rule-based simulations and birds occupied slightly more peripheral positions.Source: §7 · p. 22
- The experiments emphasize iterative prompt tuning; future work could explore partial memory or reinforcement signals to move beyond stateless approaches.Source: §7 · p. 22
Disclaimer
The article reflects only the author’s view; the EU Research Executive Agency is not responsible for uses of the information.
- The article reflects only the author’s view, and the EU Research Executive Agency accepts no responsibility for any use of its information.Source: Disclaimer · p. 22