compact

package
v0.0.0-...-70723b6 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: MIT Imports: 3 Imported by: 6

Documentation

Index

Constants

View Source
const (
	Terminal = Sou1 | Sou9 | Man1 | Man9 | Pin1 | Pin9
	Wind     = East | South | West | North
	Dragon   = White | Green | Red

	Man = Man1 | Man2 | Man3 | Man4 | Man5 | Man6 | Man7 | Man8 | Man9
	Pin = Pin1 | Pin2 | Pin3 | Pin4 | Pin5 | Pin6 | Pin7 | Pin8 | Pin9
	Sou = Sou1 | Sou2 | Sou3 | Sou4 | Sou5 | Sou6 | Sou7 | Sou8 | Sou9

	Sequence = Man | Pin | Sou

	Honor           = Wind | Dragon
	TerminalOrHonor = Terminal | Honor

	AllTiles = TileEnd - 1
	Middle   = (AllTiles ^ TerminalOrHonor) & AllTiles

	GreenYakuman = Sou2 | Sou3 | Sou4 | Sou6 | Sou8 | Green
)
View Source
const (
	FullMask = 15
)

Variables

This section is empty.

Functions

func MaskByCount

func MaskByCount(c int) uint

Types

type Generator

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

func NewTileGenerator

func NewTileGenerator() *Generator

func (*Generator) CompactFromString

func (g *Generator) CompactFromString(str string) (Instances, error)

func (*Generator) Instance

func (g *Generator) Instance(t tile.Tile) tile.Instance

func (*Generator) InstancesFromString

func (g *Generator) InstancesFromString(str string) (tile.Instances, error)

func (*Generator) Tiles

func (g *Generator) Tiles(tiles tile.Tiles) tile.Instances

func (*Generator) TilesLeft

func (g *Generator) TilesLeft() tile.Instances

type Instances

type Instances []PackedMasks

Not more than 4 tiles per type by implementation

func AllInstances

func AllInstances() Instances

func AllInstancesFromTo

func AllInstancesFromTo(from, to tile.Tile) Instances

func NewInstances

func NewInstances() Instances

func (Instances) Add

func (is Instances) Add(t tile.Instances) Instances

func (Instances) AddCount

func (is Instances) AddCount(t tile.Tile, x int) Instances

func (Instances) Check

func (is Instances) Check(t tile.Instance) bool

func (Instances) Clone

func (is Instances) Clone() Instances

func (Instances) Contains

func (is Instances) Contains(x Instances) bool

func (Instances) CopyFree

func (is Instances) CopyFree(in Tiles) Instances

func (Instances) CopyFrom

func (is Instances) CopyFrom(x Instances)

func (Instances) CountBits

func (is Instances) CountBits() int

func (Instances) CountFree

func (is Instances) CountFree(in Tiles) int

func (Instances) Each

func (is Instances) Each(f func(mask Mask) bool) bool

func (Instances) GetCount

func (is Instances) GetCount(t tile.Tile) int

func (Instances) GetFree

func (is Instances) GetFree() Tiles

func (Instances) GetFull

func (is Instances) GetFull() Tiles

func (Instances) GetMask

func (is Instances) GetMask(t tile.Tile) Mask

func (Instances) Instances

func (is Instances) Instances() tile.Instances

func (Instances) Invert

func (is Instances) Invert() Instances

func (Instances) IsEmpty

func (is Instances) IsEmpty() bool

func (Instances) Merge

func (is Instances) Merge(other Instances) Instances

func (Instances) Remove

func (is Instances) Remove(t tile.Instance) bool

func (Instances) Set

func (is Instances) Set(t tile.Instance)

func (Instances) SetCount

func (is Instances) SetCount(t tile.Tile, x int)

func (Instances) SetMask

func (is Instances) SetMask(mask Mask)

func (Instances) Sub

func (is Instances) Sub(other Instances) Instances

func (Instances) UniqueTiles

func (is Instances) UniqueTiles() Tiles

type Mask

type Mask uint

func NewMask

func NewMask(mask uint, t tile.Tile) Mask

func (Mask) Check

func (m Mask) Check(index tile.CopyID) bool

func (Mask) Count

func (m Mask) Count() int

func (Mask) Each

func (m Mask) Each(f func(tile.Instance) bool) bool

func (Mask) First

func (m Mask) First() tile.Instance

func (Mask) FirstCopy

func (m Mask) FirstCopy() tile.CopyID

func (Mask) FirstCopyNative

func (m Mask) FirstCopyNative() tile.CopyID

func (Mask) Instances

func (m Mask) Instances() tile.Instances

func (Mask) InvertTiles

func (m Mask) InvertTiles() Mask

func (Mask) IsEmpty

func (m Mask) IsEmpty() bool

func (Mask) IsFull

func (m Mask) IsFull() bool

func (Mask) Mask

func (m Mask) Mask() uint

func (Mask) Merge

func (m Mask) Merge(x Mask) Mask

func (Mask) NaiveCount

func (m Mask) NaiveCount() int

func (Mask) Remove

func (m Mask) Remove(x Mask) Mask

func (Mask) SetCopyBit

func (m Mask) SetCopyBit(cid tile.CopyID) Mask

func (Mask) SetCount

func (m Mask) SetCount(in int) Mask

func (Mask) SetIntBit

func (m Mask) SetIntBit(index uint) Mask

func (Mask) Tile

func (m Mask) Tile() tile.Tile

func (Mask) UnsetCopyBit

func (m Mask) UnsetCopyBit(cid tile.CopyID) Mask

func (Mask) UnsetIntBit

func (m Mask) UnsetIntBit(index uint) Mask

type PackedMasks

type PackedMasks uint64

func SinglePackedMasks

func SinglePackedMasks(mask Mask, index uint) PackedMasks

func (PackedMasks) CountBits

func (pm PackedMasks) CountBits() int

func (PackedMasks) Get

func (pm PackedMasks) Get(index uint, tile tile.Tile) Mask

func (PackedMasks) Set

func (pm PackedMasks) Set(mask Mask, index uint) PackedMasks

type TestGenerator

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

func NewTestGenerator

func NewTestGenerator(t require.TestingT) *TestGenerator

func (*TestGenerator) CompactFromString

func (tg *TestGenerator) CompactFromString(str string) Instances

func (*TestGenerator) InstancesFromString

func (tg *TestGenerator) InstancesFromString(str string) tile.Instances

func (*TestGenerator) TilesLeft

func (tg *TestGenerator) TilesLeft() tile.Instances

type Tiles

type Tiles uint64

Unique tiles

const (
	Man1 Tiles = 1 << iota
	Man2
	Man3
	Man4
	Man5
	Man6
	Man7
	Man8
	Man9

	Pin1
	Pin2
	Pin3
	Pin4
	Pin5
	Pin6
	Pin7
	Pin8
	Pin9

	Sou1
	Sou2
	Sou3
	Sou4
	Sou5
	Sou6
	Sou7
	Sou8
	Sou9

	East
	South
	West
	North

	White
	Green
	Red

	TileEnd
)

func FromTile

func FromTile(t tile.Tile) Tiles

func FromTiles

func FromTiles(tiles ...tile.Tile) Tiles

func NewTiles

func NewTiles(x ...tile.Tile) Tiles

func (Tiles) Check

func (ts Tiles) Check(t tile.Tile) bool

func (Tiles) Count

func (ts Tiles) Count() int

func (Tiles) Each

func (ts Tiles) Each(f func(tile.Tile) bool) bool

func (Tiles) EachRange

func (ts Tiles) EachRange(begin, end tile.Tile, f func(tile.Tile) bool) bool

func (Tiles) Invert

func (ts Tiles) Invert() Tiles

func (Tiles) IsEmpty

func (ts Tiles) IsEmpty() bool

func (Tiles) Merge

func (ts Tiles) Merge(other Tiles) Tiles

func (Tiles) Normalize

func (ts Tiles) Normalize() Tiles

func (Tiles) Set

func (ts Tiles) Set(t tile.Tile) Tiles

func (Tiles) SetAll

func (ts Tiles) SetAll(t tile.Tiles) Tiles

func (Tiles) Sub

func (ts Tiles) Sub(other Tiles) Tiles

func (Tiles) Tiles

func (ts Tiles) Tiles() tile.Tiles

func (Tiles) Unset

func (ts Tiles) Unset(t tile.Tile) Tiles

type Totals

type Totals []int

func NewTotals

func NewTotals() Totals

func (Totals) Add

func (ts Totals) Add(t tile.Tile, d int)

func (Totals) Clone

func (ts Totals) Clone() Totals

func (Totals) Count

func (ts Totals) Count() int

func (Totals) FreeTiles

func (ts Totals) FreeTiles() Tiles

func (Totals) FullTiles

func (ts Totals) FullTiles() Tiles

func (Totals) Get

func (ts Totals) Get(t tile.Tile) int

func (Totals) IsFull

func (ts Totals) IsFull(t tile.Tile) bool

func (Totals) Merge

func (ts Totals) Merge(in Instances) Totals

func (Totals) Set

func (ts Totals) Set(t tile.Tile, d int)

func (Totals) UniqueCount

func (ts Totals) UniqueCount() int

func (Totals) UniqueTiles

func (ts Totals) UniqueTiles() Tiles

Jump to

Keyboard shortcuts

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