public ChessGame(string fen) { var parts = fen.Split(); PieceSerializer.ParseBoard(parts[0], out WhiteKingSquare, out BlackKingSquare, out Board); ActiveColor = PieceSerializer.ToColor(parts[1]); var(hasWhiteKingMoved, hasBlackKingMoved, hasWhiteQueensideRookMoved, hasWhiteKingsideRookMoved, hasBlackQueensideRookMoved, hasBlackKingsideRookMoved) = PieceSerializer.ParseCastlings(parts[2]); HasWhiteKingMoved = hasWhiteKingMoved; HasBlackKingMoved = hasBlackKingMoved; HasWhiteQueensideRookMoved = hasWhiteQueensideRookMoved; HasWhiteKingsideRookMoved = hasWhiteKingsideRookMoved; HasBlackQueensideRookMoved = hasBlackQueensideRookMoved; HasBlackKingsideRookMoved = hasBlackKingsideRookMoved; EnPassantTargetSquare = PieceSerializer.ToSquare(parts[3]); MoveCount = int.Parse(parts[5]); var(whitePieces, blackPieces) = GetPieces(Board); WhitePieces = whitePieces; BlackPieces = blackPieces; }
public override string ToString() => PieceSerializer.ToFen(this);