Sampler Super Simple

No preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)

Tags

(This model has yet to be categorized with any tags)
Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 4.1pre3 • Viewed 107 times • Downloaded 16 times • Run 0 times
Download the 'Sampler Super Simple' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


VERSION

$Id: Sampler Super Simple.nlogo 40298 2008-07-23 20:15:38Z everreau $

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 ]

patches-own
[ true-color ]

to startup
  setup
  hubnet-set-client-interface "COMPUTER" []
  hubnet-reset
end 

to setup
  cp
  cd
  clear-output
  ask patches 
  [
    set pcolor gray
    ifelse random 2 = 0
    [ set true-color blue ]
    [ set true-color green ]
  ]
end 

to go
  every 0.1
  [
    listen-clients
    display
  ]
end 

;;
;; HubNet Procedures
;;

to listen-clients
  while [ hubnet-message-waiting? ]
  [
    hubnet-fetch-message
    ifelse hubnet-enter-message? ;; when clients enter we get a special message
    [ create-new-student ]
    [
      ifelse hubnet-exit-message? ;; when clients exit we get a special message
      [ remove-student ]
      [ ask students with [user-id = hubnet-message-source]
        [ execute-command hubnet-message-tag ] 
      ]
    ]
  ]
end 

to create-new-student
  create-students 1
  [
    set user-id hubnet-message-source
    ht
  ]
end 

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

to execute-command [command]
  if command = "View"
  [
    let x round ( item 0 hubnet-message )
    let y round ( item 1 hubnet-message )
    let my-patch-set patches with [pxcor >= (x - 1) and pxcor <= (x + 1) and pycor >= (y - 1) and pycor <= (y + 1) ]

    hubnet-clear-overrides hubnet-message-source
    hubnet-send-override hubnet-message-source my-patch-set "pcolor" [true-color]
  ]
end 

There are 2 versions of this model.

Uploaded by When Description Download
Uri Wilensky over 12 years ago Sampler Super Simple Download this version
Uri Wilensky over 12 years ago Sampler Super Simple Download this version

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.