// find path from top to down in I axis
 public bool RunOne()
 {
     // Generate a random map
     _byteMap = _mapGen.Generate();
     // Build node map
     _nodeMap = new Node[_mapInput.Height, _mapInput.Width];
     for (int i = 0; i < _mapInput.Height; i++)
     {
         for (int j = 0; j < _mapInput.Width; j++)
         {
             _nodeMap[i, j]   = new Node();
             _nodeMap[i, j].I = i;
             _nodeMap[i, j].J = j;
             if (_byteMap[j, i] == 0)
             {
                 _nodeMap[i, j].Value = true;
                 // Mark end node
                 if (i >= _mapInput.Height - 1 - _pathInput.Jump)
                 {
                     _nodeMap[i, j].EndNode = true;
                 }
             }
         }
     }
     // Loop through all possible starting nodes
     for (int i = 0; i <= _pathInput.Jump; i++)
     {
         for (int j = 0; j < _mapInput.Width; j++)
         {
             if (_nodeMap[i, j].Value && !_nodeMap[i, j].Used)                     // Check if node is set and not used
             {
                 // PriorityQueue = 1, DepthFirst = 2
                 if (_pathInput.SearchAlgorithm == 1)
                 {
                     if (PriorityQueueSearch(_nodeMap[i, j]))
                     {
                         return(true);
                     }
                 }
                 else if (_pathInput.SearchAlgorithm == 2)
                 {
                     if (DepthFirstSearch(_nodeMap[i, j]))
                     {
                         return(true);
                     }
                 }
             }
         }
     }
     return(false);
 }
Beispiel #2
0
 // find path from top to down in I axis
 public bool RunOne()
 {
     // Generate a random map
     return(RunOne(_mapGen.Generate()));
 }