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; }
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; } }
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; }
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; }
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; }
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; }
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)); }
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); }
public void AddNode(Node n) { Nodes.Add(n); }