Documentation
¶
Overview ¶
Package sgf parses and decodes generic game tree collection
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collection ¶
type Collection []*Tree
Collection game trees
func Parse ¶
func Parse(sgf string) Collection
Parse SGF
Example (NoVariation) ¶
No Variation
package main import ( "fmt" "github.com/dgf/gotv/sgf" ) func main() { s := "(;GM[1]SZ[19]FF[4];B[aa];W[bb];B[cc])" fmt.Println(sgf.Parse(s)) }
Output: (;FF[4]GM[1]SZ[19];B[aa];W[bb];B[cc])
Example (OneVariationAtMove3) ¶
One variation at move 3
package main import ( "fmt" "github.com/dgf/gotv/sgf" ) func main() { s := `(;FF[4]GM[1]SZ[19];B[aa];W[bb] (;B[cc];W[dd];B[ad];W[bd]) (;B[hh];W[hg]))` fmt.Println(sgf.Parse(s)) }
Output: (;FF[4]GM[1]SZ[19];B[aa];W[bb](;B[cc];W[dd];B[ad];W[bd])(;B[hh];W[hg]))
Example (TwoVariationAtDifferentMoves) ¶
Two variations at different moves
package main import ( "fmt" "github.com/dgf/gotv/sgf" ) func main() { s := `(;FF[4]GM[1]SZ[19];B[aa];W[bb] (;B[cc];W[dd] (;B[ad];W[bd]) (;B[ee];W[ff]) ) (;B[hh];W[hg]))` fmt.Println(sgf.Parse(s)) }
Output: (;FF[4]GM[1]SZ[19];B[aa];W[bb](;B[cc];W[dd](;B[ad];W[bd])(;B[ee];W[ff]))(;B[hh];W[hg]))
Example (TwoVariationAtMove3) ¶
Two variations at move 3
package main import ( "fmt" "github.com/dgf/gotv/sgf" ) func main() { s := `(;FF[4]GM[1]SZ[19];B[aa];W[bb] (;B[cc]N[A];W[dd];B[ad];W[bd]) (;B[hh]N[B];W[hg]) (;B[gg]N[C];W[gh];B[hh];W[hg];B[kk]))` fmt.Println(sgf.Parse(s)) }
Output: (;FF[4]GM[1]SZ[19];B[aa];W[bb](;B[cc]N[A];W[dd];B[ad];W[bd])(;B[hh]N[B];W[hg])(;B[gg]N[C];W[gh];B[hh];W[hg];B[kk]))
Example (VariationOfVariation) ¶
Variation of a variation
package main import ( "fmt" "github.com/dgf/gotv/sgf" ) func main() { s := `(;FF[4]GM[1]SZ[19];B[aa];W[bb] (;B[cc]N[A];W[dd];B[ad];W[bd]) (;B[hh]N[B];W[hg]) (;B[gg]N[C];W[gh];B[hh] (;W[hg]N[A];B[kk]) (;W[kl]N[B])))` fmt.Println(sgf.Parse(s)) }
Output: (;FF[4]GM[1]SZ[19];B[aa];W[bb](;B[cc]N[A];W[dd];B[ad];W[bd])(;B[hh]N[B];W[hg])(;B[gg]N[C];W[gh];B[hh](;N[A]W[hg];B[kk])(;N[B]W[kl])))
func (Collection) String ¶
func (c Collection) String() string
String tree collection (encode SGF Collection)
Click to show internal directories.
Click to hide internal directories.