Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Board ¶
Board represents a game board, which is a grid of positions on which tiles can be placed. The zero-value of a Board is a zero-sized board.
func WithLayout ¶
WithLayout creates a board with no tiles, with the specified layout.
Example ¶
__, st, dl, dw, tl, tw := AllPositionTypes() board := WithLayout(Layout{ {tw, __, __, dl, __, __, __, tw, __, __, __, dl, __, __, tw}, {__, dw, __, __, __, tl, __, __, __, tl, __, __, __, dw, __}, {__, __, dw, __, __, __, dl, __, dl, __, __, __, dw, __, __}, {dl, __, __, dw, __, __, __, dl, __, __, __, dw, __, __, dl}, {__, __, __, __, dw, __, __, __, __, __, dw, __, __, __, __}, {__, tl, __, __, __, tl, __, __, __, tl, __, __, __, tl, __}, {__, __, dl, __, __, __, dl, __, dl, __, __, __, dl, __, __}, {tw, __, __, dl, __, __, __, st, __, __, __, dl, __, __, tw}, {__, __, dl, __, __, __, dl, __, dl, __, __, __, dl, __, __}, {__, tl, __, __, __, tl, __, __, __, tl, __, __, __, tl, __}, {__, __, __, __, dw, __, __, __, __, __, dw, __, __, __, __}, {dl, __, __, dw, __, __, __, dl, __, __, __, dw, __, __, dl}, {__, __, dw, __, __, __, dl, __, dl, __, __, __, dw, __, __}, {__, dw, __, __, __, tl, __, __, __, tl, __, __, __, dw, __}, {tw, __, __, dl, __, __, __, tw, __, __, __, dl, __, __, tw}, }) fmt.Printf("The board: %v", board)
Output:
func WithStandardLayout ¶
func WithStandardLayout() Board
WithStandardLayout returns an empty Board with a standardised layout.
func (*Board) NeighbourHasTile ¶
NeighbourHasTile returns true if any neighbouring position of the position at the specified coordinate has a tile on it.
func (*Board) Neighbours ¶
Neighbours returns the cardinal neighbouring positions to the specified coordinate. If a neighbour would be out of bounds, nil is returned in its place. Neighbours are always returned in North, South, East, West order.
type Layout ¶
type Layout [][]PositionType
Layout represents a layout for creating a Board. Layouts are specified from the top row down, from the leftmost column to the rightmost.
type Position ¶
type Position struct { Type PositionType Tile *tile.Tile }
Position represents a single position on a Board, which may be occupied by a tile and may have a special property.
type PositionType ¶
type PositionType interface { CountsAsConnected() bool ModifyTileScore(score int) int ModifyWordScore(score int) int Name() string }
PositionType represents a type of board position, which may be a starting position, or a position with a score bonus, etc.
func AllPositionTypes ¶
func AllPositionTypes() (__, st, dl, dw, tl, tw PositionType)
AllPositionTypes returns a set of built in position types which can be used to conveniently specify board Layouts. The position types returned are: normal/empty, start, double letter score, double word score, triple letter score, triple word score.
The same instances of the position types are always returned so they can be compared to each other.
See WithLayout for example usage.