Ejemplo n.º 1
0
        private int countSequenceOfEatableOpponentPieces(int i_BoardRow, int i_BoardColumn, Direction.eVertical i_VerticalDirection, Direction.eHorizontal i_HorizontalDirection)
        {
            int numberOfEatenOpponentPieces = 0;
            int nextRow    = i_BoardRow;
            int nextColumn = i_BoardColumn;

            Player.ePlayerNumber opponentPlayer = m_CurrentGameState.CurrentPlayer.getOpponentPlayer();

            while (isLocationInBoardRange(nextRow, nextColumn) && opponentPlayer == m_CurrentGameState.GameBoard[nextRow, nextColumn].OccupyingPlayer)
            {
                numberOfEatenOpponentPieces++;
                nextRow    = nextRow + (int)i_VerticalDirection;
                nextColumn = nextColumn + (int)i_HorizontalDirection;
            }

            if (!isLocationInBoardRange(nextRow, nextColumn) || m_CurrentGameState.GameBoard[nextRow, nextColumn].OccupyingPlayer == Player.ePlayerNumber.None)
            {
                numberOfEatenOpponentPieces = 0;
            }

            return(numberOfEatenOpponentPieces);
        }
Ejemplo n.º 2
0
        private void flipSurroundedOpponentPieces(int i_BoardRow, int i_BoardColumn, Direction.eVertical i_VerticalDirection, Direction.eHorizontal i_HorizontalDirection)
        {
            int nextRow    = i_BoardRow + (int)i_VerticalDirection;
            int nextColumn = i_BoardColumn + (int)i_HorizontalDirection;

            Player.ePlayerNumber opponentPlayerNumber = m_CurrentGameState.CurrentPlayer.getOpponentPlayer();

            // Check if move is valid in this direction
            int opponentPiecesSurroundedInDirection = getMoveValueInDirection(i_BoardRow, i_BoardColumn, i_VerticalDirection, i_HorizontalDirection);

            if (opponentPiecesSurroundedInDirection > 0)
            {
                while (m_CurrentGameState.GameBoard[nextRow, nextColumn].OccupyingPlayer == opponentPlayerNumber)
                {
                    m_CurrentGameState.GameBoard.FlipCell(nextRow, nextColumn);
                    nextRow    = nextRow + (int)i_VerticalDirection;
                    nextColumn = nextColumn + (int)i_HorizontalDirection;
                }
            }
        }
Ejemplo n.º 3
0
        private int getMoveValueInDirection(int i_BoardRow, int i_BoardColumn, Direction.eVertical i_VerticalDirection, Direction.eHorizontal i_HorizontalDirection)
        {
            int moveValue  = 0;
            int nextRow    = i_BoardRow + (int)i_VerticalDirection;
            int nextColumn = i_BoardColumn + (int)i_HorizontalDirection;

            if (isLocationInBoardRange(nextRow, nextColumn))
            {
                if (isLocationOccupiedByAnOpponent(nextRow, nextColumn))
                {
                    moveValue = countSequenceOfEatableOpponentPieces(nextRow, nextColumn, i_VerticalDirection, i_HorizontalDirection);
                }
            }

            return(moveValue);
        }