coord

package
v1.12.2 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Coord

type Coord struct {
	X int `json:"x"`
	Y int `json:"y"`
}

Coord is just an (x,y) coordinate pair

func FromAlphanumeric

func FromAlphanumeric(s string, size int) (*Coord, error)

FromAlphanumeric converts a string like "c17" to a Coord

func FromInterface

func FromInterface(ifc any) (*Coord, error)

InterfaceToCoord essentially coerces the interface into a [2]int then turns that into a Coord

func FromLetters

func FromLetters(s string) *Coord

FromLetters takes a pair of letters and turns it into a Coord

func NewCoord

func NewCoord(x, y int) *Coord

func (*Coord) Copy

func (c *Coord) Copy() *Coord

Copy copies the Coord

func (*Coord) Equal

func (c *Coord) Equal(other *Coord) bool

Equal compares two Coords

func (*Coord) Index

func (c *Coord) Index() int

func (*Coord) String

func (c *Coord) String() string

String is for debugging

func (*Coord) ToLetters

func (c *Coord) ToLetters() string

ToLetters is sgf-specific (notice the inclusion of 'i')

type CoordSet

type CoordSet map[int]*Coord

CoordSet is used for quickly checking a set for existence of coords

func NewCoordSet

func NewCoordSet() CoordSet

NewCoordSet makes an empty CoordSet

func (CoordSet) Add

func (cs CoordSet) Add(c *Coord)

Add adds a coord to the set

func (CoordSet) AddAll

func (cs CoordSet) AddAll(ds CoordSet)

func (CoordSet) Equal

func (cs CoordSet) Equal(other CoordSet) bool

Equal does IsSubsetOf twice

func (CoordSet) Has

func (cs CoordSet) Has(c *Coord) bool

Has: uses ToLetters as the key

func (CoordSet) Intersect

func (cs CoordSet) Intersect(ds CoordSet) CoordSet

func (CoordSet) IsSubsetOf

func (cs CoordSet) IsSubsetOf(other CoordSet) bool

IsSubsetOf checks for set inclusion

func (CoordSet) List

func (cs CoordSet) List() []*Coord

List converts the map to an array

func (CoordSet) Remove

func (cs CoordSet) Remove(c *Coord)

func (CoordSet) RemoveAll

func (cs CoordSet) RemoveAll(ds CoordSet)

func (CoordSet) String

func (cs CoordSet) String() string

String is for debugging

type Diff

type Diff struct {
	Add    []*StoneSet `json:"add"`
	Remove []*StoneSet `json:"remove"`
}

Diff contains two StoneSets (Add and Remove) and is a key component of a Frame

func NewDiff

func NewDiff(add, remove []*StoneSet) *Diff

NewDiff makes a Diff based on two StoneSets

func (*Diff) Copy

func (d *Diff) Copy() *Diff

Copy makes a copy of the Diff

func (*Diff) Invert

func (d *Diff) Invert() *Diff

Invert simply exchanges Add and Remove

type Stone

type Stone struct {
	Coord *Coord // nil for passes
	Color color.Color
}

Stone is a Coord plus a Color StoneSet is essentially an extension of Stone

func NewStone

func NewStone(x, y int, c color.Color) *Stone

type StoneSet

type StoneSet struct {
	Coords      []*Coord `json:"coords"`
	color.Color `json:"color"`
}

StoneSet is an array of Coords plus a Color

func NewStoneSet

func NewStoneSet(s CoordSet, c color.Color) *StoneSet

NewStoneSet takes a CoordSet and a Color and turns it into a StoneSet

func (*StoneSet) Copy

func (s *StoneSet) Copy() *StoneSet

Copy copies the StoneSet

func (*StoneSet) Equal

func (s *StoneSet) Equal(other *StoneSet) bool

func (*StoneSet) String

func (s *StoneSet) String() string

String is for debugging

Jump to

Keyboard shortcuts

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