Netlogo 根据patch 和slider 参数的值赋予agent 的属性值(2)

Netlogo giving attribute value of agent based on value of patch and slider parameter (2)

所以,就像我之前的问题一样,我想制作代理商的购买能力属性。该属性由高中低三个类别组成。此购买能力有三个阈值,即 >= 50(低)、50>m<=100(中)和 >100(高),由两个滑块确定。此外,代理停留在具有土地价格属性的补丁上。因此,购买能力将由地价和门槛值决定。例如,如果代理人的补丁的土地价格大于 100(滑块 buycapability_high 值),则代理人的购买能力很高,等等,就像在程序中设置收入居民一样。下面的代码是我到目前为止使用的代码,用于创建或进行购买能力分类。但不幸的是,这段代码的结果是所有buycapability属性af agents are low,除此之外别无他法。即使地价大于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 

这已经是您的实际代码了吗?

我想那是因为你把补丁的值初始化放在了set-income之后。 这样,每次设置时,函数 set-income 将获得的补丁值都是 0,因为您还没有设置该值。

尝试将 set-income 放在代码的末尾

to setup
  ....
  ....
  ask patches [
    set value random-normal 6 10
    ...
    ...
  ]
  set-income2
end

希望这对您有所帮助。