Enhanced Appendices | An Enchantment of Digital Archaeology > Golems in the City

Our Code on GitHub

Berghahn Digital Archaeology supports the transparent accessibility of any code or program used and/or incorporated in the digital projects found on this site. To view, download, or suggest updates for items related to any of our projects, please visit our GitHub page and repositories.

github.com/Berghahn-DigitalArchaeology

Golems in the City

;; built for NetLogo version 6.04 ;; a small demo model that loads a map ;; populates it with golems and gives one of them ;; a message - or a virus, pick your metaphor - and turns ;; them loose. ;; Golems move by selecting a target patch of ground ahead of ;; them within their cone of vision ;; where ground they can walk on is the colour of the path ;; in the maps generated by Oleg Dolya’s Medieval Fantasy City ;; Map Generator at ;; https://watabou.itch.io/medieval-fantasy-city-generator ;; (Note that other maps can work, but you will need to be able ;; to identify the color value for any paths you want golems to ;; follow.) ;; Preliminaries and Interface Window setup ;; 1. Generate a map there and select the ‘sanguine’ colour ;; palette (if you select a different palette, you’ll have to ;; fi gure out its colour value for the pcolor variable in the ;; ‘walk’ procedure. ;; 2. Save that map to your computer in the same place you have ;; this model. ;; In the INTERFACE: ;; 3. Create a button called ‘1. Load Map’ and give it this code: ;; ca ;; import-pcolors user-file ;; 4. Create a button called ‘2. Setup Golems’ and give it this ;; code: ;; setup ;; 5. Create two sliders, one called ‘loudness’ the other called ;; ‘vision’ and set their min value to 1 and max value to about ;; 15. ;; 6. Create a ‘go’ button. Give it this code: ;; go ;; and tick off the ‘forever’ box. ;; 7. Create a slider called ;; num-walkers ;; and make sure that the minimum is set to 2 and the ‘value’ ;; (starting position of the slider) is at least 2 or more ;;---- ;; the model is built by combining default code snippets in ;; NetLogo: ;; network import ;; communication t-t network example ;; link-walking turtles ;; you can also build some monitors. For instance, right-click in ;; the interface and select new monitor ;; then paste this code into it: ;; ((count walkers with [message?]) / (count walkers)) * 100 ;; this will tell you the per cent of the population that has ;; heard the message. ;; you could graph this by making a new plot and giving it the ;; same code ;; right-click, select plot, and in plot update commands paste ;; the same code. ;; While the model is running, you could type: ;; pd ;; in the observer box at the bottom of the interface. This will ;; make the walkers draw on the map ;; where they’ve been. Maybe there’s something particular about a ;; city layout that draws walkers to particular places? ;; How else might you expand this? ;; globals breed [walkers walker] ;; the turtles who wander around walkers-own [ ;; variables that only the walkers own message? direction ] ;; setup to setup create-walkers num-walkers [ set color blue set shape “person” set size 15 setxy random-xcor random-ycor if pcolor != 38.9 [die] ;; drastic, but we don’t want any walkers in the rivers or on the ;; walls or inside buildings set message? false ;; ignorance is bliss ] ask one-of walkers [ set message? true ] reset-ticks end to go ask walkers [ ifelse color = blue [walk][chase] communicate ;; they talk to anyone else who happens to be present recolor ;; change their color if they’ve encountered someone with the ;; message ] if ((count walkers with [message?]) / (count walkers)) * 100 > 95 [stop] ;; ending condition tick end to walk ask walkers[ rt random 30 - 15 let target one-of patches in-cone 1.5 120 with [pcolor = 38.9] ;; the color of the path if target != nobody [ face target move-to target ] ] end to chase ask walkers [ rt random 30 - 15 let chasee one-of walkers in-cone vision 120 with [color = blue] if chasee != nobody [ face chasee walk ] ] end to communicate ;; walker procedure ;; shouting! if any? other walkers in-radius loudness with [message?] ;; or use this line to mimic ‘whispering’: ;; if any? other walkers-here with [message?] ;; experiment. What difference to your results does whispering ;; versus shouting make? [ set message? true ] ;; if yes, then the walker now knows the message too end to recolor ;; walker procedure ifelse message? [ set color red ] [ set color blue ] end

Latest from the Blog