本文整理汇总了C++中Cell::PrintInfo方法的典型用法代码示例。如果您正苦于以下问题:C++ Cell::PrintInfo方法的具体用法?C++ Cell::PrintInfo怎么用?C++ Cell::PrintInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cell
的用法示例。
在下文中一共展示了Cell::PrintInfo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PathExists
/**
*
* Checks whether a path exists between the starting and ending
* cells in the labyrinth
*
* This function does not actually search in the labyrinth.
* It just prepares and passes the necessary arguments to the
* PathExists_Internal() function, which does the actual search.
*
*
**/
bool Solver::PathExists(Board& board)
{
std::cout << "Let's try to find if a path exists!\n\n";
// First mark all cells as not visited.
// This is important, as another search may have been carried
// on the board
board.MarkAllCellsNotVisited();
// Now try to find the starting cell, if such exists
Cell* pStart = board.GetStart();
if(pStart == NULL)
{
// If there is no start cell, no search can be performed
std::cout << "There is no starting cell in the labyrinth!\n";
return false;
}
else
{
std::cout << "Starting from ";
pStart->PrintInfo();
std::cout << std::endl << std::endl;
return PathExists_Internal(board, board.GetStart());
}
}
示例2: PathExists_Internal
/**
*
* Uses Breadth-first search to check if there is a path
* between pStart and the target cell in the board.
*
*/
bool BfsSolver::PathExists_Internal(Board& board, Cell* pStart)
{
std::cout << "Solving with BFS\n\n";
std::queue<Cell*> cellQueue;
cellQueue.push(pStart);
Cell* pCurrent = NULL;
Cell* pNeghbour = NULL;
while( ! cellQueue.empty())
{
// Get the next element from the stack
pCurrent = cellQueue.front();
pCurrent->MarkVisited();
cellQueue.pop();
// Display some information
std::cout << "\n Queue size: " << cellQueue.size();
std::cout << "\n Popped ";
pCurrent->PrintInfo();
std::cout << std::endl;
if(pCurrent->IsTarget())
{
// If the target is found, then there is a path
return true;
}
else
{
// Otherwise keep looking
AddIfPassableAndNotVisited(cellQueue, pCurrent->GetLeftNeighbour());
AddIfPassableAndNotVisited(cellQueue, pCurrent->GetRightNeighbour());
AddIfPassableAndNotVisited(cellQueue, pCurrent->GetTopNeighbour());
AddIfPassableAndNotVisited(cellQueue, pCurrent->GetBottomNeighbour());
}
}
return false;
}