Phoebe Bloomfield
Phoebe Bloomfield

Reputation: 21

Netlogo error message "people-movement in a observer context because people-movement is turtle only."

I keep getting this error message for fro my people-movemnt. I looked at my code which is trying to create water demand in a city. I couldn't figure out how to fix the code. I am trying to copy how people would move from home to work. I am trying to check the setup of people so the code is not finished but it won't let me check until I fix the ticks. Here is the code that deals with people-movement.

to setup-people
  ask patches[
  sprout-people population
  ask people[
        if random 100 < percent-female [set is-female? true]
   ask people [
    set random-number random 100]

    ask people
    [if random-number <= 31 [set age 10]]
    ask people
    [if ((random-number > 31) and (random-number <= 37)) [set age 25]]
    ask people
    [if ((random-number > 37) and (random-number <= 50)) [set age 35]]
    ask people
    [if ((random-number > 36) and (random-number <= 75)) [set age 45]]
    ask people
    [if ((random-number > 75) and (random-number <= 81)) [set age 55]]
    ask people
    [if ((random-number > 81) and (random-number <= 87)) [set age 65]]
     ask people
    [if ((random-number > 87) ) [set age 75]]

  ]]

end

to setup-daily-activies
      if age >= 18
      [ let cbd-pickup roads with [is-school? and not is-intersection?]
  let commercial-pickup roads with [is-commercial? and not is-intersection?]
  let residential-pickup roads with [is-high-residential? or is-low-residential? or is-mid-residential? and not is-intersection?]
  let cbd-dropoff roads with [is-school? and not is-intersection? and not is-traffic-light?]
  let commercial-dropoff roads with [
    is-commercial? and
    not is-intersection? and
    not is-traffic-light?
  ]
  let residential-dropoff roads with [
    is-high-residential? or is-low-residential? or is-mid-residential? and
    not is-intersection? and
    not is-traffic-light?
  ]


  generate-activity (runresult word "leave-home" current-phase) (residential-pickup) (commercial-dropoff)

  generate-activity (runresult word "leave-work" current-phase) (commercial-dropoff) (residential-dropoff)

    ]

end



;;;;;;;;;;;;;;;;;;;;;;
;;;; Global Clock ;;;;
;;;;;;;;;;;;;;;;;;;;;;
to report-current-phase
  ; there are a total of 24 hour in a day
  ; so in case of the counter is exceeding 24
  ; set the counter back to 0
  if ticks >= 1[
    set current-phase item phase-counter all-phases
    set phase-counter phase-counter + 1
    if phase-counter mod 24 = 0 [
    set daycounter daycounter + 1
  ]]
end
;;;;;;;;;;;;;;;;;;;;;
;;;; people movement ;;;;
;;;;;;;;;;;;;;;;;;;;;
to generate-activity [some-prob origin destination]
  if random-float 1 < some-prob [
    ask person origin [
        set destination-patch-passenger one-of destination
        set d-xcor [pxcor] of destination-patch-passenger
        set d-ycor [pycor] of destination-patch-passenger
    ]
  ]
end
to people-movement
    setup-daily-activies
  let current-xcor [xcor] of self
  let current-ycor [ycor] of self

  ; destination location coordintes
  let destination-xcor1 [d-xcor] of self
  let destination-ycor1 [d-ycor] of self
  setxy d-xcor d-ycor
end

I looked at all the different setup and go codes. I tried to ask people in daily activities but I think that would be an observer code so I tried to take that away but that doesn't change anything. This step is trying to move people depending on the time and the probably on a slider.

Upvotes: 0

Views: 36

Answers (1)

Charles
Charles

Reputation: 4168

It is hard to know exactly, as you haven't included the portion of the code that calls people-movement. However, people-movement calls setup-daily-activities, which refers to a variable called age. If age is in fact a turtles-own variable, then setup-daily-activities (and thus people-movement) has to be called by a turtle, as the error suggests. (The rest of that procedure also seems to refer to things that a turtle would do.) Check to see where people-movement is called and check back if the answer is not obvious.

Upvotes: 2

Related Questions