void Start() { PathFinder2 pathfinder2 = FindObjectOfType <PathFinder2>(); var path2 = pathfinder2.GetPath2(); StartCoroutine(FollowPath2(path2)); }
private void hexgridPanel_MouseClick() { MapBoard.Path = PathFinder2.FindPath( MapBoard.StartHex, MapBoard.GoalHex, MapBoard ); }
static void Main(string[] args) { int y = 0; if (showWork) { Console.SetWindowSize(185, 50); } foreach (var line in File.ReadAllLines("input.txt")) { if (showWork) { Console.WriteLine(line); } bool[] b = new bool[line.Length]; for (int i = 0; i < line.Length; i++) { b[i] = false; char c = line[i]; if (c >= '0' && c <= '9') { coords.Add(new Point((int)(c - '0'), (int)i, (int)y)); } else if (c == '#') { b[i] = true; } } space.Add(b); y++; } coords = coords.OrderBy(f => f.Id).ToList(); if (showWork) { Console.Clear(); Console.ForegroundColor = ConsoleColor.White; Console.SetCursorPosition(0, 0); } for (int fromId = 0; fromId < coords.Count; fromId++) { Point from = coords.Single(f => f.Id == fromId); for (int toId = 0; toId < fromId; toId++) { Point to = coords.Single(f => f.Id == toId); if (showWork) { Thread.Sleep(2000); PrintSpace(); PrintCoordLocation(from); PrintCoordLocation(to); Console.SetCursorPosition(0, 0); Thread.Sleep(1000); } var finder = new PathFinder2(from, to); var distance = finder.GetDistance(); if (showWork) { finder.ReconstructPath(); } coords.Single(f => f.Id == fromId).Distances.Add(toId, distance); // Console.WriteLine("{0} -> {1}: {2}", fromId, toId, distance); if (fromId != toId) { // Console.WriteLine("{0} -> {1}: {2}", toId, fromId, distance); coords.Single(f => f.Id == toId).Distances.Add(fromId, distance); } } } Console.WriteLine("Built graph"); int answer = new RouteFinder(coords).BestRoute(); Console.WriteLine(answer); }