public void Play() { SelectPiecesAndPlayOrder(); board.AssignInitialPieces(computer); board.AssignInitialPieces(human); computer.UpdateValidMoves(board); human.UpdateValidMoves(board); string display = board.GetBoardStatus(); runner.DisplayInfoUser("\r\n" + display + "\r\n"); Move nextMove = null; Player nextPlayer = null; Player opponent = null; while (!bStaleMate && !bGameWon) { if (bTurnHuman) { nextPlayer = human; opponent = computer; nextMove = getMoveFromUser(); } else { nextPlayer = computer; opponent = human; nextMove = computer.PickRandomValidMove(); } if (nextMove == null) { if (bStaleMate) { display = board.GetBoardStatus(); runner.DisplayInfoUser("\r\n" + display); runner.DisplayInfoUser("\r\nStalemate: No more valid moves available. Game ends"); } else { runner.DisplayInfoUser("Bye " + human.GetName() + ". Play again anytime."); break; } } else { if (bTurnHuman) { runner.DisplayInfoUser("Moving your piece as you selected: " + nextMove.toString()); } else { runner.DisplayInfoUser("I am making my move: " + nextMove.toString()); } board.MakeNextMove(nextPlayer, nextMove); if (opponent.GetNumberActivePieces() == 0) { bGameWon = true; display = board.GetBoardStatus(); runner.DisplayInfoUser("\r\n" + display); runner.DisplayInfoUser("\r\nGame Over: Winner is " + nextPlayer.GetName()); break; } computer.UpdateValidMoves(board); human.UpdateValidMoves(board); if (opponent.GetNumberOfAvailableMoves() < 1) { bStaleMate = true; display = board.GetBoardStatus(); runner.DisplayInfoUser("\r\n" + display); runner.DisplayInfoUser("\r\nStalemate: No more moves left for " + opponent.GetName()); runner.DisplayInfoUser(human.GetName() + " has " + human.GetNumberActivePieces() + " pieces left"); runner.DisplayInfoUser(computer.GetName() + " has " + computer.GetNumberActivePieces() + " pieces left\r\n"); break; } display = board.GetBoardStatus(); runner.DisplayInfoUser("\r\n" + display + "\r\n"); } bTurnHuman = !bTurnHuman; } }