tinymove

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const BlanksBitMask = 127 << 12
View Source
const ColBitMask = 0b00111110
View Source
const DefaultSmallMoveArenaSize = 65536

DefaultSmallMoveArenaSize is the initial capacity (in SmallMoves) for a SmallMoveArena. 65536 * 16 bytes = 1 MB, matching magpie's DEFAULT_INITIAL_SMALL_MOVE_ARENA_SIZE.

View Source
const RowBitMask = 0b00000111_11000000

Variables

View Source
var DefaultSmallMove = SmallMove{}

DefaultSmallMove is a blank move (a pass)

View Source
var TBitMasks = [7]uint64{63 << 20, 63 << 26, 63 << 32, 63 << 38, 63 << 44, 63 << 50, 63 << 56}

Functions

This section is empty.

Types

type SmallMove

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

A SmallMove consists of a TinyMove which encodes all the positional and tile info, plus a few extra fields needed for endgames and related modules. We're trying to strike a balance between decreasing allocations and still staying speedy.

func PassMove

func PassMove() SmallMove

func TilePlayMove

func TilePlayMove(tm TinyMove, score int16, tilesPlayed, playLength uint8) SmallMove

func (*SmallMove) AddEstimatedValue

func (m *SmallMove) AddEstimatedValue(v int16)

AddEstimatedValue adds an estimate to the existing estimated value of this estimate. Estimate.

func (*SmallMove) CoordsAndVertical

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

func (*SmallMove) EstimatedValue

func (m *SmallMove) EstimatedValue() int16

EstimatedValue is an internal value that is used in calculating endgames and related metrics.

func (*SmallMove) IsPass

func (m *SmallMove) IsPass() bool

func (*SmallMove) PlayLength

func (m *SmallMove) PlayLength() int

func (*SmallMove) Score

func (m *SmallMove) Score() int

func (*SmallMove) SetEstimatedValue

func (m *SmallMove) SetEstimatedValue(v int16)

SetEstimatedValue sets the estimated value of this move. It is calculated outside of this package.

func (*SmallMove) ShortDescription

func (m *SmallMove) ShortDescription() string

func (*SmallMove) TilesPlayed

func (m *SmallMove) TilesPlayed() int

func (*SmallMove) TinyMove

func (m *SmallMove) TinyMove() TinyMove

type SmallMoveArena added in v0.13.0

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

SmallMoveArena is a bump allocator for SmallMove slices. It uses LIFO (stack) discipline: Alloc advances the offset, Dealloc shrinks it. The backing slice grows as needed and is never freed — the GC handles it.

Each thread in the endgame/pre-endgame solver gets its own arena, so no synchronization is needed.

func NewSmallMoveArena added in v0.13.0

func NewSmallMoveArena(initialCap int) *SmallMoveArena

NewSmallMoveArena returns an arena with the given initial capacity.

func (*SmallMoveArena) Alloc added in v0.13.0

func (a *SmallMoveArena) Alloc(n int) []SmallMove

Alloc returns a sub-slice of length n from the arena, bumping the offset. The returned slice shares the arena's backing array. If there is insufficient capacity the backing slice is doubled (or grown to fit), which is expected to be rare given the generous initial size.

func (*SmallMoveArena) Dealloc added in v0.13.0

func (a *SmallMoveArena) Dealloc(n int)

Dealloc releases n elements from the top of the arena (LIFO).

func (*SmallMoveArena) Reset added in v0.13.0

func (a *SmallMoveArena) Reset()

Reset resets the arena to empty, logically freeing all allocations.

type TinyMove

type TinyMove uint64

TinyMove is a 64-bit representation of a move. We can probably make it smaller at the cost of higher decoding. It is made to be as small as possible to fit it in a transposition table.

const InvalidTinyMove TinyMove = 1 << 63

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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