private Tile addToBestPath(List<Tile> bestpath, Tile toadd, Tile prev) { int x = toadd.getX(); int y = toadd.getY(); int mapx = toadd.getMapX(); int mapy = toadd.getMapY(); int len = toadd.getLength(); if(DEBUG) Console.WriteLine("Adding tile at (" + mapx + "," + mapy + ") to bestpath! Cost is " + toadd.getTotalCost()); Tile newadd = new Tile(mapx, mapy, x, y, len, astarwaypoint, Color.White); newadd.setPrevious(prev); bestpath.Add(newadd); return newadd; }
private void addTile(Tile toadd, Tile prev, List<Tile> open, Tile goal) { toadd.setPrevious(prev); int distance = getCumulativeCost(toadd); toadd.addToTotalCost(distance + Math.Abs(toadd.getMapX() - goal.getMapX()) + Math.Abs(toadd.getMapY() - goal.getMapY())); if(DEBUG) Console.WriteLine("Adding node with cost " + toadd.getTotalCost() + " to open list"); open.Add(toadd); }