Esempio n. 1
0
 public bool DoesContain(Node n)
 {
     //bool total = true;
     foreach (Node temp in Nodes)
     {
         bool t = true;
         List<Person> tempList = new List<Person>();
         tempList.AddRange(temp.persons);
         foreach (Person p in n.persons)
         {
             Person tempPerson = tempList.FirstOrDefault(per => per.type == p.type && per.state == p.state);
             if (!(tempPerson.state == p.state && tempPerson.type == p.type))
             {
                 t = false;
             }
             tempList.Remove(tempPerson);
         }
         if (t)
             return false;
     }
     return true;
 }
Esempio n. 2
0
 public bool reconstruct_path(Node current_node, Node start)
 {
     if (current_node.cameFrom != null)
     {
         reconstruct_path(current_node.cameFrom, start);
         total.Add(current_node);
         return true;
     }
     else
     {
         total.Add(current_node);
         if (current_node == start)
             return true;
         return false;
     }
 }
Esempio n. 3
0
 private List<int> neighbour_nodes(Node x)
 {
     List<int> neighbours = new List<int>();
     foreach (Edge edge in graph.Edges)
     {
         if (edge.isDirected)
         {
             if (edge.FromNode == x.Id)
                 neighbours.Add(edge.ToNode);
         }
         else
         {
             if (edge.FromNode == x.Id)
                 neighbours.Add(edge.ToNode);
             else if (edge.ToNode == x.Id)
                 neighbours.Add(edge.FromNode);
         }
     }
     return neighbours;
 }
Esempio n. 4
0
 private Node lowestF_Score(Node goal, double g_Score)
 {
     double f_score = 0;
     Node lowest = null;
     foreach (Node temp in openSet)
     {
         if (lowest == null)
         {
             lowest = temp;
             double tempg_Score = g_Score + dist_between(temp, goal);
             double temph_Score = heuristic_estimate_of_distance(temp, goal);
             f_score = tempg_Score + temph_Score;
         }
         else
         {
             double tempg_Score = g_Score + dist_between(temp, goal);
             double temph_Score = heuristic_estimate_of_distance(temp, goal);
             double tempf_score = tempg_Score + temph_Score;
             if (tempf_score < f_score)
             {
                 lowest = temp;
                 f_score = tempf_score;
             }
         }
     }
     return lowest;
 }
Esempio n. 5
0
        private bool isNeighbour(Node neighbour, Node current)
        {
            foreach (Edge edge in graph.Edges)
            {
                if (edge.isDirected)
                {
                    if (edge.FromNode == neighbour.Id && edge.ToNode == current.Id)
                        return true;

                }
                else
                {
                    if (edge.FromNode == neighbour.Id && edge.ToNode == current.Id)
                        return true;
                    else if (edge.ToNode == neighbour.Id && edge.FromNode == current.Id)
                        return true;
                }
            }
            return false;
        }
Esempio n. 6
0
 private double heuristic_estimate_of_distance(Node start, Node goal)
 {
     //manhattan distance
     //return (start.position.x - goal.position.x) + (start.position.y - goal.position.y);
     return 0;
 }
Esempio n. 7
0
 private double dist_between(Node x, Node y)
 {
     return 0;
     //return Math.Sqrt(Math.Pow(x.position.Length(), 2) + Math.Pow(y.position.Length(), 2));
 }
Esempio n. 8
0
 public void AddNode(int id, State mOne, State mTwo, State mThree, State kOne, State kTwo, State kThree, State Boat)
 {
     Node n = new Node(id, mOne, mTwo, mThree, kOne, kTwo, kThree, Boat);
     Nodes.Add(n);
 }
Esempio n. 9
0
 public void AddNode(Node n)
 {
     Nodes.Add(n);
 }