private AvailableMove selectMove(List<AvailableMove> allMovesList, Piece[,] board, ref bool mate, string colour) { AvailableMove move = new AvailableMove(); if (allMovesList.Count > 0) { var maxRating = allMovesList.Max(x => x.Rating); move = allMovesList.Where(x => x.Rating == maxRating).First(); } else if (cf.isThreatened(uf.FindKing(colour, board), uf.OtherColour(colour), board)) { df.Checkmate(colour); mate = true; } else { df.Stalemate(); mate = true; } return move; }
private double evaluateChildren(MoveNode currentNode, int depth) { List<double> ratings = new List<double>(); foreach (MoveNode child in currentNode.Children) ratings.Add(child.Move.Rating); if (depth % 2 == 1) return ratings.Min(); else return ratings.Max(); }