public TabuSearch(INeighbourFinder neighbourFinder, ITabuList tabuList, ILongTermMemory longTermMemory, ICostFinder costFinder, IAspirationCriteria aspirationCriteria, IStopCriteria stopCriteria, IStopCriteria noChange, IStopCriteria costLessThan) { this.neighbourFinder = neighbourFinder; this.tabuList = tabuList; this.longTermMemory = longTermMemory; this.costFinder = costFinder; this.aspirationCriteria = aspirationCriteria; this.stopCriteria = stopCriteria; this.noChange = noChange; this.costLessThan = costLessThan; }
public static List <Vector2> GetPath(this DesignerViewModel designer, Vector2 startPoint, Vector2 endPoint, INeighbourFinder neighbourFinder = null) { var points = new List <Vector2>(); try { var mapBuilder = new MapBuilder(); foreach (var item in designer.ConnectedComponents.ToList()) { mapBuilder.AddObstacle(item.Position - Vector2.One, item.Size + (Vector2.One * 2)); } mapBuilder.SetStart(startPoint); mapBuilder.SetEnd(endPoint); mapBuilder.SetDimensions(designer.Width, designer.Height); var mapResult = mapBuilder.Build(); if (!mapResult.Success) { throw new Exception(mapResult.Message); } var pathFinder = new PathFinder.Algorithm.PathFinder(mapResult.Map, neighbourFinder ?? DefaultNeighbourFinder.Straight(0.5f)); points.AddRange(pathFinder.FindPath()); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } return(points); }