Documentation ¶
Overview ¶
Package takuzu provides functions to solve, build or validate takuzu puzzles.
Index ¶
- Constants
- func BoardsMatch(t1, t2 *Takuzu, ignoreUndefined bool) (match bool, line, col int)
- func CheckRangeCounts(cells []Cell) (full bool, n0, n1 int)
- func Copy(src, dst *Takuzu) error
- func SetSchrodingerLevel(level uint)
- func SetVerbosityLevel(level int)
- type Cell
- type Takuzu
- func (b Takuzu) CheckColumn(i int) error
- func (b Takuzu) CheckLine(i int) error
- func (b Takuzu) Clone() Takuzu
- func (b Takuzu) DumpBoard()
- func (b Takuzu) DumpString()
- func (b Takuzu) FillLineColumn(l, c int)
- func (b Takuzu) GetColumn(i int) []Cell
- func (b Takuzu) GetColumnPointers(i int) []*Cell
- func (b Takuzu) GetLine(i int) []Cell
- func (b Takuzu) GetLinePointers(i int) []*Cell
- func (tak Takuzu) ReduceBoard(trivial bool, wid string, buildBoardTimeout, reduceBoardTimeout time.Duration) (*Takuzu, error)
- func (b Takuzu) Set(l, c, value int)
- func (b Takuzu) ToString() string
- func (b Takuzu) TrivialHint() (line, col, value int)
- func (b Takuzu) TrySolveRecurse(allSolutions *[]Takuzu, timeout time.Duration) (*Takuzu, error)
- func (b Takuzu) TrySolveTrivial() (bool, error)
- func (b Takuzu) Validate() (bool, error)
Constants ¶
const ( ErrorNil = iota ErrorDuplicate ErrorTooManyValues ErrorTooManyAdjacentValues )
Variables ¶
This section is empty.
Functions ¶
func BoardsMatch ¶
BoardsMatch compares a Takuzu board to another, optionally ignoring empty cells. Returns true if the two boards match.
func CheckRangeCounts ¶
CheckRangeCounts returns true if all cells of the provided range are defined, as well as the number of 0s and the number of 1s in the range.
func SetSchrodingerLevel ¶
func SetSchrodingerLevel(level uint)
SetSchrodingerLevel initializes the "Schrödinger" level (0 means disabled) It must be called before any board generation or reduction.
func SetVerbosityLevel ¶
func SetVerbosityLevel(level int)
SetVerbosityLevel initializes the verbosity level of the resolution routines.
Types ¶
type Takuzu ¶
Takuzu is a Takuzu game board (Size x Size)
func NewFromString ¶
NewFromString creates a new Takuzu board from a string definition
func NewRandomTakuzu ¶
func NewRandomTakuzu(size int, simple bool, wid string, buildBoardTimeout, reduceBoardTimeout time.Duration, minRatio, maxRatio int) (*Takuzu, error)
NewRandomTakuzu creates a new Takuzu board with a given size
func (Takuzu) CheckColumn ¶
CheckColumn returns an error if the column i fails validation
func (Takuzu) DumpString ¶
func (b Takuzu) DumpString()
DumpString writes the content of the board as a string
func (Takuzu) FillLineColumn ¶
FillLineColumn add missing 0s or 1s if all 1s or 0s are there. Note: This method can update b.
func (Takuzu) GetColumnPointers ¶
GetColumnPointers returns a slice of pointers to the cells of the ith column of the board
func (Takuzu) GetLinePointers ¶
GetLinePointers returns a slice of pointers to the cells of the ith line of the board
func (Takuzu) ReduceBoard ¶
func (tak Takuzu) ReduceBoard(trivial bool, wid string, buildBoardTimeout, reduceBoardTimeout time.Duration) (*Takuzu, error)
ReduceBoard randomly removes as many numbers as possible from the takuzu board and returns a pointer to the new board. The initial takuzu might be modified.
func (Takuzu) TrivialHint ¶
TrivialHint returns the coordinates and the value of the first cell that can be guessed using trivial methods. It returns {-1, -1, -1} if none can be found.
func (Takuzu) TrySolveRecurse ¶
TrySolveRecurse tries to solve the takuzu recursively, using trivial method first and using guesses if it fails.
func (Takuzu) TrySolveTrivial ¶
TrySolveTrivial tries to solve the takuzu using a loop over simple methods It returns true if all cells are defined, and an error if the grid breaks the rules.