我想给代理商提供收入属性,该代理商基于代理商停留的补丁值和滑块参数。
to setup
if pcolor = yellow
[sprout-resident 1
[set color sky
set shape "default"
set size 1
set-income
ask patch-here [set pcolor brown
set landuse "resident"
set is-bought? TRUE
set owner [who] of myself]]]
end
to set-income
ifelse land-price > buycapabilityhigh(this is the slider parametr) [set income "high"]
[ifelse land-price < buycapabilitymiddlle and land-price > buycapabilitylow [set income "middle"]
[if land-price < buycapabilitylow [set income "low"]]]
end
所以我想根据代理商所在的土地价格给出代理商类别高中低收入,并根据滑块设定的购买能力。请帮助提供建议,以编码这种机制。感谢
答案 0 :(得分:-1)
变量land-price
是补丁的属性吗?
如果是,那么我认为问题出在你的set-income
函数中。
您应该在if语句中使用[land-price] of patch-here
而不只是land-price
。
此外,就像艾伦说的那样。你可以使用一系列if语句。 它就像这样
if [land-price] of patch-here > ... [...]
if [land-price] of patch-here < ... and ... [...]
if [land-price] of patch-here < ... [...]