# Building Multi-Agent Systems with NetLogo in the AI-For-Beginners Curriculum

> Learn to build multi-agent systems with NetLogo in the AI-For-Beginners curriculum. Program autonomous agents to simulate complex phenomena like disease spread.

- Repository: [Microsoft/AI-For-Beginners](https://github.com/microsoft/AI-For-Beginners)
- Tags: tutorial
- Published: 2026-08-05

---

**The Microsoft AI-For-Beginners curriculum teaches multi-agent modeling through NetLogo, a visual environment where learners program autonomous "turtle" agents to simulate complex phenomena like disease spread and predator-prey dynamics.**

The AI-For-Beginners repository introduces agent-based modeling as a foundational AI concept, using NetLogo to provide an intuitive, graphical entry point before diving into deep learning frameworks. This lesson bridges the gap between theoretical multi-agent systems and practical implementation, requiring no advanced programming background while demonstrating how individual agent behaviors generate emergent collective patterns.

## What Is NetLogo and Why Use It for Multi-Agent Systems?

NetLogo is a multi-agent programming environment built on a modified version of the Logo programming language. It enables users to control hundreds or thousands of independent agents simultaneously, making abstract concepts like emergence, self-organization, and stochastic behavior tangible and visible. According to the source in [`lessons/6-Other/23-MultiagentSystems/README.md`](https://github.com/microsoft/AI-For-Beginners/blob/main/lessons/6-Other/23-MultiagentSystems/README.md), the curriculum leverages this visual approach to teach system dynamics that later inform understanding of multi-agent reinforcement learning and distributed AI systems.

## Core NetLogo Concepts Covered in the Curriculum

### The Agent Paradigm: Turtles and Patches

In NetLogo, agents are called **turtles**—autonomous entities that can move across a grid of **patches** (stationary grid cells). As implemented in the Microsoft curriculum, these turtles form the atomic units of any simulation, possessing properties like position, heading, color, and size that learners manipulate through simple commands.

### Essential Command Primitives

The lesson introduces fundamental building blocks that control agent behavior:

- `create-turtles <number>` – Spawns the specified number of agents
- `forward` (or `fd`) – Moves turtles in their current heading
- `rt` / `lt` – Rotate turtles right or left
- `setxy` – Positions turtles at specific coordinates
- `tick` – Advances the simulation clock

## Exploring the Models Library

The curriculum directs learners to NetLogo's built-in **Models Library**, a collection of pre-built simulations including *Wolf-Sheep Predation* and *Virus* models. As documented in [`lessons/6-Other/23-MultiagentSystems/README.md`](https://github.com/microsoft/AI-For-Beginners/blob/main/lessons/6-Other/23-MultiagentSystems/README.md), these serve as starting points for understanding complex systems before students modify them for custom scenarios.

## Hands-On Implementation: Your First Multi-Agent Simulation

The following example from the repository demonstrates a basic flocking behavior where 50 turtles move stochastically across the environment:

```netlogo
;; Simple NetLogo example: a flock of turtles moving forward
to setup
  clear-all
  create-turtles 50 [
    set color blue
    set shape "turtle"
    set size 1.5
    setxy random-xcor random-ycor
  ]
end

to go
  ask turtles [
    fd 10                ;; move forward 10 patches
    rt random 360       ;; turn a random amount
  ]
  tick
end

```

**Code Breakdown:**

- `create-turtles 50` initializes the agent population with individual property assignments using the bracket block syntax
- `fd 10` advances each turtle 10 patch units forward based on its current heading
- `rt random 360` applies a stochastic rotation between 0 and 359 degrees, creating emergent random walk patterns
- `ask turtles [...]` broadcasts commands to the entire agent collective

## The Practical Assignment: Real-World Application

The assignment documented in [`lessons/6-Other/23-MultiagentSystems/assignment.md`](https://github.com/microsoft/AI-For-Beginners/blob/main/lessons/6-Other/23-MultiagentSystems/assignment.md) tasks learners with selecting a model from the NetLogo Models Library and adapting it to represent a contemporary scenario. Common adaptations include modifying the *Virus* model parameters to simulate **COVID-19 transmission dynamics** or adjusting predator-prey ratios to reflect specific ecological systems. Students must submit their modified `.nlogo` code files with documentation explaining their parameter choices and observed emergent behaviors.

## Curriculum Integration and Prerequisites

While the broader AI-For-Beginners curriculum focuses on Python, TensorFlow, and PyTorch for neural network implementation, this NetLogo module—located in `lessons/6-Other/23-MultiagentSystems/`—requires only the NetLogo application (available as a separate download, not included in the [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) Conda configuration). This intentional separation allows beginners to grasp agent-based theory graphically before implementing similar concepts mathematically in Python-based reinforcement learning modules.

## Summary

- The AI-For-Beginners curriculum uses **NetLogo** to teach **building multi-agent systems** through visual, turtle-based simulations
- Core files include [`lessons/6-Other/23-MultiagentSystems/README.md`](https://github.com/microsoft/AI-For-Beginners/blob/main/lessons/6-Other/23-MultiagentSystems/README.md) for instruction and [`assignment.md`](https://github.com/microsoft/AI-For-Beginners/blob/main/assignment.md) for the practical exercise
- Key primitives include `create-turtles`, `fd`, and `ask` for controlling agent collectives
- The **Models Library** provides pre-built simulations like *Virus* and *Wolf-Sheep Predation* for customization
- This module serves as a conceptual bridge to Python-based multi-agent reinforcement learning

## Frequently Asked Questions

### Do I need to know Python to use NetLogo in this curriculum?

No. NetLogo uses its own syntax based on the Logo programming language. The [`lessons/6-Other/23-MultiagentSystems/README.md`](https://github.com/microsoft/AI-For-Beginners/blob/main/lessons/6-Other/23-MultiagentSystems/README.md) file explicitly states that no Python knowledge is required for this specific lesson, though the skills learned here complement later Python-based AI implementations.

### Where can I download NetLogo for this assignment?

The curriculum instructions in [`lessons/6-Other/23-MultiagentSystems/README.md`](https://github.com/microsoft/AI-For-Beginners/blob/main/lessons/6-Other/23-MultiagentSystems/README.md) direct learners to the official NetLogo website for download. Note that NetLogo is not included in the repository's [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) Conda environment, as it runs as a standalone Java application.

### What types of models can I create with the assignment?

According to [`lessons/6-Other/23-MultiagentSystems/assignment.md`](https://github.com/microsoft/AI-For-Beginners/blob/main/lessons/6-Other/23-MultiagentSystems/assignment.md), learners typically adapt existing Models Library simulations—such as the *Virus* model for disease spread or *Wolf-Sheep Predation* for ecological dynamics—to represent real-world scenarios like pandemic transmission or resource competition.

### How does this NetLogo lesson relate to modern AI and machine learning?

While NetLogo provides a visual introduction to agent behaviors, it establishes foundational concepts—emergence, stochastic processes, and collective intelligence—that underpin modern **multi-agent reinforcement learning** systems implemented later in the curriculum using TensorFlow and PyTorch.