NetLogo Playground Tag

No preview image

1 collaborator

Default-person Brian Donovan (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 4.1 • Viewed 180 times • Downloaded 28 times • Run 1 time
Download the 'NetLogo Playground Tag' modelDownload this modelEmbed this model

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

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

breed [kids person]
kids-own [ energy timeit ]
globals [whosit whowillit tagged runavg counter timeitlist qkcnt recount] 

to setup
  clear-all
  set-default-shape kids "person"
  create-kids number [
    set color white
    setxy random-xcor random-ycor
    set energy random 10  ;start with a random amt. of energy
  ]
  
  set timeitlist []
  set qkcnt 0
  
  while [qkcnt < number ]
  [
    set timeitlist lput 0 timeitlist
    set qkcnt qkcnt + 1
  ]
  
  set runavg n-values 2 [avg-speed]
  set counter 1
  while [counter < number / 2]
  [
    set runavg fput (Avg-Speed / (.5 * counter)) runavg
    set runavg lput (Avg-Speed * (.5 * counter)) runavg
    set counter counter + 1
  ]
;  setup-plot
;  do-plot
end 

to go
 
  
  ask kids
  [ 
    set label who
    run-away
    chase
    set timeitlist replace-item who timeitlist timeit
     ]
  tick
  ;do-plot
end 

to tag
  
  ask kids with [who = whosit]
  [
    
    ask min-one-of other kids [distance myself]        
      [
      set color red
      wait .01
      set whosit who 
      ]
      
    set color 85
    fd 10
    
    
    
  ]
end 

to chase
  
  ask kids with [who = whosit]
  [
    print word whosit"'s it"
    set timeit timeit + 1
    set color red
   
   
    face min-one-of other kids [distance myself]  
    fd item who runavg
   
    set energy energy - 0.1
  
  if energy < .001
  [
    set energy 7]
  
  
  if count kids with [who != whosit] in-radius (30 / Reach) > 0
  [tag]
   
  ]
end 

to run-away
  ask kids with [who != whosit] 
  [ 
    set color 85
    if count kids with [who = whosit] in-radius 3 > 0 
    [ifelse energy > 0
  [
    
    repeat 10 
  [fd item who runavg 
   
    set energy energy - 1
  ]]
  [set color green
    set energy 7]
  ]]
end 

to tire     
  ;; rest if you run out of energy
  if energy < 0 
  [repeat 10 [fd 1 bk 1]
  set energy energy + 7]
end 

;; plotting procedures

to setup-plot
  set-current-plot "Time Spent It vs Speed"
  set-plot-y-range 0 number
  set-plot-x-range 0 max runavg
  set-plot-pen-mode 1
end 

to do-plot
  set-current-plot "Time Spent It vs Speed"
  set recount 0
  while [recount < number] 
  [ plotxy item recount runavg item recount timeitlist]
end 

There is only one version of this model, created about 15 years ago by Brian Donovan.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.