2013-04-14 3 views
1

J'ai utilisé visage dans NetLogo sans aucun problème, mais n'est pas vers tout de même? (Dans le contexte d'un agent faisant face à la direction d'un patch/Agent)Quelle est la différence entre le visage et vers?

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. 

Y at-il un scénario dans lequel l'aide mis vers la rubrique est mieux que d'utiliser visage?

Répondre

2

Y a-t-il des circonstances dans lesquelles vous aimeriez connaître le cap vers quelque chose sans vraiment vous tourner pour y faire face? Je suis sûr que vous pourriez penser à beaucoup. Un exemple serait de choisir entre deux positions possibles selon certains critères.

Disons que vous voulez faire face à l'un des deux agents, selon un vous oblige à tourner le moins:

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 ] 

(Dans la vraie vie, vous auriez probablement faire des choses un peu différemment, mais j'espère que cela porte le point à travers.)

+0

Je vois. J'ai été obsédé par l'utilisation de "vers" dans un contexte de "mise en route vers ...", c'est pourquoi je continue de le comparer à "face". Je comprends maintenant. Je vous remercie! – Gannicus

Questions connexes