0% found this document useful (0 votes)
27 views8 pages

Simultech 2021 4 CR

PyLogo is a Python reimplementation of the popular agent-based modeling platform NetLogo. The developers created PyLogo because while NetLogo is widely used, its programming language makes developing complex models unnecessarily difficult. PyLogo allows models to be written in Python, which is a more straightforward programming language. The paper discusses issues with the NetLogo language and provides a simple example model written in PyLogo.

Uploaded by

Emmanuel Dahito
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views8 pages

Simultech 2021 4 CR

PyLogo is a Python reimplementation of the popular agent-based modeling platform NetLogo. The developers created PyLogo because while NetLogo is widely used, its programming language makes developing complex models unnecessarily difficult. PyLogo allows models to be written in Python, which is a more straightforward programming language. The paper discusses issues with the NetLogo language and provides a simple example model written in PyLogo.

Uploaded by

Emmanuel Dahito
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

PyLogo: A Python Reimplementation of (Much of) NetLogo

Russ Abbott and Jung Soo Lim


Department of Computer Science, California State University, Los Angeles,
5151 State University Drive, Los Angeles, California, U.S.A.
{rabbott, jlim34}@exchange.calstatela.edu

Keywords: ABM, Agent-Based Modeling, NetLogo, PyLogo, Python, Simulation.

Abstract: In the world of Agent-Based Modeling (ABM), NetLogo reigns as the most widely used platform. The NetL-
ogo world of agents interacting in a two-dimensional space seems to provide just the right level of simplicity
and abstraction for a wide range of models. Regrettably, the NetLogo language makes model development
more painful than necessary.
This combination—widespread popularity accompanied by unnecessary coding pain—motivated the develop-
ment of PyLogo, a NetLogo-like modeling and simulation environment in which developers write their models
in Python. Although other NetLogo-like systems exist, as far as we know PyLogo is the only NetLogo-like
system in Python at this level of completeness. This paper examines a number of issues with the NetLogo
language and offers a simple, illustrative PyLogo example model.
PyLogo is open source and is available at this GitHub repository. We welcome collaborators.

1 INTRODUCTION 2 RELATED WORK


For a senior-level modeling and simulation class we There are, of course, many modeling and simulation
developed a pure-Python version of NetLogo. systems, both agent-based and non-agent-based. The
following discusses only agent-based systems.
Why NetLogo?
First the classics. Repast (North et al., 2013) and
• Due to its widespread adoption, NetLogo has be- then MASON (Luke et al., 2005) established agent-
come the standard platform for communicating based modeling as a distinct discipline. They re-
and implementing ABMs (Thiele, 2014). main among the most widely-used ABM systems, es-
• NetLogo is recognized as robust and powerful but pecially for complex models or models with many
nevertheless easy to learn (Badham, 2015). agents. These were followed by AnyLogic (Grigoryev,
2015). All use Java for model development.
Why Python? More recent agent-based systems include:
• The NetLogo language makes the development of • ABCE (Taghawi-Nejad et al., 2017), a Python-
non-trivial models unnecessarily painful. based platform tailored for economic phenomena;
• Python is one of the most straightforward pro- • Agents.jl (Vahdati, 2019), a Julia-based relative
gramming languages. It is often used to intro- newcomer; and
duce students to programming and yet has become
the de facto scripting language for many areas of • GAMA (Taillandier et al., 2019), which describes
computer science (Nagpal and Gabrani, 2019). itself as an environment for spatially explicit
agent-based simulations. GAMA models are
Our Objectives for This Paper. written in GAML, a scripting-like language.

• To document some of NetLogo’s awkward fea- NetLogo (Tisue and Wilensky, 2004a; Tisue and
tures. (Section 3). Wilensky, 2004b) teased the possibility of writing
models in pseudo-English.
• To discuss a small PyLogo model. (Section 4).
It stands apart as the best platform for both begin-
ners and serious scientific modelers. Many if not
most public scientific ABMs are implemented in
NetLogo, which has become a standard platform Tisue and Wilensky continue:
for agent-based simulation (Railsback et al., 2017).
Logo is best known for its “turtle graphics,” in
NetLogo’s popularity triggered work in multiple which a virtual being or “turtle” moves around the
directions. For example, mechanisms exist for inter- screen drawing figures by leaving a trail behind it-
acting with NetLogo from other languages. self. NetLogo generalizes Logo’s single turtle to
support hundreds or thousands of turtles all mov-
• NetLogo Mathematica allows Mathematica to ing around and interacting.
control NetLogo. (Bakshy and Wilensky, 2007). Different “breeds” of turtle may be defined, and
• NL4Py (Gunaratne and Garibay, 2018) and Pynet- different variables and behaviors can be associated
logo (Jaxa-Rozen and Kwakkel, 2018) offer ac- with each breed. In effect, NetLogo adds a primi-
cess to and control over NetLogo from Python. A tive object-oriented overlay to Logo.
NetLogo extension allows calls to Python. Turtles inhabit a grid of programmable “patches.”
Collectively, the turtles and patches are called
• RNetLogo (Thiele, 2014) enables one to write R “agents.” Agents can interact with each other.
code that calls NetLogo. A NetLogo extension A collection of agents—e.g., the set of all turtles or
allows one to call R from NetLogo. the set of all patches—is known as an agentset. One
Finally, a number of NetLogo-like systems allow can make custom agentsets on the fly: for example
model developers to write in a language other than the the set of all red turtles or the set of patches with
a given X coordinate. One can ask all agents in an
standard NetLogo script. agentset, to perform a series of operations.
• ReLogo (Ozik et al., 2013), an offspring of Repast,
allows users to write models in Groovy, a script- NetLogo is specified in a clearly-written user
like version of Java. manual (Wilensky, 2019).
The remainder of this section discusses concerns
• Mesa (Masad and Kazil, 2015) comes closest to about the language.
PyLogo. Although Mesa less complete (no links),
Mesa models are written in Python. Mesa consists
of a “headless” modeling component along with a
3.2 Keywords
JavaScript visualization component.
NetLogo is somewhat ambiguous about keywords.
NetLogo Critiques. We found no earlier work The Programming Guide says,
critiquing NetLogo as a language. The only keywords are globals, breed, turtles-
own, patches-own, to, to-report, and end, plus
extensions and the experimental includes.
3 THE NetLogo LANGUAGE But tacking -own onto a breed name makes the
combination a keyword: if cats is a breed, cats-own
This section discusses the NetLogo language and functions like turtles-own.
some of the issues that motivated PyLogo. NetLogo has a number of such “keyword-
We wish to acknowledge (again) NetLogo’s ex- constructors.” For example, breeds of links are de-
traordinary success. Wilensky (Wilensky, 2020) re- clared using the “keywords” undirected-link-breed
ports that since January 2019 there have been at least and directed-link-breed.
700k unique visitors to the NetLogo website, 130k Furthermore,
NetLogo downloads, 7000 papers that use NetLogo, Built-in primitive names may not be shadowed or
and 600 courses that use NetLogo. Wilensky believes redefined, so they are effectively a kind of keyword.
these are significant under-estimates.
Although the NetLogo dictionary lists roughly
500 built-in names, this is less of a problem than one
3.1 A Brief History of NetLogo might imagine. Most built-in names are either con-
stants (like true) or function names (like sin).
Tisue and Wilensky (Tisue and Wilensky, 2004a),
More confusingly, control constructs such as if,
(Tisue and Wilensky, 2004b) discuss NetLogo.
ifelse, ifelse-value, and while appear as if they were
Logo, as originally developed by Seymour Papert keywords. According to the Programming Guide,
and Wally Feurzeig (Feurzeig and Papert, 1967), is
derived from Lisp but has a syntax that seems to Control structures such as if and while are special
non-programmers to be similar to English. forms. You can’t define your own special forms, so
you can’t define your own control structures.
Although Logo’s debt to Lisp is clear, see (Harvey,
1982), its commitment to being “English-like” led to Infix operators such as of and with, and identifiers
an imperative-style. such as self and myself also function like keywords.
It would appear that and, or, set, let, filter, map. 3.4.1 ask and foreach
and other functions are also defined via special forms.
It adds confusion to deny keyword status to identifiers Consider a world of five turtles and two lists, both or-
defined via special forms. dered by who-number: a list of their heading degrees,
Finally, breed is both a built-in own variable, and a list of distances to move. We want our turtles
which records—and can be set to change—an entity’s to turn by the indicated number of degrees and then
breed, and a keyword used to declare breeds. to move forward the indicated distance. This seems
tailor-made for foreach.
3.3 A Primitive Object-oriented But turtles is an agentset and foreach requires
Capability lists—and the problem requires that they be ordered.
Our solution will be to use sort-on [who] turtles
NetLogo offers a primitive form of object-oriented to convert the turtles agentset into an ordered list of
programming through its breed mechanism. If one turtles. Then, since we are requiring the turtles to per-
thinks of NetLogo’s turtle as similar to Python’s ob- form turtle methods, we will embed an ask in the fore-
ject, a breed is something like a subclass of turtle. ach anonymous procedure. Not very pretty code.
Both turtles and breeds may have the equivalent of ( f o r e a c h s o r t −on [ who ] t u r t l e s
instance variables—declared through the -own key- [ 30 40 120 50 270 ]
word constructor. [ 40 20 50 10 30 ]
But breeds differ in important ways from classes [ [ t deg d i s t ] −>
in most object-oriented languages. a s k t [ r t deg f d d i s t ] ] )

• one can’t declare a sub-breed of a breed;


A Python version is much simpler. (We assume
• breed methods are not marked as restricted to
that turtle(n) retrieves the turtle with who-number n,
breed instances;
that rt() and fd() are turtle methods, and that count()
• even though patches are agents, one can’t create a has been imported from itertools).)
breed of patches; and
f o r who , deg , d i s t i n
• when an entity’s breed variable is changed, say
z i p ( count () ,
from breed-1 to breed-2, it loses its breed-1 in- [ 30 , 40 , 120 , 50 , 270 ] ,
stance variables and gains those of breed-2. [ 40 , 20 , 50 , 10 , 30 ] ) :
t = t u r t l e ( who )
3.4 Sets and Lists t . r t ( deg )
t . fd ( d i s t )

Sets and lists are treated as unrelated data structures.


This raises a couple of issues. 3.4.2 with/filter, of/map, and List
• Why limit sets to agents? Just as one can have lists Comprehensions
of both agents and numbers, one should be able to
have sets of numbers as well as sets of agents. One of Python’s most powerful and intuitive con-
• More importantly, given a NetLogo function de- structs is the list comprehension. Wikipedia lists
fined for one, there is generally a similar but nearly three dozen languages that include it. Python
different function defined for the other—creating style guides, such as GitHub’s, generally recommend
confusing redundancy. The following pairs of them over map and filter. Yet NetLogo does not offer
functions operate on sets and lists respectively. list comprehensions.
It is possible, if somewhat ugly, to create a simple
– ask and foreach NetLogo equivalent using of and with. For example,
– with and filter assuming t.who retrieves turtle t’s who-number, one
can mimic Python’s
– of and map
In each case, the two functions provide very simi- [ t . who ∗ t . who f o r t i n t u r t l e s
lar functionality. Replacing each pair with a single i f t . who % 2 == 1 ]

function that operates on both sets and lists would


simplify the language and reduce the memory bur- with
den on users. This is straightforward in Python
[ who ∗ who ] o f t u r t l e s
since sets and lists are both types of collections.
w i t h [ who mod 2 = 1 ]
Following are some simple illustrative examples.
The Python list comprehension is well-known and Let’s consider 1 - 3 in order.
widely used. A general NetLogo list comprehension 1. This illustrates why we call the reporter associ-
would be welcome. ated with of an ask-reporter. That’s how self gets
some-turtle as its value.
3.5 Reporters
2. This illustrates how map is special. Although
NetLogo uses the term reporter in multiple—and of- its first argument plays the same role as the of
ten confusing—ways. reporter, the two reporters take different forms:
[next-turtle self] vs next-turtle.
• Primitive Reporters, such as turtle and list.
3. runresult is required because it is not permissi-
• User-defined Procedures created with to-report. ble to apply anonymous procedures to their argu-
• ask-reporters. Many NetLogo primitives—such ments in the same way that one applies standard
as all? max-n-of (and similar), of, sort-on, while, procedures to their arguments. That’s the case
and with (and similar)—provide ask-like contexts even if the anonymous procedure is given a name.
for reporters. By that we mean that these reporters
run in the same sort of context in which ask com- [ n −> n + n ] k
mand blocks run, i.e., as something like “meth-
ods” of the agents running them. In the example and
at the end of the previous section, the who in the
reporter [who * who] referred to the who-number to−r e p o r t t e s t −named−anon [ k ]
l e t d o u b l e [ n −> n + n ]
of the then-active turtle.
report double k
• Anonymous Reporters. These may or may not end
work as one would expect.
Consider the following example. (The parenthe- both generate the (unhelpful) error message:
ses are required for correct parsing.) Expected command. Also see Section 3.8.
turtle ( [ who ] o f a− t u r t l e + 1 )
3.6 The if and while Constructs Require
Assuming a-turtle refers to a turtle, this reports Different Condition Forms
the turtle with the successor who-number.
One can define a reporter, named, say, next-turtle, The if family of statements requires a boolean expres-
to perform this function. sion as condition; while requires a reporter block.
to−r e p o r t n e x t − t u r t l e [ a− t u r t l e ] i f e l s e 3 > 4 [ show 3 ] [ show 4 ]
r e p o r t t u r t l e ( [ who ] o f a− t u r t l e + 1 )
end parses and produces 4.
When applied, w h i l e [ 3 > 4 ] [ show 3 ]

n e x t − t u r t l e some− t u r t l e
parses and correctly produces nothing. Why require
users to remember which form is required?
produces the correct answer. But attempting
[ n e x t − t u r t l e ] o f some− t u r t l e 3.7 Non-standard Terminology
produces the error message: NEXT-TURTLE expected NetLogo uses the terms reporter and report for con-
1 input. (See Section 3.8 for why.) Furthermore, one cepts for which virtually all other languages use func-
may not wrap next-turtle in an anonymous reporter. tion and return.
Agent primitives such as of and with don’t accept The functions word and sentence are also non-
anonymous procedures. standard and confusing.
The following are all equivalent. • The function word converts its argument(s) to
0 . n e x t − t u r t l e some− t u r t l e ; ; as above strings, which it concatenates.
1 . [ n e x t − t u r t l e s e l f ] o f some− t u r t l e • The function sentence combines the functionality
2 . f i r s t map n e x t − t u r t l e
of list and what might traditionally be called flat-
( l i s t some− t u r t l e )
3. ( runresult
ten. Confusingly, sentence has no specific con-
[ t −> n e x t − t u r t l e t ] some− t u r t l e ) nection to words or strings.
3.8 Higher-order Functions For a list containing those function, write

Since almost the very beginning, NetLogo has in- list [ n −> d o u b l e n ] [ n −> s q u a r e n ]
cluded the standard trio of higher-order functions: fil-
ter, map, and reduce. However, it appears to be quite rather than
awkward for model developers to create and use their
own higher order functions. list double square
Consider an attempted definition of the trivial
function application-of that expects a reporter proce-
dure as its first argument and an argument for that re- We could test this as follows.
porter procedure as its second. application-of applies
t o t e s t −a p p l i c a t i o n −o f [ k ]
its first argument to its second and returns the result. l e t l s t l i s t [ n −> d o u b l e n ]
(One might want this if one wants to select a function [ n −> s q u a r e n ]
from a list and apply it to some element.) f o r e a c h l s t [ f n −>
show a p p l i c a t i o n −o f f n k ]
to−r e p o r t a p p l i c a t i o n −o f [ f n a r g ] end
report fn arg
end t e s t −a p p l i c a t i o n −o f 6 ; ; => 12 36

The preceding fails to compile. But as we did in


Section 3.5, we can use the map trick. 3.9 Identifiers and Shadowing
to−r e p o r t a p p l i c a t i o n −o f [ f n a r g ]
r e p o r t f i r s t map f n ( l i s t a r g ) In the following, NetLogo’s shadowing rules disallow
end the parameters x (which is global) and dx (which is a
primitive) and the local variables y (which is global)
But attempted execution and z (which is a parameter name).
a p p l i c a t i o n −o f l a s t a− l i s t
globals [ x y ]

produces the error message: APPLICATION-OF ex-


t o t e s t −s c o p e [ x dx z ]
pected 2 inputs. That’s the case even though the body
let y 3
of the function executes without complaint.
let z 4
f i r s t map l a s t ( l i s t [1 2 3]) ; ; => 3 ...
end

The problem is that it’s not possible to refer by


name to a function as an object—except as the first
argument of map and other special cases. 3.10 Square Brackets and Parentheses
Making the parentheses explicit, NetLogo parses
Square brackets are required for the following.
a p p l i c a t i o n −o f l a s t a− l i s t
• command block components of higher-order (and
as control) constructs such as ask, carefully, crt, cro,
hatch, sprout, if, loop, repeat, while;
a p p l i c a t i o n −o f ( l a s t ( a− l i s t ) )
• reporter components of functions such as all?, ev-
ery, max-n-of, of, sort-on, with;
So (almost) any time a procedure name appears, the
NetLogo parser takes it as a procedure call. • anonymous expressions, which must be sur-
One work-around is to use anonymous proce- rounded by square brackets;
dures. Suppose we define double and square. • “containers” for components of keyword con-
to−r e p o r t d o u b l e [ n ]
structs such as at-points (two levels), breed, ex-
report n + n tensions, globals, histogram, includes, -own;
end
• lists (but only of literals) in the code or of any
to−r e p o r t s q u a r e [ n ]
values in the output. The list [1 2] is ok, but the
report n ∗ n would-be list [(turtle 0) (turtle 1)] is not.
end • parameter lists;
Figure 1: Starburst.

That’s too much of a burden for comfort. 3.13 Dot Notation for Accessing
Parentheses are required around any construct Instance Variables and Methods
that includes a function (such as foreach, ifelse, map,
list, and others) that (a) may take a variable number Most object-oriented languages use dot-notation for
of arguments and (b) is given two or more. instance variables and methods. NetLogo fore-
Parentheses are not required if only one argument goes dot notation: [who] of turtle-x rather than
appears—except for list which requires parentheses turtle-x.who. Dot notation is simpler and cleaner.
for one argument but not for two.

3.11 Stack Trace for Run-time Errors 4 STARBURST: A PyLogo MODEL


NetLogo is inconsistent with respect to run-time This section examines a simple PyLogo model.
errors—sometimes displaying a stack trace and at Starburst begins with a user-selected number of
other times only an error notice, with no hint about agents at the center of the grid. When run, 20% of
how the program got there. If a stack trace can be the agents move toward each corner. The final 20%
provided in some situations, why not in all? remain stationary. Since the agents in each group
have identical coordinates, each group appears to be
a single agent. At a user-selected tick, the agents
3.12 Dictionaries “explode”, producing a “starburst“ effect, and start to
move in random directions. From then on the agents
Dictionaries are one of Python’s most useful features. experience a repulsive force from each other, produc-
NetLogo’s table extension functions like a Python ing swerving trajectories.
dictionary. But table operations must include the pre- Figure 1 is a screenshot. The bottom two rows
fix table::, which makes for cluttered code. of buttons are standard on all PyLogo models. The
1 # i m p o r t s n o t shown . . .
2
3 c l a s s S t a r b u r s t A g e n t ( Agent ) :
4
5 def u p d a t e v e l o c i t y ( s e l f ) :
6 velocity = self . velocity
7 influence radius = gui get ( ' Influence radius ' )
8 n e i g h b o r s = s e l f . a g e n t s i n r a d i u s ( i n f l u e n c e r a d i u s ∗ BLOCK SPACING ( ) )
9 for neighbor in neighbors :
10 f o r c e = Agent . f o r c e s c a c h e . g e t ( ( n e i g h b o r , s e l f ) , None )
11 i f f o r c e i s None :
12 force = force as dxdy ( s e l f . center pixel , neighbor . c e n t e r p i x e l )
13 Agent . f o r c e s c a c h e [ ( n e i g h b o r , s e l f ) ] = f o r c e ∗ (−1 )
14 velocity = velocity + force
15 s p e e d f a c t o r = g u i g e t ( ' Speed f a c t o r ' )
16 s e l f . s e t v e l o c i t y ( n o r m a l i z e d x d y ( v e l o c i t y , 1 . 5∗ s p e e d f a c t o r / 100 ) )
17
18
19 c l a s s S t a r b u r s t W o r l d ( World ) :
20
21 def setup ( s e l f ) :
22 nbr agents = gui get ( ' nbr agents ' )
23 for i n range ( n b r a g e n t s ) :
24 s e l f . a g e n t c l a s s ( s c a l e=1 )
25 v s = [ V e l o c i t y (( −1 , −1 ) ) , V e l o c i t y (( −1 , 1 ) ) , V e l o c i t y ( ( 0 , 0 ) ) ,
26 V e l o c i t y ( ( 1 , −1 ) ) , V e l o c i t y ( ( 1 , 1 ) ) ]
27 f o r ( a g e n t , v e l ) i n z i p ( World . a g e n t s , c y c l e ( v s ) ) :
28 agent . s e t v e l o c i t y ( v e l )
29
30 def step ( s e l f ) :
31 b u r s t t i c k = g u i g e t ( ' Burst t i c k ' )
32 i f World . t i c k s >= b u r s t t i c k :
33 Agent . u p d a t e a g e n t v e l o c i t i e s ( )
34
35 Agent . u p d a t e a g e n t p o s i t i o n s ( )
36
37
38 # PySimpleGUI d e f i n i t i o n s . PyLogo u s e s t h e v e r y s t r a i g h t f o r w a r d
39 # P y S i m p l e G u i ( h t t p s : / / p y s i m p l e g u i . r e a d t h e d o c s . i o / ) a s i t s GUI f r a m e w o r k .
40
41 # As i n many Python p r o g r a m s , t h e f o l l o w i n g s t a r t s t h e model .
42 if name == ” m a i n ” :
43 PyLogo ( S t a r b u r s t W o r l d , ' S t a r b u r s t ' , g u i l e f t u p p e r , a g e n t c l a s s=S t a r b u r s t A g e n t ,
44 b o u n c e =(True , F a l s e ) , p a t c h s i z e=9 , b o a r d r o w s c o l s =(71 , 71 ) )

Listing 1: Starburst model.

penultimate line includes setup, go once, and go but- • step() executes at each tick. If the number of
tons, similar to NetLogo models. The go button, ticks has exceeded the user-settable “burst tick,”
initially green, turns red and is renamed stop when (not displayed), the static method Agent.update -
clicked. The exit button terminates the model. The agent velocities() is called. That, in turn, calls up-
top five lines allow the user to set model parameters. date velocity() for each Starburst Agent.
Starburst consists of a Starburst Agent subclass of update velocity() updates an agent’s velocity as
the PyLogo Agent class and a Starburst World sub- a function of its distances from its neighbors.
class of the PyLogo World class. (See Listing 1.) The influence radius slider determines how close
• setup() consults the gui to determine the num- agents must be to effect each other.
ber of agents. It creates those agents and sets Agent.forces cache stores the inter-agent forces so
their velocities as described earlier. PyLogo pro- that they are computed only once each tick.
vides substantial agent-motion support, including Agent.update agent positions() updates agent po-
velocity as an agent attribute. sitions based on their positions and velocities.
5 CONCLUSION Masad, D. and Kazil, J. (2015). Mesa: an agent-based mod-
eling framework. In 14th PYTHON in Science Confer-
PyLogo has two major weaknesses. ence, pages 53–60.
Nagpal, A. and Gabrani, G. (2019). Python for data ana-
• PyLogo is not optimized. It runs more slowly lytics, scientific and technical applications. In 2019
than NetLogo, and it can gracefully handle only Amity International Conference on Artificial Intelli-
a smaller number of agents. Even so, it handles gence (AICAI), pages 140–145. IEEE.
the standard NetLogo examples quite well. North, M. J., Collier, N. T., Ozik, J., Tatara, E. R., Macal,
C. M., Bragen, M., and Sydelko, P. (2013). Com-
• PyLogo doesn’t offer graphing. plex adaptive systems modeling with repast simphony.
Notwithstanding these limitations, PyLogo was Complex adaptive systems modeling, 1(1):3.
more than adequate for teaching an ABM course. Ozik, J., Collier, N. T., Murphy, J. T., and North, M. J.
PyLogo’s primary advantage is that model devel- (2013). The relogo agent-based modeling language.
In 2013 Winter Simulations Conference (WSC), pages
opers write in Python. For people accustomed to writ- 1560–1568. IEEE.
ing software, writing in Python is much less frustrat- Railsback, S., Ayllón, D., Berger, U., Grimm, V., Lytinen,
ing than writing in NetLogo. Experienced program- S., Sheppard, C., and Thiele, J. (2017). Improving
mers often feel that they are fighting the language execution speed of models implemented in netlogo.
when writing in NetLogo. The opposite is generally Journal of Artificial Societies and Social Simulation,
true when writing in Python. 20(1).
PyLogo confirms that something as simple and Taghawi-Nejad, D., Tanin, R. H., Chanona, R. M. D. R.,
intuitive as agents interacting on a grid (using tick- Carro, A., Farmer, J. D., Heinrich, T., Sabuco, J., and
based scheduling) accommodates a very wide range Straka, M. J. (2017). Abce: A python library for eco-
nomic agent-based modeling. In International Con-
of models. ference on Social Informatics, pages 17–30. Springer.
The development of PyLogo—a fully operational
Taillandier, P., Gaudou, B., Grignard, A., Huynh, Q.-N.,
core completed in a month, with additional features Marilleau, N., Caillou, P., Philippon, D., and Dro-
plus a range of models added while using the system goul, A. (2019). Building, composing and experi-
for a class—demonstrates that Python enables rapid menting complex spatial models with the gama plat-
development of a fairly sophisticated system. form. GeoInformatica, 23(2):299–322.
Thiele, J. C. (2014). R marries netlogo: introduction to
PyLogo is comparatively small: 10 core files and the rnetlogo package. Journal of Statistical Software,
15 models of 2,000 SLOC and 3,000 SLOC respec- 58(2):1–41.
tively. It is open-source and available for download. Tisue, S. and Wilensky, U. (2004a). Netlogo: A simple en-
vironment for modeling complexity. In International
conference on complex systems, volume 21, pages 16–
21. Boston, MA.
REFERENCES Tisue, S. and Wilensky, U. (2004b). Netlogo: Design and
implementation of a multi-agent modeling environ-
Badham, J. (2015). Review of: Wilensky, An Introduction ment. In Proceedings of agent, volume 2004, pages
to Agent-Based Modeling. Journal of Artificial Soci- 7–9.
eties and Social Simulation, 18(4).
Vahdati, A. R. (2019). Agents.jl: agent-based modeling
Bakshy, E. and Wilensky, U. (2007). Netlogo-mathematica framework in julia. Journal of Open Source Software,
link. Center for Connected Learning and Computer- 4(42):1611.
Based Modeling, Northwestern University, Evanston,
IL. Wilensky, U. (2019). Netlogo user manual.
Feurzeig, W. and Papert, S. (1967). The logo programming Wilensky, U. (2020). Private communication.
language. ODP-Open Directory Project.
Grigoryev, I. (2015). Anylogic 7 in three days. A quick
course in simulation modeling, 2.
Gunaratne, C. and Garibay, I. (2018). Nl4py: Agent-
based modeling in python with parallelizable netlogo
workspaces. arXiv preprint arXiv:1808.03292.
Harvey, B. (1982). Why logo. Byte, 7(8):163–193.
Jaxa-Rozen, M. and Kwakkel, J. H. (2018). Pynetlogo:
Linking netlogo with python. Journal of Artificial So-
cieties and Social Simulation, 21(2).
Luke, S., Cioffi-Revilla, C., Panait, L., Sullivan, K., and
Balan, G. (2005). Mason: A multiagent simulation
environment. Simulation, 81(7):517–527.

You might also like