Notes‎ > ‎

Basic Netlogo Attachment Model

posted 7 Feb 2012, 07:29 by David Sherlock   [ updated 7 Feb 2012, 07:32 ]
Attached is the base of my netlogo model. An attachment will be made to objects within a certain proximity. You can move the people and objects about. Thats it for now. Some thinking about the model behind it will come.

Looks something like this:


This sits behind it:

globals[person-end;;used to work out who is talking
        object-end ;;used to work object I am talking to
]

undirected-link-breed[attachments attachment]

breed[people person ] ;; we have people
breed[objects object] ;; we have objects

;;;;;;;;;                                 
;; Its the Body massage machine GO    
;;;;;;;;

to go
    tick ;;tock
     ask links [die] ;;end conversations
     ask people [start-attachment] ;;start conversations
     
    if mouse-down? [ ;;is the mouse down, move person or object
    let candidate min-one-of turtles [distancexy mouse-xcor mouse-ycor]
    if [distancexy mouse-xcor mouse-ycor] of candidate < 1 [
      ;; The WATCH primitive puts a "halo" around the watched turtle.
      watch candidate
      while [mouse-down?] [
        ;; If we don't force the display to update, the user won't
        ;; be able to see the turtle moving around.
        display
        ;; The SUBJECT primitive reports the turtle being watched.
        ask subject [ setxy mouse-xcor mouse-ycor ]
      ]
      ;; Undoes the effects of WATCH.  Can be abbreviated RP.
      reset-perspective
    ]
  ]
     
     
end

;;;;;;;;;;;;;
;; DOING PROCEDURES
;;;;;;;;;;;;;

to start-attachment ;;turtle procedure
  ask people [create-attachment]
end


;;;;;;
;; UPDATE PROCEDURES
;;;;;

to update-people 

end

;;;;;;
;; DOING PROCEDURES
;;;;;;

to create-attachment
  
 
     create-attachments-with other objects  in-radius 15 [ ;;create the conversations
         set person-end end1
         set object-end end2   
         
             ifelse link-length < 5[
             ;;do something  
             ;;else kill it
             ] 
             ;;else
             [
               
             ]
         
              
     ]

end


;;;;;;;;
;;; SETUP PROCEDURES
;;;;;;;;

to setup
  ca ;;clear everything  
  setup-people ;;add people
  setup-objects ;;add objects
end

to setup-people
  create-people starting-people  ;;create as many as slider says
    [ setxy random-xcor random-ycor ;;bung them in random places
      set shape "person" ;;set them as people
      set size 4
      ask people[update-people] ;;
    ]
end

to setup-objects
  create-objects starting-objects  ;;create as many as slider says
    [ setxy random-xcor random-ycor ;;bung them in random places
      set shape "computer workstation" ;;set them as people
      set size 4 ;;
    ]
end

ċ
basic.nlogo
(13k)
David Sherlock,
7 Feb 2012, 07:29
Comments