private void sendToFormOthloGameBoardTheCurrentValidMovesCoordinate(List <Coordinates> i_ValidMoveCoordinate)
        {
            Player playerTurn        = m_OtheloGameLogic.GetCurrentPlayerTurn();
            bool   isAgainstComputer = m_OtheloGameLogic.Player2.IsPlayerIsComputer; //need to send if isAgainstComputer to the func below, because we *dont* want to mark in gray computer cells options

            m_FormOthloGameBoard.ShowUpdatePlayerTurn(playerTurn);
            m_FormOthloGameBoard.MarkAndAllowToPressOnlyValidMovesPictureBox(i_ValidMoveCoordinate, playerTurn, isAgainstComputer);
        }
Beispiel #2
0
        public Node minimax(OtheloGameLogic i_BoardPiecesPosition, int i_Depth, bool i_MaximizingPlayer)
        {
            if (i_Depth == 0 || (!i_BoardPiecesPosition.GetCurrentPlayerTurn().IsHaveValidMove&& !i_BoardPiecesPosition.GetOpposingPlayer().IsHaveValidMove))
            {
                return(boardPositionAIScore(i_BoardPiecesPosition));
            }

            if (i_MaximizingPlayer)
            {
                int  maxEval    = int.MinValue;
                Node resMaxEval = new Node();
                resMaxEval.ScoreResult         = maxEval;
                resMaxEval.BoardPiecesPosition = i_BoardPiecesPosition;

                foreach (Coordinates child in i_BoardPiecesPosition.ValidCoordinatesToAddPieces())
                {
                    i_BoardPiecesPosition.SetInputPieceAndFlipAllTheInfluencedPieces(child, true);
                    Node eval = minimax(i_BoardPiecesPosition, i_Depth - 1, false);

                    if (maxEval < eval.ScoreResult)
                    {
                        resMaxEval.ScoreResult         = eval.ScoreResult;
                        resMaxEval.BoardPiecesPosition = i_BoardPiecesPosition;
                    }
                }
                return(resMaxEval);
            }
            else
            {
                int  minEval    = int.MaxValue;
                Node resMinEval = new Node();
                resMinEval.ScoreResult         = minEval;
                resMinEval.BoardPiecesPosition = i_BoardPiecesPosition;

                foreach (Coordinates child in i_BoardPiecesPosition.ValidCoordinatesToAddPieces())
                {
                    i_BoardPiecesPosition.SetInputPieceAndFlipAllTheInfluencedPieces(child, true);
                    Node eval = minimax(i_BoardPiecesPosition, i_Depth - 1, true);

                    if (minEval > eval.ScoreResult)
                    {
                        resMinEval.ScoreResult         = eval.ScoreResult;
                        resMinEval.BoardPiecesPosition = i_BoardPiecesPosition;
                    }
                }
                return(resMinEval);
            }
        }