Documentation ¶
Overview ¶
Package baduk implements a library for playing games of Baduk/Go. It's optimized for code simplicity, and doesn't include any AI support.
Index ¶
- type Board
- func (b *Board) Decode(str string) (err error)
- func (b *Board) Encode() (enc string, err error)
- func (b *Board) Init(size int) (err error)
- func (b *Board) PrettySVG() (svg string)
- func (b *Board) PrettyString() (str string)
- func (b *Board) Score() (black, white int)
- func (b *Board) ScorePretty() (str string)
- func (b *Board) SetB(x, y int) (err error)
- func (b *Board) SetW(x, y int) (err error)
- type Piece
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Board ¶
A Board represents information about the state of a Go game. Size represents the size of the board, Grid is the storage of Pieces.
func (*Board) Encode ¶
Encodes the Board state into a compressed, base64-encoded URL-safe string enc.
func (*Board) PrettySVG ¶
Creates a string representing an SVG view of the board, suitable for use inline in web templates. Wrap in an external div with particular width/height in CSS to control size. Yay for resolution independence!
func (*Board) PrettyString ¶
Creates pretty string, suitable for use by fmt.Printf or any logging functions. Note that black and white circles are reversed compared to their unicode code points; this assumes your terminal has a dark background.
func (*Board) Score ¶
Scores the Board. Scoring follows this algorithm: A color's score = total pieces + total empty pieces completely enclosed by said color. If empty pieces are enclosed by both colors, then empty territory is contested and not added to either score. This method is consistent with a simple version of Chinese area scoring.
func (*Board) ScorePretty ¶
Makes a string suitable for Sprintf output that declares the winner