本文整理汇总了C++中Maze::getMazeWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ Maze::getMazeWidth方法的具体用法?C++ Maze::getMazeWidth怎么用?C++ Maze::getMazeWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Maze
的用法示例。
在下文中一共展示了Maze::getMazeWidth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: goEast
bool MazeSolver::goEast(Creature& myCreature, Maze& myMaze) {
// coming from the west
cout << "Trying to head East!" << endl;
if ((myCreature.getCrCol() + 1) < myMaze.getMazeWidth())
{
//get the state of the space to the east
char stateOfEast = myMaze.getSquareState(myCreature.getCrRow(), myCreature.getCrCol() + 1);
cout << "State of the East reads: " << stateOfEast << endl;
// and if space to the east is clear
if (stateOfEast == myMaze.getClearSymbol() || stateOfEast == myMaze.getPathSymbol()) // if the square is clear or on path, it has not been visited
{
cout << "Moving the creature east. " << endl;
myCreature.moveEast();
cout << "Movement is a success... Marking the path..." << endl;
myCreature.markAsPath();
cout << "Path Marked." << endl;
myMaze.display();
// if we're at the exit, we're done
if (isAtExit(myCreature, myMaze))
{
cout << "We've reached the end of the maze!" << endl;
success = true;
}
else
{
success = goNorth(myCreature, myMaze); // else try to go north again
if (!success)
{
success = goEast(myCreature, myMaze); // else try to go east
if (!success)
{
success = goSouth(myCreature, myMaze);// else try to go south
if (!success)
{
cout << "Heading back West!" << endl << endl;
myCreature.markAsVisited(); // else mark the square as visited
goWest(myCreature, myMaze); // and head back West
}
}
}
}
}
}
else success = false;
return success;
}