/* * int QuiescenceSearch(int alpha, int beta, bool isWhite, bool topLevel) { * SortedList<int, ushort> captureMoves = moveGenerator.GetMoves (true, false); * * if (captureMoves.Count == 0) { * nodesSearched ++; * int evaluation = Evaluate(); * if (topLevel) { * quiescenceScore = evaluation; * } * return Evaluate(); * } * * int value = int.MinValue; * if (isWhite) { // white is trying to attain the highest evaluation possible * * for (int i =0; i < captureMoves.Count; i ++) { * BoardGround.MakeMove(captureMoves[i]); * value = Math.Max(value,QuiescenceSearch(alpha, beta, false, false)); * alpha = Math.Max(alpha, value); * BoardGround.UnmakeMove(captureMoves[i]); * * if(topLevel && findingMoveForWhite) { // has searched full depth and is now looking at top layer of moves to select the best * if (value>quiescenceScore) { * quiescenceScore = value;; * } * } * * if (beta <= alpha) { // break * breakCount++; * break; * } * } * return value; * } * * // black is trying to obtain the lowest evaluation possible * value = int.MaxValue; * for (int i =0; i < captureMoves.Count; i ++) { * BoardGround.MakeMove(captureMoves[i]); * value = Math.Min(value,QuiescenceSearch(alpha, beta, true, false)); * beta = Math.Min(beta, value); * BoardGround.UnmakeMove(captureMoves[i]); * * if(topLevel && !findingMoveForWhite) { // has searched full depth and is now looking at top layer of moves to select the best * if (value<quiescenceScore) { * quiescenceScore = value;; * } * } * * if (beta <= alpha) { // break * breakCount++; * break; * } * } * * return value; * } */ public int Evaluate() { return(EvaluationGround.Evaluate()); }