Documentation
¶
Overview ¶
Main labyrinth functionality
Index ¶
- Constants
- type Coordinates
- type Field
- func (f *Field) At(c Coordinates) (cell, error)
- func (f *Field) CountCells() map[cell]uint
- func (Field) Error(s string) error
- func (f *Field) FillEmptyCellsWithWalls()
- func (f *Field) GetLabyrinth() [][]uint
- func (f *Field) Init(filename string) error
- func (f *Field) LoadLabyrinth(l [][]uint) error
- func (f *Field) LoadLabyrinthFromFile(file_path string) error
- func (f *Field) MakeEmpty(leave_start_and_finish bool)
- func (f *Field) SaveLabyrinthToFile(file_path string) error
- func (f *Field) Set(new_cell cell, c Coordinates) error
- func (f *Field) SetSize(width, length uint)
- func (f *Field) SetStartAndFinish(start, finish Coordinates)
- func (f *Field) Size() uint
- func (f Field) String() string
- type Route
Constants ¶
const ( Empty cell = iota Wall Start Finish Path Unknown // should always be last for type validation )
Enum for possible things placed in a cell
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Coordinates ¶
type Coordinates struct {
X, Y int
}
Simply a coordinate pair to show the placement of a Cell
func (Coordinates) Distance ¶
func (c Coordinates) Distance(dest Coordinates) float64
Calculate distance between two coordinates
func (Coordinates) IsValid ¶
func (c Coordinates) IsValid(maxX, maxY uint) bool
Check that coordinates are within bounds
func (Coordinates) String ¶
func (c Coordinates) String() string
String representation of coordinates struct
type Field ¶
type Field struct {
Width, Length uint
Start, Finish Coordinates
Configuration *configuration
// contains filtered or unexported fields
}
Container for labyrinth and additional characteristics
func (*Field) At ¶
func (f *Field) At(c Coordinates) (cell, error)
Get cell type at given coordinates
func (*Field) CountCells ¶
Count all cell types in the labyrinth
func (*Field) FillEmptyCellsWithWalls ¶
func (f *Field) FillEmptyCellsWithWalls()
Replace paths with empty cells and fill the rest with walls
func (*Field) GetLabyrinth ¶
Return serialized labyrinth data
func (*Field) LoadLabyrinth ¶
Load labyrinth from input data
func (*Field) LoadLabyrinthFromFile ¶
Deserialize and load labyrinth data from file
func (*Field) SaveLabyrinthToFile ¶
Save serialized labyrinth data to file in existing directory
func (*Field) Set ¶
func (f *Field) Set(new_cell cell, c Coordinates) error
Change cell type at the chosen coordinates
func (*Field) SetStartAndFinish ¶
func (f *Field) SetStartAndFinish(start, finish Coordinates)
Set start and finish points
type Route ¶
Linked list to represent a route
func (*Route) GetIterator ¶
func (r *Route) GetIterator() func() (Coordinates, bool)
Return iterator to go over the entire Route