private double EvaluateMove(Move move, Game game) { var gameWithMove = game.Move(move.ChessPiece, move.ToX, move.ToY); var opponents = move.ChessPiece.IsWhite ? gameWithMove.BlackChessPieces : gameWithMove.WhiteChessPieces; var nextOpponentMoves = _moveGenerator.NextMoves(opponents, gameWithMove).ToArray(); var friends = (move.ChessPiece.IsWhite ? gameWithMove.WhiteChessPieces : gameWithMove.BlackChessPieces).Where(x => x.Id != move.ChessPiece.Id); var nextFriendMoves = _moveGenerator.NextMoves(friends, gameWithMove).ToArray(); var ctx = new ChessContext() { Move = move, GameBeforeMove = game, GameAfterMove = gameWithMove, NextOpponentMoves = nextOpponentMoves, NextFriendMoves = nextFriendMoves }; var rating = _knowledge.EvaluateMove(ctx); return(rating); }
public double EvaluateMove(ChessContext ctx) { var rating = _ratings.Select(f => f(ctx)).Sum(); return(rating); }