gpt4 book ai didi

button - NetLogo: "stop"不能永远从另一个程序按钮吗?

转载 作者:行者123 更新时间:2023-12-05 03:03:25 26 4
gpt4 key购买 nike

我在下面简化了我的问题。当没有机器人时,我想停止执行永远的按钮“go”,我想从另一个过程(在本例中为“test”)调用它,如下所示:

to go
test
end

to test
if not any? robots [ stop ]
end

这样做的原因是我想在机器人死亡的地方调用 stop 以便我可以发送适当的用户消息。

最佳答案

遗憾的是,您必须重新组织您的代码,以便您调用 if not any? robots [ stop ] 为了满足以下条件:

查看文档:

A forever button can also be stopped from code. If the forever button directly calls a procedure, then when that procedure stops, the button stops. (In a turtle or patch forever button, the button won’t stop until every turtle or patch stops – a single turtle or patch doesn’t have the power to stop the whole button.)

引用:http://ccl.northwestern.edu/netlogo/docs/programming.html#buttons

stop This agent exits immediately from the enclosing procedure, ask, or ask-like construct (e.g. crt, hatch, sprout). Only the enclosing procedure or construct stops, not all execution for the agent.

引用:http://ccl.northwestern.edu/netlogo/docs/dict/stop.html

我不想发布的另一种 hacky 解决方案可能是在您提出错误然后停止的地方执行以下操作。

to go
carefully[test][error-message stop]
end
to test
if not any? robots [ error "no more robots!" ]
end

关于button - NetLogo: "stop"不能永远从另一个程序按钮吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54046900/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com