A C function to play the Game of Nim
void playGame ( int piles [ ] , int n , int whoseTurn ) { cout << " GAME STARTS " struct move moves ; while ( gameOver ( piles , n ) == false ) { showPiles ( piles , n ) ; makeMove ( piles , n , & moves ) ; if ( whoseTurn == COMPUTER ) { cout << " COMPUTER ▁ removes " << moves . stones_removed << " stones ▁ from ▁ pile ▁ at ▁ index ▁ " << moves . pile_index << endl ; whoseTurn = HUMAN ; } else { cout << " HUMAN ▁ removes " << moves . stones_removed << " stones ▁ from ▁ pile ▁ at ▁ index ▁ " << moves . pile_index << endl ; whoseTurn = COMPUTER ; } } showPiles ( piles , n ) ; declareWinner ( whoseTurn ) ; return ; } void knowWinnerBeforePlaying ( int piles [ ] , int n , int whoseTurn ) { cout << " Prediction ▁ before ▁ playing ▁ the ▁ game ▁ - > ▁ " ; if ( calculateNimSum ( piles , n ) != 0 ) { if ( whoseTurn == COMPUTER ) cout << " COMPUTER ▁ will ▁ win STRNEWLINE " ; else cout << " HUMAN ▁ will ▁ win STRNEWLINE " ; } else { if ( whoseTurn == COMPUTER ) cout << " HUMAN ▁ will ▁ win STRNEWLINE " ; else cout << " COMPUTER ▁ will ▁ win STRNEWLINE " ; } return ; }