Ejemplo n.º 1
0
int main()
{
  int nCoins,nTaken;
  playerT whoseTurn;

  GiveInstructions();
  nCoins=InitialCoins;
  whoseTurn=Computer;
  
  while(nCoins>1){
    printf("There are %d coins in the pile.\n",nCoins);
    switch(whoseTurn){
      case Human:
	nTaken=GetUserMove(nCoins);
	whoseTurn=Computer;
	break;
      case Computer:
	nTaken=ChooseComputerMove(nCoins);
	printf("I'wll take %d.\n",nTaken);
	whoseTurn=Human;
	break;
    }
    nCoins-=nTaken;
  }

 AnnounceWinner(nCoins,whoseTurn);
}
Ejemplo n.º 2
0
void Game::Play () {
    m_current = FIRST;
    m_board.Reset();

    while (IsPlaying()) {
        m_board.Display();
        m_players[m_current].MakeMove(m_board);
        SetNextPlayer();
    }

    m_board.Display();
    AnnounceWinner();
}