Netlogo:乌龟检查它是否能移动到一个有效的目标



我正在尝试模拟一个社区访问当地企业。有两种类型的斑块(家庭和企业(和海龟(人和主人(。该计划是,如果店主在营业区,人们可以参观商店,否则就会被视为关闭。

一天分为三个周期:上午、下午和晚上。所有的商店通常在上午和下午,但随机有一些店主在晚上回家。如果没有商店,店主就会回家。

运行了一段时间后,我得到了错误MOVE-TO预期的输入是一个代理,但却得到了NOBODY指向";如果其他";夜间移动命令的一部分。

谢谢你的帮助!

to go
morning-move ;Morning movement (First shopping phase)
tick
afternoon-move ;Afternoon movement (Second shopping phase)
tick
evening-move ;Evening movement (Return home)
tick
end
to morning-move
ask owners [move-to work-xy] ;make owners open their businesses
ask people [ifelse any? open-busi-patches with [any? owners-here and count people-here < MaxCapacity] ;This checks if there are open businesses
[ask people [move-to one-of open-busi-patches with [any? owners-here and count people-here < MaxCapacity]]] ;move people to businesses under capacity
[ask people [move-to home-xy]]]
ask open-busi-patches [set OpsProfit OpsProfit + count people-here] ;cumulative count of patrons
end
to afternoon-move
ask people [ifelse any? open-busi-patches with [count owners-here > 0 and count people-here < MaxCapacity] ;This checks 
[ask people [move-to one-of open-busi-patches with [any? owners-here and count people-here < MaxCapacity]]] ;move people to businesses under capacity
[ask people [move-to home-xy]]]
ask open-busi-patches [set OpsProfit OpsProfit + count people-here] ;cumulative count of patrons
end
to evening-move
ask n-of random count owners owners [move-to home-xy] ;This choses a random number of owners to stay open in the evening.
ask people [ifelse any? open-busi-patches with [any? owners-here and count people-here < MaxCapacity] ;This checks 
[ask people [move-to one-of open-busi-patches with [any? owners-here and count people-here < MaxCapacity]]] ;move people to businesses under capacity
[ask people [move-to home-xy]]]
ask open-busi-patches [set OpsProfit OpsProfit + count people-here] ;cumulative count of patrons
end

因此,这是给您错误(重新格式化(的代码

to afternoon-move
ask people
[ ifelse any? open-busi-patches with [count owners-here > 0 and count people-here < MaxCapacity ]
[ ask people ;;;; THIS LINE
[ move-to one-of open-busi-patches with [any? owners-here and count people-here < MaxCapacity]
]
]
[ ask people
[ move-to home-xy]
]
]
ask open-busi-patches [set OpsProfit OpsProfit + count people-here]
end

基本问题是,我所标记的这条线实际上是在转移人们,并耗尽开放的企业。因此,第一个条件测试的是最初是否有企业有空间,而且永远不会重新测试。

最新更新