Escape from Goblin-town!
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. J.R.R. Tolkien, "The Hobbit"
The following simulation is inspired by the Goblin-town chase scene in the film The Hobbit: An Unexpected Journey.
The NetLogo model below 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. 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 dumb – 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 and take a look at these procedures:
to turn-dwarf ;;;;;; YOUR CODE GOES HERE! face-random-direction end ;--------------------------------------------------------- to turn-goblin ;;;;;; YOUR CODE GOES HERE! face-random-direction end
The command face-random-direction
is a procedure I wrote. But it's not very useful. Have a look at the other face-…
procedures in the NetLogo Code below. Maybe one of those would be better? Go ahead and replace the command face-random-direcion
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 )
Submit your code
Did you write some amazing turn-dwarf
or turn-goblin
code? Submit it here! I might add it to the simulation!