【发布时间】:2019-04-16 19:44:17
【问题描述】:
我的海龟是公司,他们拥有海龟,利润因公司而异,以及离岸?并重新安装?这是真的还是假的。
代码有些地方不对劲。我很难将 IF 和 AND 命令结合起来。如果标签的参数离岸?报告 = true 并且这些公司的利润低于报告离岸公司的利润? = false,比他们应该移动。代码的移动部分工作正常。请在下面找到我目前拥有的(错误报告)代码:
breed [ firms firm ]
firms-own [
profit
offshored? ;; reports either true or false
reshored? ;; reports either true or false
]
to setup
ask firms [
if offshored? true AND profit < [ profit ] of firms with [ offshored? = false ] [ ;; if the profit of an offshored firm is smaller than the lowest profit of firms at home, the decision to reshore is yes!
ask one-of turtles [ move-to one-of patches with [ pcolor = 58 and not any? turtles-here ] ] ;; the firm reshores
AND set reshored? true ] ] ;; the firm is now labelled as reshored
end
【问题讨论】:
标签: if-statement conditional-statements netlogo agent-based-modeling economics