本文整理汇总了C++中TicTacToe::boardIsFull方法的典型用法代码示例。如果您正苦于以下问题:C++ TicTacToe::boardIsFull方法的具体用法?C++ TicTacToe::boardIsFull怎么用?C++ TicTacToe::boardIsFull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TicTacToe
的用法示例。
在下文中一共展示了TicTacToe::boardIsFull方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: playGame
void playGame( bool compGoesFirst )
{
TicTacToe t;
char compSide, humanSide;
int row, col;
if( compGoesFirst )
{
compSide = 'x'; humanSide = 'o';
doCompMove( t, true );
}
else
{
compSide = 'o'; humanSide = 'x';
}
while( !t.boardIsFull( ) )
{
do
{
printBoard( t, compSide, humanSide );
cout << endl << "Enter row and col (starts at 0): ";
cin >> row >> col;
} while( !t.playMove( TicTacToe::HUMAN, row, col ) );
cout << endl;
printBoard( t, compSide, humanSide );
cout << endl;
if( t.isAWin( TicTacToe::HUMAN ) )
{
cout << "Human wins!!" << endl;
break;
}
if( t.boardIsFull( ) )
{
cout << "Draw!!" << endl;
break;
}
doCompMove( t, false );
if( t.isAWin( TicTacToe::COMPUTER ) )
{
cout << "Computer wins!!" << endl;
break;
}
if( t.boardIsFull( ) )
{
cout << "Draw!!" << endl;
break;
}
}
printBoard( t, compSide, humanSide );
}