Exemplo n.º 1
0
        private Tuple <int, Tuple <int, int> > alphaBetaMin(int scoreParent, bool whiteTurn, int depth = 5)
        {
            List <Tuple <int, int> > possibleMove = this.GetPossibleMove(whiteTurn);

            if (depth == 0 || this.GameFinish == true || possibleMove.Count == 0)
            {
                return(new Tuple <int, Tuple <int, int> >(evaluateGameState(!whiteTurn), null));
            }

            int minVal             = int.MaxValue;
            Tuple <int, int> minOp = null;

            foreach (Tuple <int, int> move in possibleMove)
            {
                OthelloBoard tempOthelloBoard = new OthelloBoard(this);
                tempOthelloBoard.PlayMove(move.Item1, move.Item2, false);
                Tuple <int, Tuple <int, int> > score = tempOthelloBoard.alphaBetaMax(minVal, !whiteTurn, depth - 1);
                if (score.Item1 < minVal)
                {
                    minVal = score.Item1;
                    minOp  = move;
                    if (minVal < scoreParent)
                    {
                        break;
                    }
                }
            }
            return(new Tuple <int, Tuple <int, int> >(minVal, minOp));
        }
Exemplo n.º 2
0
 public OthelloBoard(OthelloBoard other)
 {
     this.theBoard = (int[, ])other.GetBoard().Clone();
     this.computeScore();
 }