在下面的代码中,当我打印变量,制度时,我得到了" A"或者" D",但是当我打印制度或制度时,我获得[" A"]或[" D"]。
相关代码是:
patches-own [
regimep
]
governments-own [
regime
]
citizens-own [
regimec
]
...
to set-governments
ask governments [
...
ifelse random 100 < democracies% [set regime "D"] [set regime "A"]
ifelse regime = "D" [set shape "star"] [set shape "circle"]
...
]
end
to set-citizens
ask citizens [
let x governments with [idgov = [idcit] of myself] ;; idgov is a variable of the breed governments and idcit is a variable for citizens
set regimec [regime] of x
]
end
to set-patches
ask patches [
let x governments with [idgov = [idpat] of myself]
set regimed [regime] of x
]
end
这些括号来自哪里?我需要能够在没有括号的情况下打印变量。 谢谢你的帮助。
答案 0 :(得分:1)
括号是因为你的变量是一个列表而不是一个元素。
let x governments with [idgov = [idpat] of myself]
set regimed [regime] of x
governments with [idgov = [idpat] of myself]
是代理集。话虽如此,x也是代理集。
对于代理集,报告包含值的列表 代理集中每个代理的记者(按随机顺序)。
我认为您希望x成为单个代理。
试试这个
let x one-of governments with [idgov = [idpat] of myself]
set regimed [regime] of x
同样,政权也有同样的问题。