コード例 #1
0
 public override void Init(Node node, bool resetCounters)
 {
     closed.Clear();
     open.Clear();
     neighbors.Clear();
     if (resetCounters)
         agent.getCounters().reset();
     this.current = node;
     node.setParent(node.getParent());
     node.setCost(Node.Cost.Movement, 0);
     node.setCost(Node.Cost.Heuristic, node.getCost(Node.Cost.Movement) + node.getDistance(agent.getNode(Agent.NodeType.Target), heuristicMethod));
     open.Add(node);
 }
コード例 #2
0
        protected void takeStep(Agent agent, Node algorithmCurrent, Model model)
        {
            /* check to see if we didn't move at all */
            if (algorithmCurrent.isEqual(agent.getNode(Agent.NodeType.Current)))
                return;

            /* check to see if we need to backtrack */
            while (!algorithmCurrent.getParent().isEqual(agent.getNode(Agent.NodeType.Current)))
                algorithmCurrent = algorithmCurrent.getParent();

            /* take a step! */
            agent.setNode(Agent.NodeType.Current, algorithmCurrent);

            /* increment step counter */
            agent.getCounters().incSteps();
        }