Escape from Goblin-town! (2025)
A NetLogo ( Citation: Wilensky, 1999 Wilensky, U.(1999). Retrieved from http://ccl.northwestern.edu/netlogo/ ) model by Rik Blok.
This simulation is inspired by the Goblin-town chase scene in the film The Hobbit: An Unexpected Journey (2012).
Still goblins go faster than dwarves, and these goblins knew the way better (they had made the paths themselves), and were madly angry; so that do what they could the dwarves heard the cries and howls getting closer and closer. Soon they could hear even the flap of the goblin feet, many many feet which seemed only just round the last corner. The blink of red torches could be seen behind them in the tunnel they were following; and they were getting deadly tired.
The NetLogo model above simulates a set of platforms and bridges, shown from above. Dwarves (brown) are trying to get from the top-left corner, past the goblins (green), to the escape in the bottom-right corner. The goblins are trying to capture the dwarves before they escape. To see how it works, press setup and, after waiting a few seconds for the scene to be prepared, press go.
You’ll see that the dwarves and goblins are both pretty silly – they just stumble around randomly. If a dwarf should happen to find the escape, it’s just dumb luck.
Can you do better? You can edit the code in this simulation to try help the dwarves (or goblins). Click NetLogo Code at the bottom of the simulation and take a look at these procedures:
to turn-dwarf
;;;;;; YOUR CODE GOES HERE!
wiggle 30
end
;---------------------------------------------------------
to turn-goblin
;;;;;; YOUR CODE GOES HERE!
wiggle 90
end
The command wiggle
is a procedure I wrote. But it’s not very useful – it just makes the individual randomly turn left or right a bit. Have a look at the face-…
procedures in the NetLogo Code above. Maybe some of those would be better? Go ahead and replace the command wiggle
in the turn-dwarf
or turn-goblin
procedure, then click Recompile Code to try it out. Did your changes work the way you expected? (If not, see if you can figure out why not and try again 🙂)
Examples
Listing 1 shows some example turn-dwarf
and turn-goblin
procedures. Notice that some face-...
procedures only turn the individual if they’re close enough to “hear” the target. So these procedures can be called after other procedures to “override” the individual’s behaviour. For example, Listing 1 shows that dwarves will try to move towards the exit except if they hear goblins nearby; then they will try to avoid the goblins.
;---------------------------------------------------------
to turn-dwarf
;;;;;; YOUR CODE GOES HERE!
face-towards-escape ; first face exit
face-away-from-goblin-sounds ; but if hear goblins, turn away
end
;---------------------------------------------------------
Listing 1: Example turn-dwarf
and turn-goblin
procedures demonstrating how to use the face-...
procedures.
;---------------------------------------------------------
to turn-goblin
;;;;;; YOUR CODE GOES HERE!
wiggle 90 ; first turn up to 90 degrees left/right randomly
face-towards-dwarf-sounds ; but if hear dwarves, turn towards
end
;---------------------------------------------------------
Listing 1: Example turn-dwarf
and turn-goblin
procedures demonstrating how to use the face-...
procedures.
References
- Wilensky (1999)
- Wilensky, U.(1999). Retrieved from http://ccl.northwestern.edu/netlogo/