void func(chessboard *chess, int depth,int turn,Vector2i* bestmove,Vector2i start,Vector2i end) { Computer temp; if(turn==2) //If the computer is playing for player 2 then calling minSearch and trying to find largest value of board for each value returned by minsearch { int value = temp.minSearch( depth-1 , *chess ,-INFINITY,INFINITY); //Finding all the minimum values of board if( value > bestvalue ) //Selecting the best move by finding the maximum of the values obtained { bestvalue = value; bestmove[0].x = start.x; bestmove[0].y = start.y; bestmove[1].x = end.x; bestmove[1].y = end.y; } } else //Opposite of that for player 1 { int value = temp.maxSearch( depth-1 , *chess,-INFINITY,INFINITY ); //Finds all maximum values of board if( value < bestvalue ) //Selects the lowest of those values { bestvalue = value; bestmove[0].x = start.x; bestmove[0].y = start.y; bestmove[1].x = end.x; bestmove[1].y = end.y; } } delete chess; //Chess board obtained is deleted as no longer needed }