本文整理汇总了C++中Position::Col方法的典型用法代码示例。如果您正苦于以下问题:C++ Position::Col方法的具体用法?C++ Position::Col怎么用?C++ Position::Col使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Position
的用法示例。
在下文中一共展示了Position::Col方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ShowCellState
void Maze::ShowCellState(const Position &p, const CellState dist) const
{
const char CurPosChar = '+'; // Current position display character
const unsigned curPosX = 35; // X location to display current position
const unsigned curPosY = 2; // Y location to display current position
const char PathMarkChar = 'P'; // Mark the path if found.
// Display the numeric current position (x, y).
gotoxy( curPosX, curPosY);
cout << "Position: (" << p.Col() << ", " << p.Row() << ")";
// Display the new distance.
gotoxy(CellWidth*p.Col() + ColOffset, CellHeight*p.Row() + RowOffset);
// Wait and then change and display the new cell mark character.
Delay(MsPerSec/speed);
cout.width(CellWidth-1);
if (dist == PathCell)
// If cell is on the shortest path, display the PathMarkChar.
cout << PathMarkChar;
else
// Otherwise, display the cell's distance from the start.
cout << dist;
}
示例2: State
CellState Maze::State(const Position &cellPos) const
{
// If the position is off the grid, it is illegal.
if (cellPos.Row() < 0 || cellPos.Row() >= GridSize)
return Obstacle;
if (cellPos.Col() < 0 || cellPos.Col() >= GridSize)
return Obstacle;
// Start and goal are considered open.
if ( cell[cellPos.Row()][cellPos.Col()] == StartCell ||
cell[cellPos.Row()][cellPos.Col()] == GoalCell)
return Open;
// Use the stored cell distance.
return cell[cellPos.Row()][cellPos.Col()];
}
示例3: Mark
void Maze::Mark(const Position &p, const CellState newState)
{
logFile << "Mark (" << p.Row() << ", " << p.Col() << ") = " << newState << endl;
// Mark the cell with its new distance.
cell[p.Row()][p.Col()] = newState;
#if NoGraphics
// Wait and then change and display the new cell mark character.
Delay(MsPerSec/speed);
cout << endl;
Show();
#else
ShowCellState(p, newState);
#endif
}
示例4: IsOpen
bool Maze::IsOpen(const Position &cellPos) const
{
// If the position is off the grid, it is illegal.
if (cellPos.Row() < 0 || cellPos.Row() >= GridSize)
return false;
if (cellPos.Col() < 0 || cellPos.Col() >= GridSize)
return false;
// The start and goal cells are open until visited.
if (cell[cellPos.Row()][cellPos.Col()] == StartCell) // 10-16-2003 - gpc
return true;
if (cell[cellPos.Row()][cellPos.Col()] == GoalCell) // 10-16-2003 - gpc
return true;
// Use the stored cell state.
return cell[cellPos.Row()][cellPos.Col()] == Open;
}
示例5: ShowCell
void Maze::ShowCell(const Position &p, const CellState state) const
{
const unsigned MsPerSec = 1000; // Number of ms. in one second
const char CurPosChar = '+'; // Current position display character
const unsigned curPosX = 15; // X location to display current position
const unsigned curPosY = 2; // Y location to display current position
// Display the numeric current position (x, y).
gotoxy( curPosX, curPosY);
cout << "Position: (" << p.Col() << ", " << p.Row() << ")";
// Display the new state.
gotoxy(p.Col()+1, p.Row()+1);
// Wait and then change and display the new state character.
// Delay(MsPerSec/speed);
cout << state;
}
示例6: MarkPathCell
void Maze::MarkPathCell(const Position &p)
{
cell[p.Row()][p.Col()] = PathCell;
#if NoGraphics
Show();
#else
ShowCell(p, PathCell);
#endif
// Wait and then change and display the new state character.
Delay(MsPerSec/speed);
}