所以,就像我之前的问题一样,我想制作代理商的购买能力属性。该属性由三个类别组成,分别为高中和低。该购买能力的三个阈值是> = 50(低),50> m <= 100(中)和> 100(高),其由两个滑块确定。此外,代理停留在具有地价属性的补丁上。因此,购买能力将取决于地价和门槛值。例如,如果代理商补丁的地价大于100(滑块买入能力高值),那么代理商的买入能力就会很高,等等就像过程设定收入居民一样。下面的代码是我目前使用的代码,用于创建或进行购买能力分类。但不幸的是,这段代码的结果是代理商的所有购买能力属性都很低,除此之外别无他法。即使土地价格大于100,但应该很高,但事实并非如此。请帮我找出代码或其他可能出现的问题。
patches-own [value
empty]
turtles-own [income
myHouses
]
to setup
ca
;;Check inputs
let total-prob prob-rendah + prob-sedang + prob-tinggi
if (total-prob != 100 )
[
print (word "totalprob must sum to 100, but instead sum to " total-prob)
stop
]
create-turtles 100
[setxy random-pxcor random-pycor
set shape "default"
set size 1
;set-income
set-income2]
ask patches [set value random-normal 10 6
set pcolor brown + value
set empty true]
end
to set-income2
if[value] of patch-here > buycapability_middle and [value] of patch-here <= buycapability_high [set income "middle"]
if[value] of patch-here > buycapability_high [set income "high"]
if[value] of patch-here <= buycapability_middle [ set income "low"]
end
to go
let target []
ask turtles with [income = "low"]
[ let potential-target1 patches with [value < buycapability_middle and any? turtles-here = false]
set target min-one-of potential-target1 [value]
pen-down move-to target ask patch-here [set empty false]]
ask turtles with [income = "middle"]
[ let potential-target2 patches with [value < buycapability_high and value > buycapability_middle and any? turtles-here = false]
set target min-one-of potential-target2 [value]
pen-down move-to target ask patch-here [set empty false]]
ask turtles with [income = "high"]
[ let potential-target3 patches with [value > buycapability_high and any? turtles-here = false]
set target min-one-of potential-target3 [value]
pen-down move-to target ask patch-here [set empty false]]
end
答案 0 :(得分:2)
那已经是你的实际代码吗?
我认为这是因为您在set-income
之后将补丁的值初始化。
这样,每次设置时,函数set-income
将获得的补丁值将为0,因为您还没有设置该值。
尝试将set-income
放在代码的末尾
to setup
....
....
ask patches [
set value random-normal 6 10
...
...
]
set-income2
end
希望这会有所帮助。