public Traktor_agent(int paliwo_poziom, int paliwo_max, PoleCollection plansza) { this.paliwo_poziom = paliwo_poziom; this.paliwo_max = paliwo_max; this.image.Source = new BitmapImage(new Uri(@"\Images\0.jpg", UriKind.RelativeOrAbsolute)); this.poz_x = 1; this.poz_y = 1; this.jednostkiNawozu = 10; this.plansza = plansza; this.pozycja = plansza.getPole(1, 1); }
private List <Pole> reconstructPath(int[,] cameFrom, Pole current, List <Pole> trasa) { if (cameFrom[current.x, current.y] != 0 && cameFrom[current.x, current.y] != -1 && trasa.Count == 0) { int tempX; int tempY; if (cameFrom[current.x, current.y] < 100) { tempX = cameFrom[current.x, current.y] % 10; if (tempX == 0) { tempX = 10; } tempY = (cameFrom[current.x, current.y] - tempX) / 10; } else { tempX = cameFrom[current.x, current.y] % 10; if (tempX == 0) { tempX = 10; } tempY = 10; } Pole current1 = plansza.getPole(tempX, tempY); if (current != null) { reconstructPath(cameFrom, current1, trasa); trasa.Add(current); } else { return(null); } } else if (cameFrom[current.x, current.y] == 0) { trasa.Add(current); } else { return(null); } //trasa.Reverse(); return(trasa); }