Red Light Green Light
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
This section could give a general understanding of what the model is trying to show or explain.
HOW IT WORKS
This section could explain what rules the agents use to create the overall behavior of the model.
HOW TO USE IT
This section could explain how to use the model, including a description of each of the items in the interface tab.
THINGS TO NOTICE
This section could give some ideas of things for the user to notice while running the model.
THINGS TO TRY
This section could give some ideas of things for the user to try to do (move sliders, switches, etc.) with the model.
EXTENDING THE MODEL
This section could give some ideas of things to add or change in the procedures tab to make the model more complicated, detailed, accurate, etc.
NETLOGO FEATURES
This section could point out any especially interesting or unusual features of NetLogo that the model makes use of, particularly in the Procedures tab. It might also point out places where workarounds were needed because of missing features.
RELATED MODELS
This section could give the names of models in the NetLogo Models Library or elsewhere which are of related interest.
CREDITS AND REFERENCES
This section could contain a reference to the model's URL on the web if it has one, as well as any other necessary credits or references.
Comments and Questions
extensions [gogo] breed [turtle-lights turtle-light] globals [ max-flex ;; maximum input value from flex min-flex ;; minimum max-out ;; maximum output value to motor min-out ;; minimum serial-port light-ticker red-light-on? ticking? caught? time-keeper threshold ] ;; ;; All of these procedures set up junk ;; to setup ca set-constants if gogo? [ setup-gogo ] setup-nogogo create-turtle-lights 1 [ set color green set shape "circle" ] end to set-constants set max-flex 400 set min-flex 230 set max-out 7 set min-out 0 set light-ticker 0 set ticking? False turn-off-red-light set caught? False set threshold 3 set-time-keeper end to setup-gogo set serial-port user-one-of "select a port" gogo:ports gogo:open serial-port end to setup-nogogo crt 1 ask turtle 0 [set heading 0 fd 1 rt 90 set color white] end ;; ;; go is the main looping procedure ;; to go every 0.03 [ ask turtle 0 [ fd get-p1-power ] if gogo? [ gogo ] lights catch-reaction-time update-plot ] end ;; ;; REACTION TIME ;; to catch-reaction-time if not caught? and red-light-on? [ if get-p1-power < threshold [ set caught? True print "off!" set-current-plot "Reaction Speed" set-current-plot-pen "default" plot light-ticker set-current-plot-pen "time-keeper" plot time-keeper ] ] if caught? and red-light-on? and get-p1-power > threshold [ print "u smell" ] end ;; ;; LIGHTS ;; to lights set light-ticker light-ticker + 1 ;;print light-ticker ifelse red-light-on? [ if light-ticker > time-keeper [ if not caught? [ set-current-plot "Reaction Speed" set-current-plot-pen "default" plot light-ticker set-current-plot-pen "time-keeper" plot time-keeper ] turn-off-red-light set-time-keeper print "no more red light" ] ] [ if light-ticker > time-keeper [ turn-on-red-light set-time-keeper print "red light oooon!!" ] ] end to turn-on-red-light set red-light-on? True set caught? False set light-ticker 0 ask turtle-lights [set color red] if gogo? [gogo:talk-to-output-ports["d"] gogo:output-port-on] end to turn-off-red-light set red-light-on? False set light-ticker 0 ask turtle-lights [set color green] ;if gogo? [gogo:talk-to-output-ports["d"] gogo:output-port-off] end to set-time-keeper set time-keeper (random 30) + 10 end ;; ;; get-pXXX-power return the input ;; scaled to the proper motor power levels ;; to-report get-p1-power let power 0 ifelse gogo? [set power round scale-to-out gogo:sensor 1] [set power round scale-to-out p1-nogogo-in] ifelse power > 8 [ report 7 ] [ ifelse power < 0 [ report 0 ] [ report power ]] end ;; ;; Procedure that scales the input value ;; to the range of the output values ;; to-report scale-to-out[n] report ((n - min-flex) * max-out / (max-flex - min-flex)) end ;; ;; graphing of speeeeeds ;; to update-plot set-current-plot "Speeds" set-current-plot-pen "p1-pen" plot get-p1-power end ;; ;; These procedures deal with gogoboard stuff ;; mostly just short-cuts to make less typing ;; to gogo set-p1-motor get-p1-power end to kill-motors p1-motor gogo:output-port-off end to set-p1-motor [power] p1-motor ifelse power > threshold [ gogo:output-port-on ] [ gogo:output-port-off ] end to p1-motor gogo:talk-to-output-ports["a"] end
There is only one version of this model, created over 14 years ago by Rodolphe Courtier.
Attached files
No files
This model does not have any ancestors.
This model does not have any descendants.