private bool IsValid(Chessboard chessboard, GameMove move, GameHistory gameHistory)
        {
            var chessPiece = chessboard.GetChessPieceOrDefault(move.From);

            if (!chessPiece.HasValue)
            {
                return(false);
            }

            var chessBoardCopy  = (Chessboard)chessboard.Clone();
            var gameHistoryCopy = (GameHistory)gameHistory.Clone();

            gameHistoryCopy.Add(move, chessPiece.Value.Owner, chessBoardCopy);
            chessBoardCopy.Move(move);

            var kingCoordinate = chessBoardCopy.GetCoordinate(new ChessPiece {
                Owner = chessPiece.Value.Owner, Type = ChessPieceType.King
            });
            var isKingInDanger = IsCoordinateInDanger(chessBoardCopy, chessPiece.Value.Owner, gameHistoryCopy, kingCoordinate);

            return(!isKingInDanger);
        }
Beispiel #2
0
 public QuantumHarmonic Clone()
 {
     return(new QuantumHarmonic(Board.Clone(), Degeneracy));
 }