2013-04-14 105 views
1

我已經使用面對在NetLogo沒有任何問題,但不是只是一樣嗎? (在朝向貼片/劑的方向上對置的試劑的上下文中)面對和朝向有什麼區別?

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. 

是否有其中使用設置朝向標題比使用更好任何情形?

回答

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 ] 

(在現實生活中,你可能會做的事情有點不同,但我希望這帶着點。)

+0

我明白了。我被固定在「朝向......」的「朝着...」的用法上,這就是爲什麼我一直將其與「正面」進行比較的原因。我現在明白了。謝謝! – Gannicus