本文整理汇总了C++中Maze::getGrid方法的典型用法代码示例。如果您正苦于以下问题:C++ Maze::getGrid方法的具体用法?C++ Maze::getGrid怎么用?C++ Maze::getGrid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Maze
的用法示例。
在下文中一共展示了Maze::getGrid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestCreateMaze
/**
* Verify that the maze can be created with a specific size
* @params pTestData - test object to store the maze in so it
* will get cleaned up in all cases.
* @returns error string if there was an error
*/
string MazeTest::TestCreateMaze(TestUnit::tTestData* pTestData) {
Maze* pMaze = (Maze*)pTestData->testObj;
// Get the grid so we can verify it
Maze::tGrid* grid = pMaze->getGrid();
// The grid was created
if (grid == NULL) {
return "Maze grid is not defined.";
}
// the dimensions were set.
if (grid->dim.width != 10 || grid->dim.height != 5 || grid->dim.depth != 7) {
return "Maze grid dimensions do not match those specified.";
}
// They layout pointer is set
if (grid->layout == NULL) {
return "Maze grid layout was not defined.";
}
// All cells were intitlized to empty, and with their correct coords
for (int x=0; x < grid->dim.width; x++) {
for (int y=0; y < grid->dim.height; y++) {
for (int z=0; z < grid->dim.depth; z++) {
Maze::tCell cell = grid->layout[x][y][z];
if (cell.state != Maze::CELL_EMPTY || cell.coord.x != x || cell.coord.y != y || cell.coord.z != z) {
return "Maze grid layout not initialized correctly.";
}
}
}
}
return "";
}
示例2: TestSetCellState
/**
* Verifies that cells in a grid can have their state set.
* @params pTestData - test object to store the maze in so it
* will get cleaned up in all cases.
* @returns error string if there was an error
*/
string MazeTest::TestSetCellState(TestUnit::tTestData* pTestData) {
Maze* pMaze = (Maze*)pTestData->testObj;
Maze::tCoord chg1 = Maze::tCoord(0, 0, 0);
Maze::tCoord chg2 = Maze::tCoord(5, 3, 1);
Maze::tCoord chg3 = Maze::tCoord(9, 4, 6);
Maze::tCoord noChg = Maze::tCoord(2, 2, 2);
// Update the cells, start, end, and inner item
if (!pMaze->updateCell(chg1, Maze::CELL_SOLID) ||
!pMaze->updateCell(chg2, Maze::CELL_OCCUPIED) ||
!pMaze->updateCell(chg3, Maze::CELL_EXIT)) {
return "Failed to update valid cell in maze";
}
Maze::tGrid* pGrid = pMaze->getGrid();
// Verify the changes only occred where desired
Maze::tCell* cell = pGrid->at(noChg);
if (cell->state != Maze::CELL_EMPTY) {
return "Cell state change when it wasn't supposed to.";
}
// Verify changes
cell = pGrid->at(chg1);
if (cell->state != Maze::CELL_SOLID) {
return "Unable to set cell to solid state.";
}
cell = pGrid->at(chg2);
if (cell->state != Maze::CELL_OCCUPIED) {
return "Unable to set cell to occupied state.";
}
cell = pGrid->at(chg3);
if (cell->state != Maze::CELL_EXIT) {
return "Unable to set cell to exit state.";
}
return "";
}