Documentation ¶
Index ¶
- Constants
- Variables
- type Format
- type Maze
- func (maze *Maze) Clear()
- func (maze *Maze) Connected(point *Point, target *Point) bool
- func (maze *Maze) Contains(point *Point) bool
- func (maze *Maze) Generate()
- func (maze *Maze) Move(direction int)
- func (maze *Maze) Neighbors(point *Point) (neighbors []int)
- func (maze *Maze) Next(point *Point) *Point
- func (maze *Maze) Print(writer io.Writer, format *Format)
- func (maze *Maze) PrintImage(writer io.Writer, format *Format, scale int)
- func (maze *Maze) Solve()
- func (maze *Maze) Undo()
- func (maze *Maze) Write(writer chan string, format *Format)
- type Point
Constants ¶
View Source
const ( Up = 1 << iota Down Left Right )
Maze cell configurations The paths of the maze is represented in the binary representation.
View Source
const ( SolutionOffset = 4 VisitedOffset = 8 )
The solution path is represented by (Up|Down|Left|Right) << SolutionOffset. The user's path is represented by (Up|Down|Left|Right) << VisitedOffset.
Variables ¶
View Source
var Color = &Format{
Wall: "\x1b[7m \x1b[0m",
Path: " ",
StartLeft: "S ",
StartRight: " S",
GoalLeft: "G ",
GoalRight: " G",
Solution: "\x1b[44;1m \x1b[0m",
SolutionStartLeft: "\x1b[44;1mS \x1b[0m",
SolutionStartRight: "\x1b[44;1m S\x1b[0m",
SolutionGoalLeft: "\x1b[44;1mG \x1b[0m",
SolutionGoalRight: "\x1b[44;1m G\x1b[0m",
Visited: "\x1b[42;1m \x1b[0m",
VisitedStartLeft: "\x1b[42;1mS \x1b[0m",
VisitedStartRight: "\x1b[42;1m S\x1b[0m",
VisitedGoalLeft: "\x1b[42;1mG \x1b[0m",
VisitedGoalRight: "\x1b[42;1m G\x1b[0m",
Cursor: "\x1b[43;1m \x1b[0m",
}
Color format
View Source
var Default = &Format{
Wall: "##",
Path: " ",
StartLeft: "S ",
StartRight: " S",
GoalLeft: "G ",
GoalRight: " G",
Solution: "::",
SolutionStartLeft: "S:",
SolutionStartRight: ":S",
SolutionGoalLeft: "G:",
SolutionGoalRight: ":G",
Visited: "..",
VisitedStartLeft: "S.",
VisitedStartRight: ".S",
VisitedGoalLeft: "G.",
VisitedGoalRight: ".G",
Cursor: "::",
}
Default format
Directions is the set of all the directions
Opposite directions
Functions ¶
This section is empty.
Types ¶
type Format ¶
type Format struct { Wall string Path string StartLeft string StartRight string GoalLeft string GoalRight string Solution string SolutionStartLeft string SolutionStartRight string SolutionGoalLeft string SolutionGoalRight string Visited string VisitedStartLeft string VisitedStartRight string VisitedGoalLeft string VisitedGoalRight string Cursor string }
Format is the printing format of the maze
type Maze ¶
type Maze struct { Directions [][]int Height int Width int Start *Point Goal *Point Cursor *Point Solved bool Started bool Finished bool }
Maze represents the configuration of a maze
func (*Maze) PrintImage ¶ added in v0.0.1
PrintImage outputs the maze to the IO writer as PNG image
Click to show internal directories.
Click to hide internal directories.