/*private void ConfigureBestLocalePath(MapPath path) * { * var locale = path.Start; * if ((!bestLocalePaths.ContainsKey(locale.Index)) || (bestLocalePaths[locale.Index].Length < path.Length) || ((bestLocalePaths[locale.Index].Length == path.Length) && (bestLocalePaths[locale.Index].VerticalDrop < path.VerticalDrop))) || { || bestLocalePaths[locale.Index] = path; || } || ||}*/ private void AssessPath(MapPath mapPath) { if ((BestMapPath.Start.Index == 0) && (BestMapPath.End.Index == 0)) { BestMapPath = mapPath; UpdateConsole(); } else { if (mapPath.Length < BestMapPath.Length) { return; } if (mapPath.Length == BestMapPath.Length) { if (mapPath.VerticalDrop <= BestMapPath.VerticalDrop) { return; } } BestMapPath = mapPath; UpdateConsole(); } }
public void EvaluatePathsFromLocale(Locale locale) { if (localePathsEncountered.ContainsKey(locale.Index)) { return; } if ((locale.Value < BestMapPath.Length) || ((locale.Value == BestMapPath.Length) && (locale.Value <= BestMapPath.VerticalDrop))) { return; } var currentPath = new MapPath { Start = locale }; EvaluatePath(locale, currentPath); }
private void EvaluatePath(Locale assessLocale, MapPath currentMapPath) { /*if (bestLocalePaths.ContainsKey(assessLocale.Index)) * { * var bestLocalePath = bestLocalePaths[assessLocale.Index]; * currentMapPath.Length += bestLocalePath.Length; * currentMapPath.End = bestLocalePath.End; * AssessPath(currentMapPath); * ConfigureBestLocalePath(currentMapPath); * return; * }*/ localePathsEncountered[assessLocale.Index] = true; var viableNeighbours = map.GetViableNeighbours(assessLocale); if ((viableNeighbours == null) || (viableNeighbours.Count == 0)) { currentMapPath.Length++; currentMapPath.End = assessLocale; AssessPath(currentMapPath); //ConfigureBestLocalePath(currentMapPath); return; } currentMapPath.Length++; foreach (var viableNeighbour in viableNeighbours) { var path = new MapPath { Start = currentMapPath.Start, Length = currentMapPath.Length }; EvaluatePath(viableNeighbour, path); /*var pathFromNeighbour = new MapPath * { * Start = viableNeighbour, * End = path.End, * Length = path.Length- currentMapPath.Length * }; * ConfigureBestLocalePath(pathFromNeighbour);*/ } }
public GridMapEvaluator(GridMap map) { this.map = map; BestMapPath = new MapPath(); }