public OthelloGameRules(int i_SizeOfGameBoard, OthelloGamePlayer i_SecondPlayer) { m_AllCurrentLegalMovesMatrix = new OthelloGamePlayer.ePlayerColorTypes[i_SizeOfGameBoard, i_SizeOfGameBoard]; if (i_SecondPlayer.StateGame == OthelloGameBoard.eGameTypes.Computer) { m_ListWithTheCurrentPositinsOptionsOnBoardForRandom = new List <int>(); } }
public bool CheckIfPlayerHasOptionContinueToPlay(OthelloGamePlayer.ePlayerColorTypes i_NextSignalTurn, OthelloGameBoard i_OtheloGameBoard, OthelloGamePlayer i_SecondPlayer) { const bool v_LegalMovesMatrixEmptyFromCurrentSignalTurn = true; bool currentPlayerHasOptionToContinueThisTurn = true; ZeroTheLegalMovesMatrix(i_OtheloGameBoard); if (i_SecondPlayer.StateGame == OthelloGameBoard.eGameTypes.Computer && m_ListWithTheCurrentPositinsOptionsOnBoardForRandom.Count != 0) { m_ListWithTheCurrentPositinsOptionsOnBoardForRandom.Clear(); } createCurrentLegalMovesMatrix(i_OtheloGameBoard, i_NextSignalTurn, i_SecondPlayer); if (checkIfLegalMovesMatrixEmptyFromNextSignalTurn(i_NextSignalTurn, i_OtheloGameBoard) == v_LegalMovesMatrixEmptyFromCurrentSignalTurn) { currentPlayerHasOptionToContinueThisTurn = !currentPlayerHasOptionToContinueThisTurn; } return(currentPlayerHasOptionToContinueThisTurn); }
public bool CheckIfTwoPlayersCanMoveInTheGame(OthelloGameBoard i_OtheloGameBoard, OthelloGamePlayer i_SecondPlayer) { bool twoPlayersCanMoveInTheGame = true; const bool v_FirstPlayerCanContinueTheGame = true; const bool v_SecondPlayerCanContinueTheGame = true; if (this.CheckIfPlayerHasOptionContinueToPlay(OthelloGamePlayer.ePlayerColorTypes.White, i_OtheloGameBoard, i_SecondPlayer) != v_FirstPlayerCanContinueTheGame || this.CheckIfPlayerHasOptionContinueToPlay(OthelloGamePlayer.ePlayerColorTypes.Black, i_OtheloGameBoard, i_SecondPlayer) != v_SecondPlayerCanContinueTheGame) { twoPlayersCanMoveInTheGame = !twoPlayersCanMoveInTheGame; } return(twoPlayersCanMoveInTheGame); }
public OthelloGamePlayer.ePlayerColorTypes CheckWhoIsTheWinnerOfTheCurrentGame(OthelloGameBoard i_OtheloGameBoard, OthelloGamePlayer i_FirstPlayer, OthelloGamePlayer i_SecondPlayer) { OthelloGamePlayer.ePlayerColorTypes theWinnerOfTheCurrentGame; if (i_OtheloGameBoard.NumOfFirstPlayerSignalsOnBoard > i_OtheloGameBoard.NumOfSecondPlayerSignalsOnBoard) { theWinnerOfTheCurrentGame = OthelloGamePlayer.ePlayerColorTypes.Black; } else if (i_OtheloGameBoard.NumOfFirstPlayerSignalsOnBoard < i_OtheloGameBoard.NumOfSecondPlayerSignalsOnBoard) { theWinnerOfTheCurrentGame = OthelloGamePlayer.ePlayerColorTypes.White; } else { // FirstPlayer signals == SecondPlayer signals on board theWinnerOfTheCurrentGame = OthelloGamePlayer.ePlayerColorTypes.Empty; } i_FirstPlayer.PlayerCurrentGamePoints = i_OtheloGameBoard.NumOfFirstPlayerSignalsOnBoard; i_SecondPlayer.PlayerCurrentGamePoints = i_OtheloGameBoard.NumOfSecondPlayerSignalsOnBoard; return(theWinnerOfTheCurrentGame); }
private void fillSpecificCellInLegalMovesMatrix(OthelloGameBoard i_OtheloGameBoard, OthelloGamePlayer.ePlayerColorTypes i_CurrentSignalTurn, int i_RowIndex, int i_ColumnIndex, OthelloGamePlayer i_SecondPlayer) { const bool v_LegalMove = true; if (checkIfLegalMoveAndUpdateLegalMovesMatrix(i_OtheloGameBoard, i_CurrentSignalTurn, i_RowIndex, i_ColumnIndex) == v_LegalMove) { // Fill the specific cell in the legal moves matrix with the current signal turn this.m_AllCurrentLegalMovesMatrix[i_RowIndex, i_ColumnIndex] = i_CurrentSignalTurn; // Fill the List with the relevent matrix indexes cell - For the random action later if (i_SecondPlayer.StateGame == OthelloGameBoard.eGameTypes.Computer) { m_ListWithTheCurrentPositinsOptionsOnBoardForRandom.Add(i_RowIndex); // Put the row index of cell in the even place of the list m_ListWithTheCurrentPositinsOptionsOnBoardForRandom.Add(i_ColumnIndex); // Put the column index of cell in the odd place of the list } } }
public void FillCurrentLegalMovesMatrix(OthelloGameBoard i_OtheloGameBoard, OthelloGamePlayer.ePlayerColorTypes i_CurrentSignalTurn, OthelloGamePlayer i_SecondPlayer) { for (int i = 0; i < i_OtheloGameBoard.OtheloGameBoardMatrixDimension; i++) { for (int j = 0; j < i_OtheloGameBoard.OtheloGameBoardMatrixDimension; j++) { fillSpecificCellInLegalMovesMatrix(i_OtheloGameBoard, i_CurrentSignalTurn, i, j, i_SecondPlayer); } } }
private void createCurrentLegalMovesMatrix(OthelloGameBoard i_OtheloGameBoard, OthelloGamePlayer.ePlayerColorTypes i_CurrentSignalTurn, OthelloGamePlayer i_SecondPlayer) { FillCurrentLegalMovesMatrix(i_OtheloGameBoard, i_CurrentSignalTurn, i_SecondPlayer); }