diff --git a/sidecheck.go b/sidecheck.go index 2fedfaa7147179ac04b860b35602d078d39a8c73..d19198ff4bf1070f9390a63b072f110321c55bfe 100644 --- a/sidecheck.go +++ b/sidecheck.go @@ -4,6 +4,7 @@ import ( "strings" ) +// Constants for the different board piece types. const ( BOARD int = iota PIECE @@ -27,11 +28,13 @@ func coordsAround(x, y int) []coords { } } +// Board defines a square or rectangular grid to represent a chess-style board. type Board struct { rows, cols int board [][]int } +// NewBoard creates an empty Board with the given size. func NewBoard(rows, cols int) *Board { board := Board{ rows, cols, @@ -43,6 +46,7 @@ func NewBoard(rows, cols int) *Board { return &board } +// StringToBoard creates a Board from a string. func StringToBoard(b string) *Board { rows := strings.Split(b, "\n") rowMax := len(rows)