move

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2022 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromBoardGameCoords

func FromBoardGameCoords(c string) (int, int, bool)

FromBoardGameCoords does the inverse operation of ToBoardGameCoords above.

func ToBoardGameCoords

func ToBoardGameCoords(row int, col int, vertical bool) string

ToBoardGameCoords onverts the row, col, and orientation of the play to a coordinate like 5F or G4.

Types

type Move

type Move struct {
	// contains filtered or unexported fields
}

Move is a move. It can have a score, position, equity, etc. It doesn't have to be a scoring move.

func NewBonusScoreMove

func NewBonusScoreMove(t MoveType, tiles alphabet.MachineWord, score int) *Move

func NewChallengeMove

func NewChallengeMove(leave alphabet.MachineWord, alph *alphabet.Alphabet) *Move

NewChallengeMove creates a challenge with the given leave.

func NewExchangeMove

func NewExchangeMove(tiles alphabet.MachineWord, leave alphabet.MachineWord,
	alph *alphabet.Alphabet) *Move

NewExchangeMove creates an exchange.

func NewLostScoreMove

func NewLostScoreMove(t MoveType, rack alphabet.MachineWord, score int) *Move

func NewPassMove

func NewPassMove(leave alphabet.MachineWord, alph *alphabet.Alphabet) *Move

NewPassMove creates a pass with the given leave.

func NewScoringMove

func NewScoringMove(score int, tiles alphabet.MachineWord,
	leave alphabet.MachineWord, vertical bool, tilesPlayed int,
	alph *alphabet.Alphabet, rowStart int, colStart int, coords string) *Move

NewScoringMove creates a scoring *Move and returns it.

func NewScoringMoveSimple

func NewScoringMoveSimple(score int, coords string, word string, leave string,
	alph *alphabet.Alphabet) *Move

NewScoringMoveSimple takes in user-visible strings. Consider moving to this (it is a little slower, though, so maybe only for tests)

func NewUnsuccessfulChallengePassMove

func NewUnsuccessfulChallengePassMove(leave alphabet.MachineWord, alph *alphabet.Alphabet) *Move

func (*Move) Action

func (m *Move) Action() MoveType

func (*Move) Alphabet

func (m *Move) Alphabet() *alphabet.Alphabet

Alphabet is the alphabet used by this move

func (*Move) BoardCoords

func (m *Move) BoardCoords() string

func (*Move) CoordsAndVertical

func (m *Move) CoordsAndVertical() (int, int, bool)

func (*Move) Dupe

func (m *Move) Dupe() *Move

func (*Move) Equity

func (m *Move) Equity() float64

Equity is the equity of this move.

func (*Move) FullRack

func (m *Move) FullRack() string

FullRack returns the entire rack that the move was made from. This can be calculated from the tiles it uses and the leave.

func (*Move) HasDupe

func (m *Move) HasDupe() bool

func (*Move) Leave

func (m *Move) Leave() alphabet.MachineWord

func (*Move) LeaveString

func (m *Move) LeaveString() string

func (*Move) MoveTypeString

func (m *Move) MoveTypeString() string

func (*Move) Score

func (m *Move) Score() int

func (*Move) SetDupe

func (m *Move) SetDupe(o *Move)

func (*Move) SetEquity

func (m *Move) SetEquity(e float64)

SetEquity sets the equity of this move. It is calculated outside this package.

func (*Move) SetValuation

func (m *Move) SetValuation(v float32)

SetValuation sets the valuation of this move. It is calculated outside of this package.

func (*Move) SetVisited

func (m *Move) SetVisited(v bool)

func (*Move) ShortDescription

func (m *Move) ShortDescription() string

ShortDescription provides a short description, useful for logging or user display.

func (*Move) String

func (m *Move) String() string

String provides a string just for debugging purposes.

func (*Move) Tiles

func (m *Move) Tiles() alphabet.MachineWord

func (*Move) TilesPlayed

func (m *Move) TilesPlayed() int

TilesPlayed returns the number of tiles played by this move.

func (*Move) TilesString

func (m *Move) TilesString() string

func (*Move) UniqueSingleTileKey

func (m *Move) UniqueSingleTileKey() int

func (*Move) Valuation

func (m *Move) Valuation() float32

Valuation is the "value" of this move. This is an internal value that is used in calculating endgames and other such metrics.

func (*Move) Visited

func (m *Move) Visited() bool

type MoveType

type MoveType uint8

MoveType is a type of move; a play, an exchange, pass, etc.

const (
	MoveTypePlay MoveType = iota
	MoveTypeExchange
	MoveTypePass
	MoveTypeChallenge
	MoveTypePhonyTilesReturned
	MoveTypeChallengeBonus
	MoveTypeUnsuccessfulChallengePass

	MoveTypeEndgameTiles
	MoveTypeLostTileScore
	MoveTypeLostScoreOnTime
)

Jump to

Keyboard shortcuts

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