Documentation ¶
Overview ¶
Package movegen contains all the move-generating functions. It makes heavy use of the GADDAG. Implementation notes: - Is the specification in the paper a bit buggy? Basically, if I assume an anchor is the leftmost tile of a word, the way the algorithm works, it will create words blindly. For example, if I have a word FIRE on the board, and I have the letter E on my rack, and I specify F as the anchor, it will create the word EF! (Ignoring the fact that IRE is on the board) You can see this by just stepping through the algorithm. It seems that anchors can only be on the rightmost tile of a word
Index ¶
- func AllPlaysRecorder(gen *GordonGenerator, rack *alphabet.Rack, leftstrip, rightstrip int, ...)
- func NullPlayRecorder(gen *GordonGenerator, a *alphabet.Rack, leftstrip, rightstrip int, ...)
- func TopPlayOnlyRecorder(gen *GordonGenerator, rack *alphabet.Rack, leftstrip, rightstrip int, ...)
- type GordonGenerator
- func (gen *GordonGenerator) GenAll(rack *alphabet.Rack, addExchange bool) []*move.Move
- func (gen *GordonGenerator) Plays() []*move.Move
- func (gen *GordonGenerator) SetGame(g *game.Game)
- func (gen *GordonGenerator) SetPlayRecorder(pr PlayRecorderFunc)
- func (gen *GordonGenerator) SetSortingParameter(s SortBy)
- func (gen *GordonGenerator) SetStrategizer(st strategy.Strategizer)
- type MoveGenerator
- type PlayRecorderFunc
- type SortBy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllPlaysRecorder ¶ added in v0.4.9
func NullPlayRecorder ¶ added in v0.4.9
func TopPlayOnlyRecorder ¶ added in v0.4.9
func TopPlayOnlyRecorder(gen *GordonGenerator, rack *alphabet.Rack, leftstrip, rightstrip int, t move.MoveType)
TopPlayOnlyRecorder is a heavily optimized, ugly function to avoid allocating a lot of moves just to throw them out. It only records the very top move.
Types ¶
type GordonGenerator ¶ added in v0.2.0
type GordonGenerator struct {
// contains filtered or unexported fields
}
GordonGenerator is the main move generation struct. It implements Steven A. Gordon's algorithm from his paper "A faster Scrabble Move Generation Algorithm"
func NewGordonGenerator ¶ added in v0.2.0
func NewGordonGenerator(gd *gaddag.SimpleGaddag, board *board.GameBoard, ld *alphabet.LetterDistribution) *GordonGenerator
NewGordonGenerator returns a Gordon move generator.
func (*GordonGenerator) GenAll ¶ added in v0.2.0
GenAll generates all moves on the board. It assumes anchors have already been updated, as well as cross-sets / cross-scores.
func (*GordonGenerator) Plays ¶ added in v0.2.0
func (gen *GordonGenerator) Plays() []*move.Move
Plays returns the generator's generated plays.
func (*GordonGenerator) SetGame ¶ added in v0.4.9
func (gen *GordonGenerator) SetGame(g *game.Game)
func (*GordonGenerator) SetPlayRecorder ¶ added in v0.4.9
func (gen *GordonGenerator) SetPlayRecorder(pr PlayRecorderFunc)
func (*GordonGenerator) SetSortingParameter ¶ added in v0.2.0
func (gen *GordonGenerator) SetSortingParameter(s SortBy)
SetSortingParameter tells the play sorter to sort by score, equity, or perhaps other things. This is useful for the endgame solver, which does not care about equity.
func (*GordonGenerator) SetStrategizer ¶ added in v0.4.9
func (gen *GordonGenerator) SetStrategizer(st strategy.Strategizer)
type MoveGenerator ¶ added in v0.2.11
type MoveGenerator interface { GenAll(rack *alphabet.Rack, addExchange bool) []*move.Move SetSortingParameter(s SortBy) Plays() []*move.Move SetPlayRecorder(pf PlayRecorderFunc) SetStrategizer(st strategy.Strategizer) }
MoveGenerator is a generic interface for generating moves.