本文整理汇总了C++中TicTacToe::clearBoard方法的典型用法代码示例。如果您正苦于以下问题:C++ TicTacToe::clearBoard方法的具体用法?C++ TicTacToe::clearBoard怎么用?C++ TicTacToe::clearBoard使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TicTacToe
的用法示例。
在下文中一共展示了TicTacToe::clearBoard方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
TicTacToe t;
// Movement variables
uint8_t x, y;
// BOOST Random generation support
//boost::mt19937 gen;
// Get current microseconds
struct timeval tv;
gettimeofday(&tv, NULL);
boost::mt19937 gen(tv.tv_usec);
boost::uniform_int<> dist(1, 3);
boost::variate_generator<boost::mt19937&,
boost::uniform_int<> > roll(gen, dist);
while(1) {
// Until we finish a game
while(false == t.finished())
{
do
{
// Move with PRNG
x = roll();
y = roll();
// Keep rolling until a proper space is found
if(t.occupied(x, y))
{
continue;
}
// Make a move
}
while(!t.move(x,y));
// A move succeeded!
// Print the board
t.printBoard();
}
// Game is finished. Who won?
t.printResult();
// Continue?
std::cout << "Press Enter to play again!\n";
// Get a single character from the keyboard
// If it's not a newline, break out of the while loop
if(std::cin.get() != '\n') break;
// Otherwise, clear the board and continue to the next game
t.clearBoard();
}
return EXIT_SUCCESS;
}