SoletekForce/Pathfinding/PathSearch.cs
/// <summary>
/// Executes a breath first search until either depthLimit has reached, target Cell
/// has been found or all accessible cells has been iterated
/// </summary>
/// <returns><c>true</c>, if target cell was found, <c>false</c> otherwise.</returns>
Executes a breath first search until either depthLimit has reached, target Cell
has been found or all accessible cells has been iterated
Executes a breath first search until either depthLimit has reached target Cell has been found or all accessible cells has been iterated
bool BreathFirstSearch()
		{
			while (frontier.Count > 0)
			{
				var current = frontier.Dequeue();
				if (current.data + 1 > depth)
				{
					if (TargetFound) return true;
					depth++;
				}
				if (depthLimit != -1 && depth > depthLimit)
				{
					frontier.Enqueue(current);
					return false;
				}
				foreach (var neighbourCell in map.GetNeighbours(current.Host))
				{
					PathNode neighbour = neighbourCell.Node;
					if (neighbour.data == -1 && CheckCell(neighbourCell))
					{
						neighbour.data = depth;
						TargetFound |= neighbourCell == targetLimit;
						frontier.Enqueue(neighbour);
					}
				}
			}
			return false;
		}
bool BreathFirstSearch ( ) { while ( frontier . Count > 0 ) { var current = frontier . Dequeue ( ) ; if ( current . data + 1 > depth ) { if ( TargetFound ) return true ; depth ++ ; } if ( depthLimit != - 1 && depth > depthLimit ) { frontier . Enqueue ( current ) ; return false ; } foreach ( var neighbourCell in map . GetNeighbours ( current . Host ) ) { PathNode neighbour = neighbourCell . Node ; if ( neighbour . data == - 1 && CheckCell ( neighbourCell ) ) { neighbour . data = depth ; TargetFound |= neighbourCell == targetLimit ; frontier . Enqueue ( neighbour ) ; } } } return false ; }
Executes a breath first search until either depthLimit has reached, target Cell
has been found or all accessible cells has been iterated
Executes a breath first search until either depthLimit has reached target Cell has been found or all accessible cells has been iterated
None