cepo

package
v0.0.0-...-88544f8 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LeftRight CornerOrientation = 0
	UpDown    CornerOrientation = 1
	FrontBack CornerOrientation = 2

	// Short forms
	LF = LeftRight
	UD = UpDown
	FB = FrontBack

	FirstCornerOrientation = LeftRight
	LastCornerOrientation  = FrontBack
	CornerOrientationCount = 3
)
View Source
const DefaultCacheName = "rubik.cache"

Variables

View Source
var G1Moves = makeG1Moves()
View Source
var G2Moves = makeG2Moves()
View Source
var G3Moves = makeG3Moves()

Functions

func MakeG1CornerOrientationsTable

func MakeG1CornerOrientationsTable() map[CornerOrientations]uint8

func MakeG2CornerPermutationTable

func MakeG2CornerPermutationTable(g3 map[CornerPermutation]uint8) map[CornerPermutation]uint8

func MakeG2EdgePermutationTable

func MakeG2EdgePermutationTable() map[EdgePermutation]uint8

func MakeG3BetterHeuristicTable

func MakeG3BetterHeuristicTable() map[G3Cube]uint8

func MakeG3CornerPermutationTable

func MakeG3CornerPermutationTable() map[CornerPermutation]uint8

func MakeG3EdgePermutationTable

func MakeG3EdgePermutationTable() map[EdgePermutation]uint8

func MakeG3HeuristicTable

func MakeG3HeuristicTable() map[Cube]uint8

Types

type CornerOrientation

type CornerOrientation = uint8

type CornerOrientations

type CornerOrientations struct {
	Bits uint32
}

func NewCornerOrientationsSolved

func NewCornerOrientationsSolved() CornerOrientations

func (*CornerOrientations) Apply

func (co *CornerOrientations) Apply(move cmn.Move)

func (CornerOrientations) Distance

func (co CornerOrientations) Distance() int

func (CornerOrientations) Get

func (CornerOrientations) IsSolved

func (co CornerOrientations) IsSolved() bool

func (*CornerOrientations) Set

func (co *CornerOrientations) Set(index cmn.CornerIndex, orientation CornerOrientation)

type CornerPermutation

type CornerPermutation struct {
	Bits CornerPermutationBits
}

func NewCornerPermutationSolved

func NewCornerPermutationSolved() CornerPermutation

func (CornerPermutation) AllInCorrectOrbit

func (cp CornerPermutation) AllInCorrectOrbit() bool

func (CornerPermutation) AllInCorrectOrbitDistance

func (cp CornerPermutation) AllInCorrectOrbitDistance() int

func (*CornerPermutation) Apply

func (cp *CornerPermutation) Apply(move cmn.Move)

func (CornerPermutation) Distance

func (cp CornerPermutation) Distance() int

func (CornerPermutation) Get

func (CornerPermutation) IsSolved

func (cp CornerPermutation) IsSolved() bool

func (*CornerPermutation) Set

func (cp *CornerPermutation) Set(index, value cmn.CornerIndex)

type CornerPermutationBits

type CornerPermutationBits = uint32

type Cube

type Cube struct {
	EdgeOrientations   EdgeOrientations
	EdgePermutation    EdgePermutation
	CornerOrientations CornerOrientations
	CornerPermutation  CornerPermutation
}

func NewCubeSolved

func NewCubeSolved() *Cube

func (*Cube) Apply

func (c *Cube) Apply(m cmn.Move)

func (*Cube) Blueprint

func (c *Cube) Blueprint() string

func (*Cube) Clone

func (c *Cube) Clone() cmn.Cube

func (Cube) Equal

func (c Cube) Equal(o Cube) bool

func (*Cube) Get

func (c *Cube) Get(coord cmn.CubeCoord) cmn.Side

func (*Cube) IsG1

func (c *Cube) IsG1() bool

func (*Cube) IsG2

func (c *Cube) IsG2() bool

func (*Cube) IsG2AssumingG1

func (c *Cube) IsG2AssumingG1() bool

func (*Cube) IsG4

func (c *Cube) IsG4() bool

func (*Cube) IsG4AssumingG3

func (c *Cube) IsG4AssumingG3() bool

func (*Cube) IsSolved

func (c *Cube) IsSolved() bool

func (*Cube) NewSolver

func (c *Cube) NewSolver() cmn.Solver

type EdgeOrientationBits

type EdgeOrientationBits = uint16
const (
	EdgeOrientationMaskUp    EdgeOrientationBits = 0b1001_0000_0101
	EdgeOrientationMaskDown  EdgeOrientationBits = 0b0110_0000_1010
	EdgeOrientationMaskLeft  EdgeOrientationBits = 0b0000_0011_0011
	EdgeOrientationMaskRight EdgeOrientationBits = 0b0000_1100_1100
	EdgeOrientationMaskFront EdgeOrientationBits = 0b0011_0110_0000
	EdgeOrientationMaskBack  EdgeOrientationBits = 0b1100_1001_0000
)

type EdgeOrientations

type EdgeOrientations struct {
	Bits EdgeOrientationBits
}

func NewEdgeOrientationsSolved

func NewEdgeOrientationsSolved() EdgeOrientations

func (*EdgeOrientations) Apply

func (eo *EdgeOrientations) Apply(move cmn.Move)

func (EdgeOrientations) Distance

func (eo EdgeOrientations) Distance() int

func (EdgeOrientations) Equal

func (eo EdgeOrientations) Equal(other EdgeOrientations) bool

func (EdgeOrientations) Get

func (EdgeOrientations) IsSolved

func (eo EdgeOrientations) IsSolved() bool

func (*EdgeOrientations) Set

func (eo *EdgeOrientations) Set(index cmn.EdgeIndex, orientation cmn.EdgeOrientation)

type EdgePermutation

type EdgePermutation struct {
	Bits EdgePermutationBits
}

func NewEdgePermutationSolved

func NewEdgePermutationSolved() EdgePermutation

func (EdgePermutation) AllInCorrectSlice

func (ep EdgePermutation) AllInCorrectSlice() bool

func (EdgePermutation) AllInCorrectSliceDistance

func (ep EdgePermutation) AllInCorrectSliceDistance() int

func (*EdgePermutation) Apply

func (ep *EdgePermutation) Apply(move cmn.Move)

func (EdgePermutation) Distance

func (ep EdgePermutation) Distance() int

func (EdgePermutation) Equal

func (ep EdgePermutation) Equal(other EdgePermutation) bool

func (EdgePermutation) FRBLCorrectSliceDistance

func (ep EdgePermutation) FRBLCorrectSliceDistance() int

func (EdgePermutation) FRBLInCorrectSlice

func (ep EdgePermutation) FRBLInCorrectSlice() bool

func (EdgePermutation) FUBDCorrectSliceDistance

func (ep EdgePermutation) FUBDCorrectSliceDistance() int

func (EdgePermutation) FUBDInCorrectSlice

func (ep EdgePermutation) FUBDInCorrectSlice() bool

func (EdgePermutation) Get

func (ep EdgePermutation) Get(index cmn.EdgeIndex) cmn.EdgeIndex

func (EdgePermutation) IsSolved

func (ep EdgePermutation) IsSolved() bool

func (*EdgePermutation) Set

func (ep *EdgePermutation) Set(index, value cmn.EdgeIndex)

func (EdgePermutation) URBLCorrectSliceDistance

func (ep EdgePermutation) URBLCorrectSliceDistance() int

func (EdgePermutation) URBLInCorrectSlice

func (ep EdgePermutation) URBLInCorrectSlice() bool

type EdgePermutationBits

type EdgePermutationBits = uint64
const (
	EdgePermutationMaskUp    EdgePermutationBits = 0b111_000_000_111_000_000_000_000_000_111_000_111
	EdgePermutationMaskDown  EdgePermutationBits = 0b000_111_111_000_000_000_000_000_111_000_111_000
	EdgePermutationMaskLeft  EdgePermutationBits = 0b000_000_000_000_000_000_111_111_000_000_111_111
	EdgePermutationMaskRight EdgePermutationBits = 0b000_000_000_000_111_111_000_000_111_111_000_000
	EdgePermutationMaskFront EdgePermutationBits = 0b000_000_111_111_000_111_001_000_000_000_000_000
	EdgePermutationMaskBack  EdgePermutationBits = 0b111_111_000_000_111_000_000_111_000_000_000_000
)

type G3Cube

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

func ToG3Cube

func ToG3Cube(c Cube) G3Cube

func (*G3Cube) Apply

func (c *G3Cube) Apply(move cmn.Move)

type Solver

type Solver struct {
	G1CornerHeuristicTable map[CornerOrientations]uint8
	G2EdgeHeuristicTable   map[EdgePermutation]uint8
	G2CornerHeuristicTable map[CornerPermutation]uint8
	G3HeuristicTable       map[Cube]uint8
}

func GetGlobalSolver

func GetGlobalSolver() *Solver

func NewSolver

func NewSolver() *Solver

func (*Solver) IsG3

func (s *Solver) IsG3(c *Cube) bool

func (*Solver) IsG3AssumingG2

func (s *Solver) IsG3AssumingG2(c *Cube) bool

func (*Solver) PrintStats

func (s *Solver) PrintStats()

func (*Solver) Solve

func (s *Solver) Solve(cube cmn.Cube) []cmn.Move

func (*Solver) ToG1

func (s *Solver) ToG1(c *Cube) []cmn.Move

func (*Solver) ToG2

func (s *Solver) ToG2(c *Cube) []cmn.Move

func (*Solver) ToG2AssumingG1

func (s *Solver) ToG2AssumingG1(c *Cube) []cmn.Move

func (*Solver) ToG3

func (s *Solver) ToG3(c *Cube) []cmn.Move

func (*Solver) ToG3AssumingG2

func (s *Solver) ToG3AssumingG2(c *Cube) []cmn.Move

func (*Solver) ToG4

func (s *Solver) ToG4(c *Cube) []cmn.Move

func (*Solver) ToG4AssumingG3

func (s *Solver) ToG4AssumingG3(c *Cube) []cmn.Move

Jump to

Keyboard shortcuts

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