movegen

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: May 29, 2019 License: GPL-3.0 Imports: 6 Imported by: 2

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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, bag *alphabet.Bag,
	board *board.GameBoard, strategy strategy.Strategizer) *GordonGenerator

NewGordonGenerator returns a Gordon move generator.

func (*GordonGenerator) Gen added in v0.2.0

func (gen *GordonGenerator) Gen(col int, word alphabet.MachineWord, rack *alphabet.Rack,
	nodeIdx uint32)

Gen is an implementation of the Gordon Gen function.

func (*GordonGenerator) GenAll added in v0.2.0

func (gen *GordonGenerator) GenAll(rack *alphabet.Rack)

GenAll generates all moves on the board. It assumes anchors have already been updated, as well as cross-sets / cross-scores.

func (*GordonGenerator) GoOn added in v0.2.0

func (gen *GordonGenerator) GoOn(curCol int, L alphabet.MachineLetter, word alphabet.MachineWord,
	rack *alphabet.Rack, newNodeIdx uint32, oldNodeIdx uint32)

GoOn is an implementation of the Gordon GoOn function.

func (*GordonGenerator) Plays added in v0.2.0

func (gen *GordonGenerator) Plays() []*move.Move

Plays returns the generator's generated plays.

func (*GordonGenerator) RecordPlay added in v0.2.0

func (gen *GordonGenerator) RecordPlay(word alphabet.MachineWord, startCol int,
	rack *alphabet.Rack)

RecordPlay records a play.

func (*GordonGenerator) Reset added in v0.2.0

func (gen *GordonGenerator) Reset()

Reset resets the generator by clearing the board and refilling the bag.

func (*GordonGenerator) SetBoardToGame added in v0.2.0

func (gen *GordonGenerator) SetBoardToGame(alph *alphabet.Alphabet, game board.VsWho)

func (*GordonGenerator) SetOppRack added in v0.2.0

func (gen *GordonGenerator) SetOppRack(r *alphabet.Rack)

SetOppRack sets the opponent's rack to the passed-in value. This is used to compute equity for plays that go out.

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.

type SortBy added in v0.2.0

type SortBy int
const (
	SortByScore SortBy = iota
	SortByEquity
)

Jump to

Keyboard shortcuts

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