我不断收到来自我的人民运动的错误消息。我查看了我的代码,该代码试图在城市中创造用水需求。我不知道如何修复代码。我正在尝试模仿人们如何从家里搬到工作场所。我正在尝试检查人员的设置,因此代码尚未完成,但在修复蜱虫之前它不会让我检查。这是处理人员移动的代码。
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
end
我查看了所有不同的设置和运行代码。我试图在日常活动中询问人们,但我认为这将是一个观察者代码,所以我试图将其拿走,但这并没有改变任何东西。
很难确切地知道,因为您没有包含调用
people-movement
的代码部分。然而,people-movement
调用setup-daily-activities
,它引用了一个名为age
的变量。如果年龄实际上是海龟自己的变量,那么 setup-daily-activities
(因此 people-movement
)必须由海龟调用,如错误所示。 (该过程的其余部分似乎也指的是乌龟会做的事情。)检查 people-movement
被调用的位置,如果答案不明显,请回来检查。