Documentation ¶
Index ¶
- Constants
- Variables
- type BoardDirection
- type BonusSquare
- type CrossSet
- type GameBoard
- func (g *GameBoard) Clear()
- func (g *GameBoard) ClearAllCrosses()
- func (g *GameBoard) ClearCrossSet(row int, col int, dir BoardDirection)
- func (g *GameBoard) Dim() int
- func (b *GameBoard) GenAllCrossSets(gaddag *gaddag.SimpleGaddag, bag *alphabet.Bag)
- func (b *GameBoard) GenCrossSet(row int, col int, dir BoardDirection, gaddag *gaddag.SimpleGaddag, ...)
- func (g *GameBoard) GetBonus(row int, col int) BonusSquare
- func (g *GameBoard) GetCrossScore(row int, col int, dir BoardDirection) int
- func (g *GameBoard) GetCrossSet(row int, col int, dir BoardDirection) CrossSet
- func (g *GameBoard) GetLetter(row int, col int) alphabet.MachineLetter
- func (g *GameBoard) GetSquare(row int, col int) *Square
- func (g *GameBoard) IsAnchor(row int, col int, dir BoardDirection) bool
- func (g *GameBoard) IsEmpty() bool
- func (g *GameBoard) IsTransposed() bool
- func (g *GameBoard) PlayMove(m *move.Move, gd *gaddag.SimpleGaddag, bag *alphabet.Bag, backup bool)
- func (g *GameBoard) RestoreFromBackup()
- func (g *GameBoard) SetAllCrosses()
- func (g *GameBoard) SetCrossSetLetter(row int, col int, dir BoardDirection, ml alphabet.MachineLetter)
- func (g *GameBoard) SetFromPlaintext(qText string, alph *alphabet.Alphabet) *TilesInPlay
- func (g *GameBoard) SetLetter(row int, col int, letter alphabet.MachineLetter)
- func (b *GameBoard) SetRow(rowNum int, letters string, alph *alphabet.Alphabet)
- func (b *GameBoard) SetToGame(alph *alphabet.Alphabet, game VsWho) *TilesInPlay
- func (g *GameBoard) ToDisplayText(alph *alphabet.Alphabet) string
- func (g *GameBoard) Transpose()
- func (g *GameBoard) UpdateAllAnchors()
- type Square
- type TilesInPlay
- type VsWho
- type WordDirection
Constants ¶
const ( // TrivialCrossSet allows every possible letter. It is the default // state of a square. TrivialCrossSet = (1 << alphabet.MaxAlphabetSize) - 1 )
Variables ¶
var ( // CrosswordGameBoard is a board for a fun Crossword Game, featuring lots // of wingos and blonks. CrosswordGameBoard []string )
Functions ¶
This section is empty.
Types ¶
type BoardDirection ¶
type BoardDirection uint8
const ( HorizontalDirection BoardDirection = iota VerticalDirection )
func (BoardDirection) String ¶
func (bd BoardDirection) String() string
type BonusSquare ¶
type BonusSquare rune
A BonusSquare is a bonus square (duh)
const ( // Bonus3WS is a triple word score Bonus3WS BonusSquare = '=' // Bonus3LS is a triple letter score Bonus3LS BonusSquare = '"' // Bonus2LS is a double letter score Bonus2LS BonusSquare = '\'' // Bonus2WS is a double word score Bonus2WS BonusSquare = '-' )
type CrossSet ¶
type CrossSet uint64
A CrossSet is a bit mask of letters that are allowed on a square. It is inherently directional, as it depends on which direction we are generating moves in. If we are generating moves HORIZONTALLY, we check in the VERTICAL cross set to make sure we can play a letter there. Therefore, a VERTICAL cross set is created by looking at the tile(s) above and/or below the relevant square and seeing what letters lead to valid words.
type GameBoard ¶
type GameBoard struct {
// contains filtered or unexported fields
}
A GameBoard is the main board structure. It contains all of the Squares, with bonuses or filled letters, as well as cross-sets and cross-scores for computation. (See Appel & Jacobson paper for definition of the latter two terms)
func (*GameBoard) ClearAllCrosses ¶
func (g *GameBoard) ClearAllCrosses()
ClearAllCrosses disallows all letters on all squares (more or less).
func (*GameBoard) ClearCrossSet ¶
func (g *GameBoard) ClearCrossSet(row int, col int, dir BoardDirection)
func (*GameBoard) GenAllCrossSets ¶
func (b *GameBoard) GenAllCrossSets(gaddag *gaddag.SimpleGaddag, bag *alphabet.Bag)
GenAllCrossSets generates all cross-sets. It goes through the entire board; our anchor algorithm doesn't quite match the one in the Gordon paper. We do this for both transpositions of the board.
func (*GameBoard) GenCrossSet ¶
func (b *GameBoard) GenCrossSet(row int, col int, dir BoardDirection, gaddag *gaddag.SimpleGaddag, bag *alphabet.Bag)
GenCrossSet generates a cross-set for each individual square.
func (*GameBoard) GetCrossScore ¶
func (g *GameBoard) GetCrossScore(row int, col int, dir BoardDirection) int
func (*GameBoard) GetCrossSet ¶
func (g *GameBoard) GetCrossSet(row int, col int, dir BoardDirection) CrossSet
func (*GameBoard) GetLetter ¶
func (g *GameBoard) GetLetter(row int, col int) alphabet.MachineLetter
func (*GameBoard) IsAnchor ¶
func (g *GameBoard) IsAnchor(row int, col int, dir BoardDirection) bool
IsAnchor returns whether the row/col pair is an anchor in the given direction.
func (*GameBoard) IsTransposed ¶
func (*GameBoard) PlayMove ¶
PlayMove plays a move on a board. It must place tiles on the board, regenerate cross-sets and cross-points, and recalculate anchors.
func (*GameBoard) RestoreFromBackup ¶
func (g *GameBoard) RestoreFromBackup()
RestoreFromBackup restores the squares of this board from the backupBoard.
func (*GameBoard) SetAllCrosses ¶
func (g *GameBoard) SetAllCrosses()
SetAllCrosses sets the cross sets of every square to every acceptable letter.
func (*GameBoard) SetCrossSetLetter ¶
func (g *GameBoard) SetCrossSetLetter(row int, col int, dir BoardDirection, ml alphabet.MachineLetter)
func (*GameBoard) SetFromPlaintext ¶
func (g *GameBoard) SetFromPlaintext(qText string, alph *alphabet.Alphabet) *TilesInPlay
SetFromPlaintext sets the board from the given plaintext board. It returns a list of all played machine letters (tiles) so that the caller can reconcile the tile bag appropriately.
func (*GameBoard) SetLetter ¶
func (g *GameBoard) SetLetter(row int, col int, letter alphabet.MachineLetter)
func (*GameBoard) SetToGame ¶
func (b *GameBoard) SetToGame(alph *alphabet.Alphabet, game VsWho) *TilesInPlay
SetToGame sets the board to a specific game in progress. It is used to generate test cases.
func (*GameBoard) Transpose ¶
func (g *GameBoard) Transpose()
Transpose transposes the board, swapping rows and columns.
func (*GameBoard) UpdateAllAnchors ¶
func (g *GameBoard) UpdateAllAnchors()
type Square ¶
type Square struct {
// contains filtered or unexported fields
}
A Square is a single square in a game board. It contains the bonus markings, if any, a letter, if any (' ' if empty), and any cross-sets and cross-scores
func (*Square) Letter ¶
func (s *Square) Letter() alphabet.MachineLetter
type TilesInPlay ¶
type TilesInPlay struct { OnBoard []alphabet.MachineLetter Rack1 []alphabet.MachineLetter Rack2 []alphabet.MachineLetter }
type VsWho ¶
type VsWho uint8
VsWho is an enumeration
const ( // VsEd was a game I played against Ed, under club games 20150127vEd VsEd VsWho = iota // VsMatt was a game I played against Matt Graham, 2018 Lake George tourney VsMatt // VsJeremy was a game I played against Jeremy Hall, 2018-11 Manhattan tourney VsJeremy // VsOxy is a constructed game that has a gigantic play available. VsOxy // VsMatt2 at the 2018-11 Manhattan tourney VsMatt2 // VsRoy at the 2011 California Open VsRoy // VsMacondo1 is poor_endgame_timing.gcg VsMacondo1 )
type WordDirection ¶
type WordDirection int
const ( LeftDirection WordDirection = -1 RightDirection WordDirection = 1 )