Generative Art through Agent Based Simulation

M Barake
4 min readFeb 20, 2021

--

Agent-based simulation

Agent-based modelling is a powerful simulation and modelling technique that has experienced a number of applications in recent years, including applications in real-world business problems. The global behavior of a system is the result of local relationships between actors and their local environment. Agents based modelling and simulation is a system of autonomous agents that are relatively simple and follow relatively simple rules of interaction but nonetheless might lead to complex behavior. In this article, we are going to show how can this type of simulation be used to generate art.

Generative Art

Generative art refers to art that is created wholly or partially through the use of autonomous systems. Autonomous systems can be computers, but in a broader sense they are non-human and can independently determine works of art that would otherwise require decisions directly from the artist. The following images are generated via human — computer interaction with the aid of the beauty of symmetry.

Tarantula
Lion

NetLogo

NetLogo is an agent-based modelling environment that is easy to use yet have everything necessary to model complex systems. A full tutorial about using NetLogo can be found here.

https://ccl.northwestern.edu/netlogo/docs/tutorial1.html

In NetLogo there is 4 different types of agents:

  • Turtle (Turtles are agents that move around in the world)
  • Patches (Each patch is a square piece of “ground” over which turtles can move and have coordinates)
  • Link (Links are agents that connect two turtles)
  • Observer (Give instruction to other agents)

The world is two dimensional and is divided up into a grid of patches.

NetLogo Model

We are going to have n turtles. Each turtle will be linked to one or zero other turtles. A link means that one turtle is going to follow another turtle at each simulated step. A turtle will leave a trail behind. The trail could be any geometric shape, color, particles or an image. The simulation finishes when all or some turtles converge to a single point. When the simulation finishes, the trails left by the turtles will form an image. An infinite number of images can be generated by putting the turtles in different positions in the world and by linking them differently.

Code

to setup
clear-all
make-turtles
reset-ticks
end
to go ask turtles [ let target one-of out-link-neighbors
if target != nobody [
face target
set pcolor color
let dist distance target
if dist > 1 [fd 1]
]
]
tick
endto make-turtles design1endto design1 create-turtles 4 [ set size 2 ]
layout-circle turtles max-pxcor - 1
ask turtle 0 [ set color green create-link-to turtle 1 ]
ask turtle 1 [ set color yellow create-link-to turtle 2]
ask turtle 2 [ set color orange create-link-to turtle 3]
ask turtle 3 [ set color blue create-link-to turtle 0]
endto design2 create-turtles 200 [ set size 4 ]
layout-circle turtles max-pxcor - 1
ask n-of 40 turtles [
create-link-to one-of other turtles [
set color red
]
]
end

Code explained

The turtles are first created according to a certain design. The first design creates 4 turtles using a circle layout and then ask each turtle to link to another one. The go function let each turtle move one step in the direction of its neighbor according to the previous links created. The turtle will color its patch (the ground underneath) on each move. The second design creates 200 turtles and than choose at random 40 at then let each one follow another one at random.

Art produced from first design

Art produced from second design

Creating better visuals using C

Using another programming languages, similar code can be used to produce the following piece of arts.

--

--

M Barake
M Barake

Written by M Barake

An algorithm designer and developer with a passion of building AI solutions to diverse problems. 2D game designer and developer and an avid lover of nature.

No responses yet