public char[] MaxMin(char[] val, int depth, bool isOpening) { MiniMaxOpening m = new MiniMaxOpening(); MiniMaxGame mid = new MiniMaxGame(); if (depth > 0) { depth--; List <char[]> child = new List <char[]>(); char[] minValue; char[] maxValue = new char[43]; child = isOpening ? m.GenerateAdd(val) : mid.GenerateMovesMidgameEndgame(val); //so that midgame move and generate add are called by passing parameter from calling function double v = Double.NegativeInfinity; for (int ind = 0; ind < child.Count; ind++) { minValue = MinMax(child[ind], depth, isOpening); double staticEstimate = isOpening ? m.StaticEstimationOpening(minValue) : mid.StaticEstimationMidEndGame(minValue, isOpening); if (v < staticEstimate) { v = staticEstimate; _MiniMaxEstimate = v; maxValue = child[ind]; } } return(maxValue); } else if (depth == 0) { _Positions_Evaluated++; } return(val); }
public List <char[]> GenerateBlackMove(char[] val, bool isOpening) { MiniMaxOpening m = new MiniMaxOpening(); MiniMaxGame mid = new MiniMaxGame(); char[] copyOfBoard = (char[])val.Clone(); for (int ind = 0; ind < copyOfBoard.Length; ind++) { if (copyOfBoard[ind] == 'W') { copyOfBoard[ind] = 'B'; continue; } if (copyOfBoard[ind] == 'B') { copyOfBoard[ind] = 'W'; } } List <char[]> blackMove = new List <char[]>(); List <char[]> blackMoveReplace = new List <char[]>(); blackMove = isOpening ? m.GenerateAdd(copyOfBoard) : mid.GenerateMovesMidgameEndgame(copyOfBoard); foreach (char[] b in blackMove) { char[] board = b; for (int i = 0; i < board.Length; i++) { if (board[i] == 'W') { board[i] = 'B'; continue; } if (board[i] == 'B') { board[i] = 'W'; } } blackMoveReplace.Add(b); } return(blackMoveReplace); }