Пример #1
0
        // $G$ CSS-999 (-3) 5 function parameters
        private void calculateNumOfPointsToPlayersAndGetTheWinner(out int o_PointsToWinnerInCurrentGame, out int o_PointsToLosserInCurrentGame, out string o_StrTheWinnerOfTheCurrentGame, out int o_GeneralPointsOfTheWinner, out int o_GeneralPointsOfTheLosser)
        {
            o_PointsToWinnerInCurrentGame = 0;
            o_PointsToLosserInCurrentGame = 0;
            o_GeneralPointsOfTheWinner    = 0;
            o_GeneralPointsOfTheLosser    = 0;

            m_OthelloGameBoard.CountAndUpdateHowManySignalsOnBoardFromAnyKind();
            OthelloGamePlayer.ePlayerColorTypes theWinnerOfTheCurrentGame = m_OthelloGameRules.CheckWhoIsTheWinnerOfTheCurrentGame(m_OthelloGameBoard, m_FirstPlayer, m_SecondPlayer);

            m_OthelloGameBoard.GetTheNumOfPointsPlayersInThisGame(theWinnerOfTheCurrentGame, out o_PointsToWinnerInCurrentGame, out o_PointsToLosserInCurrentGame, m_FirstPlayer, m_SecondPlayer);

            if (theWinnerOfTheCurrentGame == OthelloGamePlayer.ePlayerColorTypes.Empty)
            {
                o_StrTheWinnerOfTheCurrentGame = "No Winner";
            }
            else
            {
                // Convert from Enum to string
                o_StrTheWinnerOfTheCurrentGame = Enum.GetName(typeof(OthelloGamePlayer.ePlayerColorTypes), theWinnerOfTheCurrentGame);
            }

            if (theWinnerOfTheCurrentGame == OthelloGamePlayer.ePlayerColorTypes.Black)
            {
                o_GeneralPointsOfTheWinner = m_FirstPlayer.PlayerTotalPoints;
                o_GeneralPointsOfTheLosser = m_SecondPlayer.PlayerTotalPoints;
            }
            else
            {
                o_GeneralPointsOfTheWinner = m_SecondPlayer.PlayerTotalPoints;
                o_GeneralPointsOfTheLosser = m_FirstPlayer.PlayerTotalPoints;
            }
        }
Пример #2
0
 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);
         }
     }
 }
Пример #3
0
 private void changeTurnToTheOtherPlayer()
 {
     if (m_CurrentSignalTurn == OthelloGamePlayer.ePlayerColorTypes.Black)
     {
         m_CurrentSignalTurn = OthelloGamePlayer.ePlayerColorTypes.White;
     }
     else
     {
         m_CurrentSignalTurn = OthelloGamePlayer.ePlayerColorTypes.Black;
     }
 }
Пример #4
0
        public OthelloGameBoardForm(OthelloGameBoard i_OthelloGameBoard, OthelloGamePlayer i_FirstPlayer, OthelloGamePlayer i_SecondPlayer)
        {
            InitializeComponent();

            m_GameBoardSize     = i_OthelloGameBoard.OtheloGameBoardMatrixDimension;
            m_OthelloGameRules  = new OthelloGameRules(m_GameBoardSize, i_SecondPlayer);
            m_OthelloGameBoard  = i_OthelloGameBoard;
            m_FirstPlayer       = i_FirstPlayer;
            m_SecondPlayer      = i_SecondPlayer;
            m_CurrentSignalTurn = OthelloGamePlayer.ePlayerColorTypes.Black;
            m_ButtonsMatrix     = new ButtonWithPositionInMatrix[m_GameBoardSize, m_GameBoardSize];
        }
Пример #5
0
        public bool CheckTheUserChoiseIsLegal(OthelloGamePlayer.ePlayerColorTypes i_CurrentSignalTurn, OthelloGameBoard i_OtheloGameBoard, int[] i_PositionFromUserInTheBoard)
        {
            int  rowInputIndex = i_PositionFromUserInTheBoard[0], columnInputIndex = i_PositionFromUserInTheBoard[1];
            bool userPositinChoiseIsLegal = true;

            if (m_AllCurrentLegalMovesMatrix[rowInputIndex, columnInputIndex] != i_CurrentSignalTurn)
            {
                userPositinChoiseIsLegal = !userPositinChoiseIsLegal;
            }

            return(userPositinChoiseIsLegal);
        }
Пример #6
0
        public OthelloGamePlayer.ePlayerColorTypes GetTheOppositeSignal(OthelloGamePlayer.ePlayerColorTypes i_MySignalType)
        {
            OthelloGamePlayer.ePlayerColorTypes playerSignalToReturn;

            if (i_MySignalType == OthelloGamePlayer.ePlayerColorTypes.Black)
            {
                playerSignalToReturn = OthelloGamePlayer.ePlayerColorTypes.White;
            }
            else
            {
                playerSignalToReturn = OthelloGamePlayer.ePlayerColorTypes.Black;
            }

            return(playerSignalToReturn);
        }
Пример #7
0
        public static OthelloGamePlayer.ePlayerColorTypes GetTheOppositeColor(OthelloGamePlayer.ePlayerColorTypes i_MySignalColor)
        {
            OthelloGamePlayer.ePlayerColorTypes theOppositeColor;

            if (i_MySignalColor == OthelloGamePlayer.ePlayerColorTypes.White)
            {
                theOppositeColor = OthelloGamePlayer.ePlayerColorTypes.Black;
            }
            else
            {
                theOppositeColor = OthelloGamePlayer.ePlayerColorTypes.White;
            }

            return(theOppositeColor);
        }
Пример #8
0
        private void currentPlayerCanPlayThisTurn()
        {
            OthelloGamePlayer.ePlayerColorTypes opponentPlayerName = m_OthelloGameBoard.GetTheOppositeSignal(m_CurrentSignalTurn);

            if ((m_SecondPlayer.StateGame != OthelloGameBoard.eGameTypes.Computer) || (m_SecondPlayer.StateGame == OthelloGameBoard.eGameTypes.Computer && opponentPlayerName == OthelloGamePlayer.ePlayerColorTypes.White))
            {   // Game against another player - display messages or Game against the computer and now it's my turn and the computer after me have nothing to do - so display a message about it only
                // Convert from Enum to string
                string strTheOpponentPlayerName = Enum.GetName(typeof(OthelloGamePlayer.ePlayerColorTypes), opponentPlayerName);

                MessageBox.Show(string.Format("You have another turn! cause your opponent({0}) has nothing to do", strTheOpponentPlayerName), k_TitleToMessageBox, MessageBoxButtons.OK, MessageBoxIcon.Information);

                displayTheCurrentOptionsCellsToChooseInBoard();
            }
            else if (m_SecondPlayer.StateGame == OthelloGameBoard.eGameTypes.Computer && opponentPlayerName == OthelloGamePlayer.ePlayerColorTypes.Black)
            {
                // Game against the computer and now it's the computer turn and I need play after him and have nothing to do - don't display a message about it and give another turn to computer
                checkIfTheOtherPlayerIsComputerAndPlay();
            }
        }
Пример #9
0
 public void GetTheNumOfPointsPlayersInThisGame(OthelloGamePlayer.ePlayerColorTypes i_TheWinnerOfTheCurrentGame, out int o_PointsToWinnerInCurrentGame, out int o_PointsToLosserInCurrentGame, OthelloGamePlayer i_FirstPlayer, OthelloGamePlayer i_SecondPlayer)
 {
     if (i_TheWinnerOfTheCurrentGame == OthelloGamePlayer.ePlayerColorTypes.Black)
     {
         i_FirstPlayer.PlayerTotalPoints++;
         o_PointsToWinnerInCurrentGame = this.NumOfFirstPlayerSignalsOnBoard;
         o_PointsToLosserInCurrentGame = this.NumOfSecondPlayerSignalsOnBoard;
     }
     else if (i_TheWinnerOfTheCurrentGame == OthelloGamePlayer.ePlayerColorTypes.White)
     {
         i_SecondPlayer.PlayerTotalPoints++;
         o_PointsToWinnerInCurrentGame = this.NumOfSecondPlayerSignalsOnBoard;
         o_PointsToLosserInCurrentGame = this.NumOfFirstPlayerSignalsOnBoard;
     }
     else
     {
         o_PointsToWinnerInCurrentGame = (m_OtheloGameBoardMatrixDimension * m_OtheloGameBoardMatrixDimension) / 2;
         o_PointsToLosserInCurrentGame = o_PointsToWinnerInCurrentGame;
     }
 }
Пример #10
0
        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);
        }
Пример #11
0
        private bool checkIfLegalMovesMatrixEmptyFromNextSignalTurn(OthelloGamePlayer.ePlayerColorTypes i_NextSignalTurn, OthelloGameBoard i_OtheloGameBoard)
        {
            bool legalMovesMatrixEmptyFromCurrentSignalTurn = true;

            for (int i = 0; i < i_OtheloGameBoard.OtheloGameBoardMatrixDimension; i++)
            {
                for (int j = 0; j < i_OtheloGameBoard.OtheloGameBoardMatrixDimension; j++)
                {
                    /* In case the 'LegalMovesMatrix' contains atleast one signal type -
                     * so it's mean that the current player can play this turn */

                    if (this.m_AllCurrentLegalMovesMatrix[i, j] == i_NextSignalTurn)
                    {
                        legalMovesMatrixEmptyFromCurrentSignalTurn = !legalMovesMatrixEmptyFromCurrentSignalTurn;
                        i = i_OtheloGameBoard.OtheloGameBoardMatrixDimension;
                        break;
                    }
                }
            }

            return(legalMovesMatrixEmptyFromCurrentSignalTurn);
        }
Пример #12
0
        public void PutSignalInTheRequiredUserPositionOnBoard(OthelloGameBoard i_OtheloGameBoard, OthelloGamePlayer.ePlayerColorTypes i_CurrentSignalTurn, params int[] i_PositionFromUserInTheBoard)
        {
            int rowInputIndex = i_PositionFromUserInTheBoard[0], columnInputIndex = i_PositionFromUserInTheBoard[1];

            // Put the signal in the game board
            i_OtheloGameBoard.OtheloGameBoardMatrix[rowInputIndex, columnInputIndex] = i_CurrentSignalTurn;

            changeAllTheOpponentSignalsYouBlockOnBoard(i_OtheloGameBoard, i_CurrentSignalTurn, rowInputIndex, columnInputIndex);
        }
Пример #13
0
 private void startNewGame()
 {
     m_CurrentSignalTurn = OthelloGamePlayer.ePlayerColorTypes.Black;
     m_OthelloGameBoard.InitializeOtheloGameBoard();
     initTheButtonsMatrix();
 }
Пример #14
0
        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
                }
            }
        }
Пример #15
0
        private bool checkIfLegalMoveAndUpdateLegalMovesMatrix(OthelloGameBoard i_OtheloGameBoard, OthelloGamePlayer.ePlayerColorTypes i_CurrentSignalTurn, int i_RowIndex, int i_ColumnIndex)
        {
            bool itIsLegalMove = true;

            if (i_OtheloGameBoard.OtheloGameBoardMatrix[i_RowIndex, i_ColumnIndex] != OthelloGamePlayer.ePlayerColorTypes.Empty)
            {
                itIsLegalMove = !itIsLegalMove;
            }
            else
            {
                itIsLegalMove = checkEightPossibleSidesAroundCellOnBoard(i_OtheloGameBoard, i_CurrentSignalTurn, i_RowIndex, i_ColumnIndex);
            }

            return(itIsLegalMove);
        }
Пример #16
0
        private bool checkEightPossibleSidesAroundCellOnBoard(OthelloGameBoard i_OtheloGameBoard, OthelloGamePlayer.ePlayerColorTypes i_CurrentSignalTurn, int i_RowIndex, int i_ColumnIndex)
        {
            const bool v_GoodSideToBlockTheOpponent          = true;
            bool       atLeastOneOfTheSidesIsPossibleToBlock = true;
            int        atLeastOneOfTheSidesIsOk = 0;

            // By 'rowIndexToMoveAround' and 'columnIndexToMoveAround' indexes you can check all the eight sides around you
            for (int rowIndexToMoveAround = -1; rowIndexToMoveAround <= 1; rowIndexToMoveAround++)
            {
                for (int columnIndexToMoveAround = -1; columnIndexToMoveAround <= 1; columnIndexToMoveAround++)
                {
                    // Irellevent to check my position - only check the cells around me
                    if (rowIndexToMoveAround == 0 && columnIndexToMoveAround == 0)
                    {
                        continue;
                    }

                    if (checkNextSignalInSpecificSideOppositeAndTheRowEndWithMySignalType(i_OtheloGameBoard, i_CurrentSignalTurn, i_RowIndex, i_ColumnIndex, rowIndexToMoveAround, columnIndexToMoveAround) == v_GoodSideToBlockTheOpponent)
                    {
                        atLeastOneOfTheSidesIsOk = 1;
                        rowIndexToMoveAround     = 2;
                        break;
                    }
                }
            }

            // No one of the eight sides is possible
            if (atLeastOneOfTheSidesIsOk == 0)
            {
                atLeastOneOfTheSidesIsPossibleToBlock = !atLeastOneOfTheSidesIsPossibleToBlock;
            }

            return(atLeastOneOfTheSidesIsPossibleToBlock);
        }
Пример #17
0
        private bool recursiveMethodToFlipOpponentSignalsYouBlockInSpecificRow(OthelloGameBoard i_OtheloGameBoard, OthelloGamePlayer.ePlayerColorTypes i_CurrentSignalTurn, int i_RowIndex, int i_ColumnIndex, int i_RowIndexToMoveAround, int i_ColumnIndexToMoveAround)
        {
            const bool v_StayInBoardBordersIfYouMoveOneSide       = true;
            const bool v_FlipOpponentSignalsYouBlockInSpecificRow = true;

            if (checkYouStayInBoardBordersIfYouMoveOneSideNextToPosition(i_OtheloGameBoard, i_CurrentSignalTurn, i_RowIndex, i_ColumnIndex, i_RowIndexToMoveAround, i_ColumnIndexToMoveAround) == !v_StayInBoardBordersIfYouMoveOneSide)
            {
                return(!v_FlipOpponentSignalsYouBlockInSpecificRow);
            }

            // If we arrive to empty cell before we have a signal type like me on board - so we can't block this row
            if (i_OtheloGameBoard.OtheloGameBoardMatrix[i_RowIndex + i_RowIndexToMoveAround, i_ColumnIndex + i_ColumnIndexToMoveAround] == OthelloGamePlayer.ePlayerColorTypes.Empty)
            {
                return(!v_FlipOpponentSignalsYouBlockInSpecificRow);
            }

            // If we arrive to cell with same signal type - so it is the end cell of blocking this row
            if (i_OtheloGameBoard.OtheloGameBoardMatrix[i_RowIndex + i_RowIndexToMoveAround, i_ColumnIndex + i_ColumnIndexToMoveAround] == i_CurrentSignalTurn)
            {
                return(v_FlipOpponentSignalsYouBlockInSpecificRow);
            }

            // Recursive calling
            if (recursiveMethodToFlipOpponentSignalsYouBlockInSpecificRow(i_OtheloGameBoard, i_CurrentSignalTurn, i_RowIndex + i_RowIndexToMoveAround, i_ColumnIndex + i_ColumnIndexToMoveAround, i_RowIndexToMoveAround, i_ColumnIndexToMoveAround) == v_FlipOpponentSignalsYouBlockInSpecificRow)
            {
                // Flip the signal cell on board
                i_OtheloGameBoard.OtheloGameBoardMatrix[i_RowIndex + i_RowIndexToMoveAround, i_ColumnIndex + i_ColumnIndexToMoveAround] = i_CurrentSignalTurn;
                return(v_FlipOpponentSignalsYouBlockInSpecificRow);
            }
            else
            {
                return(!v_FlipOpponentSignalsYouBlockInSpecificRow);
            }
        }
Пример #18
0
        private bool checkNextSignalInSpecificSideOppositeAndTheRowEndWithMySignalType(OthelloGameBoard i_OtheloGameBoard, OthelloGamePlayer.ePlayerColorTypes i_CurrentSignalTurn, int i_RowIndex, int i_ColumnIndex, int i_RowIndexToMoveAround, int i_ColumnIndexToMoveAround)
        {
            const bool v_StayInBoardBordersIfYouMoveOneSide            = true;
            const bool v_StayInBoardBordersIfYouMoveTwoSide            = true;
            const bool v_ThereIsMyTypeBlockSignalInTheEndOfThisSideRow = true;
            bool       nextSignalInSpecificSideOppositeAndTheRowEndWithMySignalType = true;
            int        doubleRowIndex    = i_RowIndexToMoveAround * 2;
            int        doubleColumnIndex = i_ColumnIndexToMoveAround * 2;

            if (checkYouStayInBoardBordersIfYouMoveOneSideNextToPosition(i_OtheloGameBoard, i_CurrentSignalTurn, i_RowIndex, i_ColumnIndex, i_RowIndexToMoveAround, i_ColumnIndexToMoveAround) == v_StayInBoardBordersIfYouMoveOneSide)
            {
                // If the close signal is the opposite of my type - so it is a possible side
                if (i_OtheloGameBoard.OtheloGameBoardMatrix[i_RowIndex + i_RowIndexToMoveAround, i_ColumnIndex + i_ColumnIndexToMoveAround] == i_OtheloGameBoard.GetTheOppositeSignal(i_CurrentSignalTurn))
                {
                    // If there is more than one signal after my signal in this side
                    if (checkThereIsAtLeastOneMoreSignalOnBoardTwoSidesFromMYPosition(i_OtheloGameBoard, i_CurrentSignalTurn, i_RowIndex, i_ColumnIndex, i_RowIndexToMoveAround, i_ColumnIndexToMoveAround) == v_StayInBoardBordersIfYouMoveTwoSide)
                    {
                        if (recursiveMethodToCheckThereIsMyTypeBlockSignalInTheEndOfThisSideRow(i_OtheloGameBoard, i_CurrentSignalTurn, i_RowIndex + doubleRowIndex, i_ColumnIndex + doubleColumnIndex, i_RowIndexToMoveAround, i_ColumnIndexToMoveAround) != v_ThereIsMyTypeBlockSignalInTheEndOfThisSideRow)
                        {
                            nextSignalInSpecificSideOppositeAndTheRowEndWithMySignalType = !nextSignalInSpecificSideOppositeAndTheRowEndWithMySignalType;
                        }
                    }
                    else
                    {
                        nextSignalInSpecificSideOppositeAndTheRowEndWithMySignalType = !nextSignalInSpecificSideOppositeAndTheRowEndWithMySignalType;
                    }
                }
                else
                {
                    nextSignalInSpecificSideOppositeAndTheRowEndWithMySignalType = !nextSignalInSpecificSideOppositeAndTheRowEndWithMySignalType;
                }
            }
            else
            {
                nextSignalInSpecificSideOppositeAndTheRowEndWithMySignalType = !nextSignalInSpecificSideOppositeAndTheRowEndWithMySignalType;
            }

            return(nextSignalInSpecificSideOppositeAndTheRowEndWithMySignalType);
        }
Пример #19
0
        public void PutAutomaticSignalOfCompuerOnBoard(OthelloGameBoard i_OtheloGameBoard, OthelloGamePlayer.ePlayerColorTypes i_CurrentSignalTurn)
        {
            const int k_NumOfIdxesInArray = 2;

            // Ref to Random object of the System class
            Random chooseRandomPossibleCellInTheBoard = new Random();

            int randomListIndex = chooseRandomPossibleCellInTheBoard.Next(m_ListWithTheCurrentPositinsOptionsOnBoardForRandom.Count);

            int[] positionInTheBoard = new int[k_NumOfIdxesInArray]; // Array to place the 2 indexes for the current turn of the computer

            checkIfTheRandomValueFromListIsRowOrColumnIndexInTheMatrix(positionInTheBoard, randomListIndex);

            // Put the computer signal on board according the random possible cell you have
            PutSignalInTheRequiredUserPositionOnBoard(i_OtheloGameBoard, i_CurrentSignalTurn, positionInTheBoard);
        }
Пример #20
0
        private bool recursiveMethodToCheckThereIsMyTypeBlockSignalInTheEndOfThisSideRow(OthelloGameBoard i_OtheloGameBoard, OthelloGamePlayer.ePlayerColorTypes i_CurrentSignalTurn, int i_RowIndex, int i_ColumnIndex, int i_RowIndexToMoveAround, int i_ColumnIndexToMoveAround)
        {
            const bool v_ThereIsMyTypeBlockSignalInTheEndOfThisSideRow = true;

            /* Stop conditions of the recursion :
             * If we out of the board bourders */
            if (i_RowIndex == i_OtheloGameBoard.OtheloGameBoardMatrixDimension || i_ColumnIndex == i_OtheloGameBoard.OtheloGameBoardMatrixDimension)
            {
                return(!v_ThereIsMyTypeBlockSignalInTheEndOfThisSideRow);
            }
            else if (i_OtheloGameBoard.OtheloGameBoardMatrix[i_RowIndex, i_ColumnIndex] == i_CurrentSignalTurn)
            {  // If we arrive to signal like my type - so stop and return true , cause bloking can be
                return(v_ThereIsMyTypeBlockSignalInTheEndOfThisSideRow);
            }
            else if (i_OtheloGameBoard.OtheloGameBoardMatrix[i_RowIndex, i_ColumnIndex] == OthelloGamePlayer.ePlayerColorTypes.Empty)
            { // If we arrive to empty place in board - so stop and return false , cause bloking can't be
                return(!v_ThereIsMyTypeBlockSignalInTheEndOfThisSideRow);
            }
            else if (i_RowIndex + i_RowIndexToMoveAround < 0 || i_RowIndex + i_RowIndexToMoveAround > i_OtheloGameBoard.OtheloGameBoardMatrixDimension)
            {  // In case the next step is out of rows bounds
                return(!v_ThereIsMyTypeBlockSignalInTheEndOfThisSideRow);
            }
            else if (i_ColumnIndex + i_ColumnIndexToMoveAround < 0 || i_ColumnIndex + i_ColumnIndexToMoveAround > i_OtheloGameBoard.OtheloGameBoardMatrixDimension)
            { // In case the next step is out of columns bounds
                return(!v_ThereIsMyTypeBlockSignalInTheEndOfThisSideRow);
            }

            // Recursive calling
            return(recursiveMethodToCheckThereIsMyTypeBlockSignalInTheEndOfThisSideRow(i_OtheloGameBoard, i_CurrentSignalTurn, i_RowIndex + i_RowIndexToMoveAround, i_ColumnIndex + i_ColumnIndexToMoveAround, i_RowIndexToMoveAround, i_ColumnIndexToMoveAround));
        }
Пример #21
0
        private bool checkYouStayInBoardBordersIfYouMoveOneSideNextToPosition(OthelloGameBoard i_OtheloGameBoard, OthelloGamePlayer.ePlayerColorTypes i_CurrentSignalTurn, int i_RowIndex, int i_ColumnIndex, int i_RowIndexToMoveAround, int i_ColumnIndexToMoveAround)
        {
            bool stayInBoardBordersIfYouMoveOneSide = true;

            if (i_RowIndex + i_RowIndexToMoveAround < 0 || i_RowIndex + i_RowIndexToMoveAround > i_OtheloGameBoard.OtheloGameBoardMatrixDimension - 1)
            { // Out of rows bounds
                stayInBoardBordersIfYouMoveOneSide = !stayInBoardBordersIfYouMoveOneSide;
            }
            else if (i_ColumnIndex + i_ColumnIndexToMoveAround < 0 || i_ColumnIndex + i_ColumnIndexToMoveAround > i_OtheloGameBoard.OtheloGameBoardMatrixDimension - 1)
            { // Out of columns bounds
                stayInBoardBordersIfYouMoveOneSide = !stayInBoardBordersIfYouMoveOneSide;
            }

            return(stayInBoardBordersIfYouMoveOneSide);
        }
Пример #22
0
        private bool checkThereIsAtLeastOneMoreSignalOnBoardTwoSidesFromMYPosition(OthelloGameBoard i_OtheloGameBoard, OthelloGamePlayer.ePlayerColorTypes i_CurrentSignalTurn, int i_RowIndex, int i_ColumnIndex, int i_RowIndexToMoveAround, int i_ColumnIndexToMoveAround)
        {
            bool stayInBoardBordersIfYouMoveOneSide = true;
            int  doubleRowIndex    = i_RowIndexToMoveAround * 2;
            int  doubleColumnIndex = i_ColumnIndexToMoveAround * 2;

            if ((i_RowIndex + doubleRowIndex < 0) || (i_RowIndex + doubleRowIndex) > i_OtheloGameBoard.OtheloGameBoardMatrixDimension - 1)
            {    // Out of rows bounds
                stayInBoardBordersIfYouMoveOneSide = !stayInBoardBordersIfYouMoveOneSide;
            }
            else if ((i_ColumnIndex + doubleColumnIndex) < 0 || (i_ColumnIndex + doubleColumnIndex) > i_OtheloGameBoard.OtheloGameBoardMatrixDimension - 1)
            {  // Out of columns bounds
                stayInBoardBordersIfYouMoveOneSide = !stayInBoardBordersIfYouMoveOneSide;
            }

            return(stayInBoardBordersIfYouMoveOneSide);
        }
Пример #23
0
        private void changeAllTheOpponentSignalsYouBlockOnBoard(OthelloGameBoard i_OtheloGameBoard, OthelloGamePlayer.ePlayerColorTypes i_CurrentSignalTurn, int i_RowInputIndex, int i_ColumnInputIndex)
        {
            const int k_MaxLowValueToAddColumnsAndRows  = -1;
            const int k_MaxHighValueToAddColumnsAndRows = 1;

            // By 'rowIndexToMoveAround' and 'columnIndexToMoveAround' indexes you can scan all the eight sides around you
            for (int rowIndexToMoveAround = k_MaxLowValueToAddColumnsAndRows; rowIndexToMoveAround <= k_MaxHighValueToAddColumnsAndRows; rowIndexToMoveAround++)
            {
                for (int columnIndexToMoveAround = k_MaxLowValueToAddColumnsAndRows; columnIndexToMoveAround <= k_MaxHighValueToAddColumnsAndRows; columnIndexToMoveAround++)
                {
                    // Irellevent to my position - only the cells around me
                    if (rowIndexToMoveAround == 0 && columnIndexToMoveAround == 0)
                    {
                        continue;
                    }

                    recursiveMethodToFlipOpponentSignalsYouBlockInSpecificRow(i_OtheloGameBoard, i_CurrentSignalTurn, i_RowInputIndex, i_ColumnInputIndex, rowIndexToMoveAround, columnIndexToMoveAround);
                }
            }
        }
Пример #24
0
 private void createCurrentLegalMovesMatrix(OthelloGameBoard i_OtheloGameBoard, OthelloGamePlayer.ePlayerColorTypes i_CurrentSignalTurn, OthelloGamePlayer i_SecondPlayer)
 {
     FillCurrentLegalMovesMatrix(i_OtheloGameBoard, i_CurrentSignalTurn, i_SecondPlayer);
 }