예제 #1
0
 public override float estimate(Node node)
 {
     if (node.safeNode)
         return GameMode.movement.arcs[goal.id, node.id];
     else
         return GameMode.movement.arcs[goal.id, node.id] * GameMode.movement.arcs[goal.id, node.id];
 }
예제 #2
0
파일: Scent.cs 프로젝트: jennydvr/ColorWars
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="id">ID of the node</param>
        /// <param name="intensity">Intensity</param>
        /// <param name="order">When was this parameter called</param>
        public Scent(int id, float intensity, Node origin, int order)
            : base(id, intensity, origin, order)
        {
            this.graph = GameMode.smells;
            this.location = graph.nodes[id].point;

            // If the origin is null, you are generating the smell
            if (this.origin == null)
                this.origin = graph.nodes[id];

            // The factor will be the inverse of the maximum cost
            maximum = 0;

            for (int i = 0; i != graph.nodes.Count; ++i)
                for (int j = 0; j != graph.nodes.Count; ++j)
                    if (!float.IsPositiveInfinity(graph.arcs[i, j]) & graph.arcs[i, j] > maximum)
                        maximum = graph.arcs[i, j];

            this.factor = maximum * 0.125f;
        }
예제 #3
0
파일: Node.cs 프로젝트: jennydvr/ColorWars
 /// <summary>
 /// Calculates the ditance between two nodes
 /// </summary>
 /// <param name="first">First node</param>
 /// <param name="second">Second node</param>
 /// <returns>Float that represents the distance</returns>
 public static float Distance(Node first, Node second)
 {
     return Vector2.Distance(first.point, second.point);
 }
예제 #4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="goal">Goal node for this heuristic</param>
 public SafestHeuristic(Node goal)
     : base(goal)
 {
 }