Dark room

Dark room preview image

1 collaborator

Default-person Dajun Yue (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.0.4 • Viewed 454 times • Downloaded 35 times • Run 0 times
Download the 'Dark room' 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?

(a general understanding of what the model is trying to show or explain)

HOW IT WORKS

(what rules the agents use to create the overall behavior of the model)

HOW TO USE IT

(how to use the model, including a description of each of the items in the Interface tab)

THINGS TO NOTICE

(suggested things for the user to notice while running the model)

THINGS TO TRY

(suggested things for the user to try to do (move sliders, switches, etc.) with the model)

EXTENDING THE MODEL

(suggested things to add or change in the Code tab to make the model more complicated, detailed, accurate, etc.)

NETLOGO FEATURES

(interesting or unusual features of NetLogo that the model uses, particularly in the Code tab; or where workarounds were needed for missing features)

RELATED MODELS

(models in the NetLogo Models Library and elsewhere which are of related interest)

CREDITS AND REFERENCES

(a reference to the model's URL on the web if it has one, as well as any other necessary credits, citations, and links)

Comments and Questions

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

Click to Run Model

breed [students student]

students-own 
[
  user-id 
  step-size
  dark-region
  visible-region
]

to startup
  hubnet-reset
end 

to setup
  clear-patches
  clear-drawing
  clear-output
  
  color-patches
  
  ask turtles
  [
    set step-size 1
    update-vision    ;; update vision
    hubnet-send user-id "step-size" step-size
  ]
  reset-ticks
end 

to go
  listen-clients
  every 0.1
  [
    tick
  ]
end 

;;
;;  HubNet Procedure
;;

to listen-clients
  while [hubnet-message-waiting?]
  [
    hubnet-fetch-message
    ifelse hubnet-enter-message?
    [ create-new-student ]
    [
      ifelse hubnet-exit-message?
      [ remove-student ]
      [
        ask students with [user-id = hubnet-message-source] 
        [
          execute-command hubnet-message-tag 
          update-vision
        ]
      ]
    ]
  ]
end 

to create-new-student
  create-students 1
  [
    set user-id hubnet-message-source
    set label user-id
    set step-size 1
    update-vision
  ;  pen-down
    send-info-to-clients
  ]  
end 

to remove-student
  ask students with [user-id = hubnet-message-source]
  [die]
end 

to execute-command [command]
  if command = "step-size"
  [
    set step-size hubnet-message
    stop
  ]
    if command = "up"
  [ execute-move 0 stop ]
  if command = "down"
  [ execute-move 180 stop ]
  if command = "right"
  [ execute-move 90 stop ]
  if command = "left"
  [ execute-move 270 stop ]
end 

to send-info-to-clients
  hubnet-send user-id "location" (word "(" pxcor "," pycor ")")
end 

to execute-move [new-heading]
  set heading new-heading
  fd step-size
  send-info-to-clients
end 

to color-patches
  ask n-of 10 patches [set pcolor white]
end 

to update-vision
  set visible-region patches in-radius 5
  set dark-region patches with [not member? self [visible-region] of myself]
end 

to mask
  ask turtles [
    hubnet-clear-override user-id visible-region "pcolor" 
    hubnet-send-override user-id dark-region "pcolor" [black]
  ]
end 

There is only one version of this model, created over 12 years ago by Dajun Yue.

Attached files

File Type Description Last updated
Dark room.png preview Preview for 'Dark room' over 12 years ago, by Dajun Yue Download

This model does not have any ancestors.

This model does not have any descendants.