Documentation
¶
Index ¶
- Variables
- type Bottle
- func (b Bottle) BottomColor() Color
- func (b Bottle) Clone() Bottle
- func (b Bottle) FreeSlots() int
- func (b Bottle) MarshalJSON() ([]byte, error)
- func (b Bottle) MarshalText() ([]byte, error)
- func (b *Bottle) MinRequiredMoves() int
- func (b *Bottle) PourOnto(other *Bottle) error
- func (b Bottle) TopColor() Color
- func (b Bottle) TopColorCount() int
- func (b *Bottle) UnmarshalJSON(data []byte) error
- func (b *Bottle) UnmarshalText(text []byte) error
- type Color
- type Option
- type State
- func (s *State) Apply(step Step) error
- func (s State) BottleSize() int
- func (s State) Clone() State
- func (s State) MarshalJSON() ([]byte, error)
- func (s State) MarshalText() ([]byte, error)
- func (s State) Solve(opts ...Option) ([]Step, error)
- func (s State) Solved() bool
- func (s *State) UnmarshalJSON(data []byte) error
- func (s *State) UnmarshalText(text []byte) error
- type Step
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoSolution = errors.New("there is no solution")
Functions ¶
This section is empty.
Types ¶
type Bottle ¶
type Bottle struct {
Colors []Color
}
func (Bottle) BottomColor ¶
func (Bottle) MarshalJSON ¶
func (Bottle) MarshalText ¶
func (*Bottle) MinRequiredMoves ¶
func (Bottle) TopColorCount ¶
func (*Bottle) UnmarshalJSON ¶
func (*Bottle) UnmarshalText ¶
type State ¶
type State struct {
Bottles []Bottle
}
func RandomState ¶
func (State) BottleSize ¶
func (State) MarshalJSON ¶
func (State) MarshalText ¶
func (State) Solve ¶
Solve calculates an optimal solution for s using an A* search algorithm.
The score of each (partial) solution is calculated as the sum of the number of steps so far (len(Solution.Steps)) and Solution.State.MinRequiredMoves().
If s is unsolvable, an error is returned. Use `errors.Is(ErrNoSolution)` to distinguish between this and other errors.
func (*State) UnmarshalJSON ¶
func (*State) UnmarshalText ¶
Click to show internal directories.
Click to hide internal directories.