Exemplo n.º 1
0
 public RouteSearch(int capacity)
 {
     //this._openList = new List<AsPoint>();
     //this._closeList = new List<AsPoint>();
     //
     this._openList            = new NumHashlist(capacity);
     this._closeList           = new NumHashlist(capacity);
     this._reachableStepsStack = new Stack <IEnumerable <AsPoint> >();
 }
Exemplo n.º 2
0
        public static void DrawRoute(NumHashlist closeList, List <AsPoint> route, byte[,] map, int column, int row)
        {
            var tempMap = new byte[row, column];

            Array.Copy(map, tempMap, row * column);
            //
            var tempCloseList = closeList.Where(p => p != null).ToList();// new List<AsPoint>(closeList);

            tempCloseList.RemoveAt(0);
            tempCloseList.ForEach(p => tempMap[p.X, p.Y] = 8);
            //
            var tempRoute = new List <AsPoint>(route);

            if (tempRoute.Count > 0)
            {
                tempRoute.RemoveAt(0);
            }
            if (tempRoute.Count > 1)
            {
                var lastPoint = tempRoute.Last();
                if (tempMap[lastPoint.X, lastPoint.Y] == 3)
                {
                    tempRoute.RemoveAt(tempRoute.Count - 1);
                }
            }
            tempRoute.ForEach(p => tempMap[p.X, p.Y] = 4);
            //
            Console.Clear();

            Console.Write("    ");
            for (var index = 0; index < column; index++)
            {
                Console.Write(index.ToString().PadLeft(2, ' ') + ",");
            }
            Console.Write("\n    ");
            for (var index = 0; index < column; index++)
            {
                Console.Write("___");
            }
            Console.WriteLine();
            for (var j = 0; j < row; j++)
            {
                Console.Write(j + " | ");
                for (var i = 0; i < column; i++)
                {
                    if (tempMap[j, i] == 0)
                    {
                        Console.Write("  ,");
                    }
                    else
                    {
                        Console.Write(tempMap[j, i] + " ,");
                    }
                }
                Console.WriteLine();
            }
        }