board

package
v0.0.0-...-043dd78 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InvalidBoardState = errors.New("invalid board state")
	IllegalMove       = errors.New("illegal move")
)

Functions

This section is empty.

Types

type Board

type Board struct {
	// contains filtered or unexported fields
}

Board Contains the board, capturesStones, and ko ko contains a point that is illegal to recapture due to Ko.

func New

func New(size int) *Board

New creates a new size x size board.

func (*Board) Clone

func (b *Board) Clone() *Board

Clone makes a board copy.

func (*Board) FullBoardState

func (b *Board) FullBoardState() [][]color.Color

FullBoardState returns the full board state.

func (*Board) Ko

func (b *Board) Ko() *point.Point

Ko returns the ko point.

func (*Board) PlaceStone

func (b *Board) PlaceStone(m *move.Move) (move.List, error)

PlaceStone adds a stone to the board and removes captured stones (if any). returns the captured stones, or err if any Go (baduk) rules were broken

func (*Board) SetPlacements

func (b *Board) SetPlacements(ml move.List) error

SetPlacements force-places moves on the go-board, without performing capture logic. If an illegal board position results, return an error.

func (*Board) StoneState

func (b *Board) StoneState() move.List

StoneState returns an array of all the current stone positions.

func (*Board) String

func (b *Board) String() string

String returns a string representation of this board. For example:

b.Board {{B, W, B,  },
         {W,  , B, B},
         { ,  , W,  },
         {B,  , W,  }}

Becomes  [B W B .]
         [W . B B]
         [. . W .]
         [B . W .]

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL