问题描述
我需要找到代理程序前面的补丁与某个补丁(目标)之间的最小距离,以便选择能够创建最佳(最短)路径的补丁.原始的距离仅需要一个参数,因此我不能按原样使用此功能.
I need to find the minimum distance between patches in front of my agent to a certain patch (goal), in order to select the patch that would create the most optimal (shortest) path. The primitive distance only requires one argument so I can't use it as is for this function.
推荐答案
> c0> 原语只需要一个参数,是的,但这是一个补丁或乌龟原语":必须在特定代理程序的上下文中通过询问"它与另一个代理程序的距离来运行它,因此您可以想想它作为另一个参数运行的上下文.
The distance
primitive only requires one argument, yes, but it is a "patch or turtle primitive": it must be run in the context of a particular agent by "asking" it for its distance to another, so you can think of the context in which it run as another argument.
如果您想知道patch 0 0
和patch 1 1
之间的距离,可以写:
If you want to know the distance between patch 0 0
and patch 1 1
, you can write:
ask patch 0 0 [ show distance patch 1 1 ]
或者可能更有用:
[ distance patch 1 1 ] of patch 0 0
这篇关于如何计算两个面片之间的距离?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!