Central Park Events NetLogo Model
Produced for the book series "Artificial Intelligence";
Author: W. J. Teahan; Publisher: Ventus Publishing Aps, Denmark.
powered by NetLogo
view/download model file: Central-Park-Events.nlogo
WHAT IS IT?
This model visualises a small set of events that an agent needs to perform if they wish to go from the Zoo to the Boat Pond in New York's Central Park. The events are shown using an event map representation, where events are linked to other events on separate streams in an ordered sequence. The idea is that an agent processes events simultaneously on separate streams. The approach is similar to the approach adopted for Event Stream Processing (ESP).
WHAT IS ITS PURPOSE?
The purpose of this model is to show how to visualise a series of events using an event map.
HOW IT WORKS
The model uses turtle agents to represents the states in the event map, and uses links agents to represent the paths between states. States own three variables:
- depth: The depth in the event map tree.
- stream: The stream name (where a stream consists of a sequence of sensory or motor events).
- event: The event - either sensory or motor. (Abstract events are not needed for this particular event map).
A spring layout is used to visualise the event map.
HOW TO USE IT
Press the setup button first. This will usually produce a cluttered layout. To unfold the clutter, press the change-layout button, and then dynamically change the values in the sliders that control the layout. One effective technique is to reduce the value of the spring-length slider to 0, then slowly increase it back up again until the desired length and layout is achieved.
The model's Interface buttons are defined as follows:
- setup: This will clear the environment and variables and (re)-load the event map. Normally, this will appear in a cluttered form and the change-layout button needs to be pressed subsequently.
- change-layout: This can be used to clear some of the clutter by changing the values in the three sliders.
The model's Interface sliders are defined as follows:
- spring-constant: This is a value used by the layout-spring command. Changing it will usually not affect the visualisation of the event map much.
- sprint-length: This modifies the length of the paths between the states of the event map network.
- repulsion-constant: This controls how much each of the states repel each other.
THINGS TO NOTICE
Notice how the repulsion-constant slider can be used to "repel" the states away from each other (for larger values) and "attract" the states towards each other (for smaller values).
Notice that the clutter in the network layout can often be removed by setting the value of the spring-length slider to zero and then increasing it afterwards.
THINGS TO TRY
Try altering the values of the sliders to see what effect this has on the layout.
EXTENDING THE MODEL
Combine this model with the Map Drawing model loaded using the Map Drawing Central Park World. Then show several agents wandering between the Zoo and Boat Pond by animating the map and event map at the same time. This can be done so that each agent ends up with slight variations in the paths they choose since there is the possibility for minor variations to occur between the states of the event map. For example, when turning left, the agent may choose to turn left by slightly more or slightly less than 90 degrees. Similarly, when walking forwards, the agent can choose to walk forwards a distance that varies slightly to other agents applying the same event map.
The model uses the layout-spring command for modifying the layout of the network of states (turtle agents) and paths (link agents).
See the Wall Following Events model and the Knowledge Representation model.
CREDITS AND REFERENCES
This model was created by William John Teahan.
To refer to this model in publications, please use:
Central Park Events NetLogo model.
Teahan, W. J. (2010). Artificial Intelligence. Ventus Publishing Aps.
; Central Park Events model. ; ; Draws an event map of some actions of how to go from the ; Zoo to the Boat Pond in Central Park. ; ; Copyright 2010 William John Teahan. All Rights Reserved. ; breed [states state] directed-link-breed [paths path] states-own [ depth ;; depth in the tree stream ;; the name of the stream of sensory or motor events event ;; the sensory or motor event ] globals [ root-colour node-colour link-colour ] ;; defines how the event tree gets visualised to setup clear-all ;; clear everything set-default-shape states "circle 2" set root-colour sky set node-colour sky set link-colour sky add-events (list (list "sensing-event" "use-sight") (list "motor-event" "look-around") (list "sensed-object-event" "skyscrapers") (list "motor-event" "walk-to-sensed-object") (list "motor-event" "turn-left") (list "motor-event" "walk-until-sensed-object") (list "sensed-object-event" "74th-Street-sign") (list "motor-event" "turn-left") (list "motor-event" "walk-forwards") (list "sensed-object-event" "lake-or-building")) reset-layout end to reset-layout repeat 500 [ layout-spring states paths spring-constant spring-length repulsion-constant ] ;; leave space around the edges ask states [ setxy 0.95 * xcor 0.95 * ycor ] end to change-layout reset-layout display end to set-state-label ;; sets the label for the state set label (word "[" stream " = " event "] ") end to add-events [list-of-events] ;; add events in the list-of-events list to the events tree. ;; each item of the list-of-events list must consist of a two itemed list. ;; e.g. [[hue 0.9] [brightness 0.8]] let this-depth 0 let this-stream "" let this-event "" let this-state nobody let next-state nobody let these-states states let matching-states  let matched-all-so-far true foreach list-of-events [ set this-stream first ? set this-event last ? ;; check to see if state already exists set matching-states these-states with [stream = this-stream and event = this-event and depth = this-depth] ifelse (matched-all-so-far = true) and (count matching-states > 0) [ set next-state one-of matching-states ask next-state [ set-state-label ] set these-states [out-path-neighbors] of next-state ] [ ;; state does not exist - create it set matched-all-so-far false create-states 1 [ set size 8 set depth this-depth set stream this-stream set event this-event set-state-label ifelse (depth = 0) [ set label-color root-colour ] [ set label-color node-colour ] ifelse (depth = 0) [ set color root-colour ] [ set color node-colour ] set next-state self ] ] if (this-state != nobody) [ ask this-state [ create-path-to next-state [ set color link-colour ]]] ;; go down the tree set this-state next-state set this-depth this-depth + 1 ] ask links [ set thickness 1.3 ] end ; ; Copyright 2010 by William John Teahan. All rights reserved. ; ; Permission to use, modify or redistribute this model is hereby granted, ; provided that both of the following requirements are followed: ; a) this copyright notice is included. ; b) this model will not be redistributed for profit without permission ; from William John Teahan. ; Contact William John Teahan for appropriate licenses for redistribution for ; profit. ; ; To refer to this model in publications, please use: ; ; Teahan, W. J. (2010). Central Park Events NetLogo model. ; Artificial Intelligence. Ventus Publishing Aps. ;