1

我在 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.

有没有使用set 朝向 heading比使用face更好的情况?

4

1 回答 1

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 ]

(在现实生活中,你可能会做一些不同的事情,但我希望这能传达这一点。)

于 2013-04-14T15:36:50.620 回答