Documentation ¶
Index ¶
- Constants
- func Graph(input *Board)
- type Board
- func (board *Board) AddPiece(piece Piece) bool
- func (board *Board) AddWall(i int) bool
- func (board *Board) BlockedSquares() []int
- func (board *Board) Canonicalize() *Board
- func (board *Board) Copy() *Board
- func (board *Board) DoMove(move Move)
- func (board *Board) Energy() float64
- func (board *Board) HasFullRowOrCol() bool
- func (board *Board) Hash() string
- func (board *Board) Impossible() bool
- func (board *Board) MemoKey() *MemoKey
- func (board *Board) Moves(buf []Move) []Move
- func (board *Board) Mutate() UndoFunc
- func (board *Board) ReachableStates() int
- func (board *Board) RemoveLastPiece()
- func (board *Board) RemovePiece(i int)
- func (board *Board) RemoveWall(i int)
- func (board *Board) Render() image.Image
- func (board *Board) Solve() Solution
- func (board *Board) SortPieces()
- func (board *Board) StateIterator() <-chan *Board
- func (board *Board) String() string
- func (board *Board) Target() int
- func (board *Board) UndoMove(move Move)
- func (board *Board) UnsafeSolve() Solution
- func (board *Board) UnsafeUnsolve() (*Board, Solution)
- func (board *Board) Unsolve() (*Board, Solution)
- func (board *Board) Validate() error
- type Enumerator
- type EnumeratorItem
- type Generator
- type Link
- type Memo
- type MemoKey
- type Move
- type Orientation
- type Piece
- type Solution
- type Solver
- type StaticAnalyzer
- type UndoFunc
- type Unsolver
Constants ¶
const MaxBoardSize = 16
const MaxPieces = 18
const MinBoardSize = MinPieceSize + 1
const MinPieceSize = 2
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Board ¶
type Board struct { Width int Height int Pieces []Piece Walls []int // contains filtered or unexported fields }
Board represents the complete puzzle state. The size of the grid, the placement, size, orientation of the pieces. The placement of walls (immovable obstacles). Which cells are occupied, either by a piece or a wall.
func NewBoardFromString ¶
func NewEmptyBoard ¶
func NewRandomBoard ¶
func (*Board) BlockedSquares ¶
func (*Board) Canonicalize ¶
func (*Board) HasFullRowOrCol ¶
func (*Board) Impossible ¶
func (*Board) ReachableStates ¶
func (*Board) RemoveLastPiece ¶
func (board *Board) RemoveLastPiece()
func (*Board) RemovePiece ¶
func (*Board) RemoveWall ¶
func (*Board) SortPieces ¶
func (board *Board) SortPieces()
func (*Board) StateIterator ¶
func (*Board) UnsafeSolve ¶
func (*Board) UnsafeUnsolve ¶
type Enumerator ¶
type Enumerator struct {
// contains filtered or unexported fields
}
func NewDefaultEnumerator ¶
func NewDefaultEnumerator() *Enumerator
func NewEnumerator ¶
func NewEnumerator(w, h, pr, ps, mins, maxs int) *Enumerator
func (*Enumerator) Count ¶
func (e *Enumerator) Count() uint64
func (*Enumerator) Enumerate ¶
func (e *Enumerator) Enumerate(channelBufferSize int) <-chan EnumeratorItem
func (*Enumerator) MaxGroup ¶
func (e *Enumerator) MaxGroup() int
type EnumeratorItem ¶
type Generator ¶
func NewDefaultGenerator ¶
func NewDefaultGenerator() *Generator
type MemoKey ¶
func MakeMemoKey ¶
type Move ¶
Move represents a move to make on the board. Piece indicates which piece (by index) to move and Steps is a non-zero positive or negative int that specifies how many cells to move the piece.
type Orientation ¶
type Orientation int
Orientation indicates which direction a Piece can move. Horizontal pieces can move left and right. Vertical pieces can move up and down.
const ( Horizontal Orientation = iota Vertical )
type Piece ¶
type Piece struct { Position int Size int Orientation Orientation }
Piece represents a piece (a car or a truck) on the grid. Its position is a zero-indexed int, 0 <= Position < W*H. Its size specifies how many cells it occupies. Its orientation specifies whether it is vertical or horizontal.
type Solver ¶
type Solver struct {
// contains filtered or unexported fields
}
func NewSolverWithStaticAnalyzer ¶
func NewSolverWithStaticAnalyzer(board *Board, sa *StaticAnalyzer) *Solver
func (*Solver) UnsafeSolve ¶
type StaticAnalyzer ¶
type StaticAnalyzer struct {
// contains filtered or unexported fields
}
func NewStaticAnalyzer ¶
func NewStaticAnalyzer() *StaticAnalyzer
func (*StaticAnalyzer) BlockedSquares ¶
func (sa *StaticAnalyzer) BlockedSquares(board *Board) []int
func (*StaticAnalyzer) Impossible ¶
func (sa *StaticAnalyzer) Impossible(board *Board) bool
type Unsolver ¶
type Unsolver struct {
// contains filtered or unexported fields
}
func NewUnsolver ¶
func NewUnsolverWithStaticAnalyzer ¶
func NewUnsolverWithStaticAnalyzer(board *Board, sa *StaticAnalyzer) *Unsolver