You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Supports all data types (incl compressed point lists)
Out of the box implementations for all properties needed for Go (GM[1])
SGF v4 parsing and generation
Parsing example
using dnsl48.SGF.Model;using dnsl48.SGF.Model.Property;// Parser state keeps all errorsvarparser=new dnsl48.SGF.NaiveParser();try{// The SGF tree collection
dnsl48.SGF.Model.Collection collection= parser.Parse(sgfBlob);
catch (dnsl48.SGF.NaiveParser.IParseError e){// incorrect SGF document} catch (Exception e){// unexpected runtime exception}// Strictly typed model for working with the tree// It's all have already been validated when parsedtry{varnode= collection.trees[0].nodes[0];// SZ[19] becomes Model.Property.Root.BoardSizeif(node.props.has("SZ")){
Root.BoardSize size=(Root.BoardSize) node.props["SZ"];
size.x ==19;
size.y ==19;}// RE[W+3.5] becomes Model.Property.Info.GameResultif(node.props.ContainsKey("RE")){
Info.GameResult result=(Info.GameResult) node.props["RE"];if(result.how == GameResult.WinType.Score){
result.who == Colour.White;// White won
result.score ==3.5m;// how much}}}
Generation example
using dnsl48.SGF.Model;using dnsl48.SGF.Types;// Use Model to generate SGFvarcollection=new Collection(new Tree[]{// the sequence of collection treesnew Tree(new Node[]{// the sequence of tree nodesnew Node(new IProperty[]{// the sequence of node properties// Application becomes "AP"(IProperty)new Application(new SimpleComposedText("Sharp SGF tools"),new SimpleComposedText("0.0.1")),// GameResult becomes "RE"(IProperty)new GameResult(Colour.Black,8.5m),// GameType becomes "GM"(IProperty)new GameType(1)})},new Tree[]{}// the child trees go here)});stringsgfBlob= collection.ToString();// sgfBlob contains the following: "(;AP[Sharp SGF tools:0.0.1] RE[B+8.5] GM[1])"