If you prefer to print out the whole document, please find the pdf version in the section of supervision on RM03 Moodle page.
Assignment for Supervision 2
Submission Dealine: 9 Mar(Tuesday) 12:00pm, 2021
Instructions
- Read through the instruction carefully. You may face problems if you overlook any of the steps.
- Please write your answers in a new blank word document and submit on Moodle. You can add screen captures to aid your explanation if you wish.
Note: functions and filename are highlighted
in this document.
Assignment overview
In this assignment, you will familiarise yourself with changing the codes on NetLogo using the Game of Life model.
Setup work environment
- Open
NetLogo 6.1.1
(NOTNetLogo 3D 6.1.1
). - Open
Life
fromModels Library
underSample Models
>Computer Science
>Cellular Automata
. - Game of Life is a simple cellular automata (CA) model where the state of the cells (patches) change according to behavioral rules. As the simulation runs, you can find recurring shapes like gliders and blinkers. Note: You can refer to
Conway's Game of Life
(https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life) for more detailed information. - Click
setup-random
>go-forever
to start the simulation, and clickgo-forever
again to stop the simulation.
Understanding NetLogo codes
- Let’s check the
Code
tab. (Note: If you don’t see line numbers, for Windows users, on theMenu bar
, clickTools
>Preferences
and checkShow Line Numbers
. For Mac users, on theMenu bar
, clickNetLogo
>Preferences
and checkShow Line Numbers
.) - In line 2-3,
living?
andlive-neighbors
are variables. In line 8,ask patches [ cell-death ]
means toask
(http://ccl.northwestern.edu/netlogo/docs/dict/ask.html) patches to run the[ cell-death ]
command. In line 26,[ cell-death ]
command setsliving?
as false, and sets patch color as foreground color.[ cell-birth ]
command does the opposite. - Line 14 means “ask patches to run the
ifelse
[(http://ccl.northwestern.edu/netlogo/docs/dict/ifelse.html)] (http://ccl.northwestern.edu/netlogo/docs/dict/ifelse.html) command. ifelse commands are very important in language-based rules. Line 15-17 means “ifrandom-float 100 < initial-density
reports true (in other words, “if arandom floating point number >= 0 but less than 100
is less than theinitial density (default=35)
”), run the[ cell-birth ]
command, and otherwise, run the[ cell-death ]
command. This part makes each cell to check the state of itself. Note: You can refer toNetLogo Dictionary
(http://ccl.northwestern.edu/netlogo/docs/index2.html) when trying to understand the codes.
- Line 33 means “set the variable
live-neighbors
tocount how many neighboring cells are alive
” and line 32 asks patches to run this command. This part makes each cell to check the state of its eight surrounding neighbors. Note: Refer toneighbors
[(http://ccl.northwestern.edu/netlogo/docs/dict/neighbors.html)] (http://ccl.northwestern.edu/netlogo/docs/dict/neighbors.html). - Line 38 asks patches to run another ifelse command.
Question 1. Click the Info
tab below the Menu bar
. Under HOW IT WORKS
, you can find the rules of the game. Rules can be summarised as the four points below.
- If there is exactly 3 alive neighbors, the cell becomes alive. (birth)
- If there are less than 2 alive neighbors, the cell dies. (under-population)
- If there are more than 3 alive neighbors, the cell dies. (over-population)
- If there are 2 alive neighbors, the cell remains in the state it is in. (sustainable life)
1-1. Try writing these rules into NetLogo code using if
(http://ccl.northwestern.edu/netlogo/docs/dict/if.html) statement, one line of code for the first three points (Note: You don’t need to worry about the 4th point because it doesn’t change the cell state).
1.2. Explain how these three lines of code can be shorted to line 39-42 written in the model using the ifelse
(http://ccl.northwestern.edu/netlogo/docs/dict/ifelse.html) command.
Question 2. In line 33, try changing neighbors
to neighbors4
and run the model. Observe and explain how this change affects the simulation. (Refer to neighbors4
(http://ccl.northwestern.edu/netlogo/docs/dict/neighbors.html).)
Question 3. Let’s add one additional command to the model. Add the following lines below the to cell-death
part. This command makes this cell colored in green to kill the four surrounding patches. Explain this rule in your own words. (Note: In case you don’t see green zombie cells appearing, you change the neighbors4
back to neighbors
as in the screenshot below and set the initial-density around 35% so that cells don’t die out too quickly. Also, try pressing “go-once” several times rather than “go-forever”.)
to zombie-birth
set living? true
ask neighbors [ cell-death ]
set pcolor green
end
Question 4. Let’s add a new rule for zombie-birth
. Add the following lines below the ask patches [ ifelse ]
part. This rule runs the same ifelse command on the 1,000 randomly chosen patches, this time for zombie-birth
. (Note: n-of
(http://ccl.northwestern.edu/netlogo/docs/dict/n-of.html)). Run the model and explain how this change affects the simulation.
ask n-of 1000 patches
[ ifelse live-neighbors = 3
[ zombie-birth ]
[if live-neighbors != 2
[ cell-death ] ] ]
Question 5. In 500 words, explain how the concept of game of life can apply to planning-related studies. Suggested reading includes the following and you can also refer to other materials that you find. In-text citation is encouraged.
- Dounas, T. et al. (2017) ‘Dense Urban Typologies and the Game of Life: Evolving Cellular Automata’, in Çağdaş, G. et al. (eds) Proceedings of the 17th International Conference on Computer Aided Architectural Design Futures, Istanbul Technical. Levent, Istanbul: Cenkler Matbaa, pp. 648–666. Available at: http://papers.cumincad.org/data/works/att/cf2017_648.pdf.
- Pinto, N. N. and Antunes, A. P. (2007) ‘Cellular automata and urban studies: a literature survey’, ACE: architecture, city and environment, 1(3), pp. 368–399. doi: 10.5821/ace.v1i3.2378. Available at: https://www.research.manchester.ac.uk/portal/files/22523283/POST-PEER-REVIEW-PUBLISHERS.PDF
Optional: Manually drawing cells
- Open the original
Life
model fromModels Library
again. Clicksetup-blank
anddraw-cells
button and manually attempt drawing shapes that are stable and do not change, or shapes that return to their initial state after a few ticks. (Note: You can test the patterns suggested here: https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life.)