private bool success(IAIGraphNode current) { Solution = reconstruct_path(current); IsComplete = true; IsSuccess = true; return(false); }
public GraphSolver(IEnumerable <T> sources, IEnumerable <T> destinations) { this.source = new DummySource(sources); destination = new HashSet <IAIGraphNode>(destinations.Cast <IAIGraphNode>()); openSet = new HashSet <IAIGraphNode>() { source }; closedSet = new HashSet <IAIGraphNode>(); cameFrom = new Dictionary <IAIGraphNode, IAIGraphNode>(); gScore = new Dictionary <IAIGraphNode, float>() { { source, 0 } } .WithDefault(k => float.PositiveInfinity); fScore = new Dictionary <IAIGraphNode, float>().WithDefault(s => destination.Min(d => heuristic_cost_estimate(s, d))); Solution = null; IsComplete = false; IsSuccess = false; }
private float cost_between(IAIGraphNode current, IAIGraphNode neighbor) { if (current is T && neighbor is T) { return(CostBetween((T)current, (T)neighbor)); } return(0); }
private float heuristic_cost_estimate(IAIGraphNode neighbor, IAIGraphNode d) { if (neighbor is T && d is T) { return(HeuristicCostEstimate((T)neighbor, (T)d)); } return(float.PositiveInfinity); }
private bool filter(IAIGraphNode arg) { if (arg is T) { return(FilterPath((T)arg)); } return(true); }
private IEnumerable <IAIGraphNode> getNeighbors(IAIGraphNode current) { if (current is T) { return(GetNeighbors((T)current).OfType <IAIGraphNode>()); } return(current.NextNodes); }
private IList <T> reconstruct_path(IAIGraphNode current) { var path = new List <T>(); if (current is T) { path.Add((T)current); } IAIGraphNode from; while (cameFrom.TryGetValue(current, out from)) { current = from; if (current is T) { path.Add((T)current); } } path.Reverse(); return(path); }