面子和朝向有什么区别?

时间:2013-04-14 02:41:48

标签: simulation netlogo multi-agent

我在NetLogo中使用了 face 没有任何问题,但是方向不一样? (在面向补丁/代理方向的代理人的背景下)

towards

towards agent


Reports the heading from this agent to the given agent.

If wrapping is allowed by the topology and the wrapped distance (around the edges of the world) is shorter,     towards will use the wrapped path.

Note: asking for the heading from an agent to itself, or an agent on the same location, will cause a runtime error.

set heading towards turtle 1
;; same as "face turtle 1"
See also face.

是否有任何使用设置为标题比使用 face 更好的情况?

1 个答案:

答案 0 :(得分:2)

在某些情况下,您是否希望知道朝向某个方向而不实际转向面对它?我相信你能想到很多。一个示例情况是根据某些标准在两个可能的标题之间进行选择。

假设您要面对两个代理商中的一个,无论哪个代理商要求您转换最少的代理商:

let first-heading towards first-agent
let second-heading towards second-agent

; compare my current heading to the two calculated headings:
let first-angle subtract-headings heading first-heading
let second-angle subtract-headings heading second-heading

if-else abs first-angle < abs second-angle
  [ rt first-angle ]
  [ rt second-angle ]

(在现实生活中,你可能会做一些不同的事情,但我希望这可以解决这个问题。)