Documentation ¶
Index ¶
- func Fill(c *Canvas) int
- type Canvas
- func (c *Canvas) At(p point.Point2D) int
- func (c *Canvas) Count() int
- func (c *Canvas) CountColor(color int) int
- func (c *Canvas) Draw(drawFn func(int, int, int))
- func (c *Canvas) Height() int
- func (c *Canvas) Paint(p point.Point2D, color int)
- func (c *Canvas) PrintTo(w io.Writer)
- func (c *Canvas) Width() int
- type Direction
- type Mapper
- type PathFinder
- type Status
- type Tile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Canvas ¶
type Canvas struct {
// contains filtered or unexported fields
}
Canvas is an infinitely paintable 2D surface.
func (*Canvas) CountColor ¶
CountColor returns the number of points painted with the given color.
func (*Canvas) Draw ¶
Draw calls the provided drawFn for every square on the canvas, regardless of whether it has been painted to.
func (*Canvas) Paint ¶
Paint paints a point with a color, extending the bounds of the canvas if needed.
type Direction ¶
type Direction int
Direction is a cardinal direction that the robot can be instructed to move in.
type Mapper ¶
type Mapper struct {
// contains filtered or unexported fields
}
Mapper is responsible for constructing a map of a location by controlling a robot with an Intcode program.
type PathFinder ¶
type PathFinder struct {
// contains filtered or unexported fields
}
PathFinder finds paths between a start and goal point on a map.
func NewPathFinder ¶
func NewPathFinder(canvas *Canvas, goal point.Point2D) *PathFinder
NewPathFinder creates a new path finder with a given map and goal.
func (*PathFinder) ShortestPath ¶
func (pf *PathFinder) ShortestPath() []point.Point2D
ShortestPath finds the shortest path from (0, 0) to the path finder's goal. Returns the list of points that form the path, starting from the goal and ending with the start point, including both.
type Status ¶
type Status int
Status is a status code that can be returned from the Intcode program.
const ( // HitWall signals that the droid hit a wall and was not able to move. HitWall Status = iota // Moved signals that the droid moved in the requested direction but // did not find the destination. Moved // FoundDestination signals that the droid moved in the requested // direction and found the destination. FoundDestination )
type Tile ¶
type Tile int
Tile is a type of tile drawn on a map.
const ( // TileUnknown is a tile that hasn't been discovered TileUnknown Tile = iota // TilePassable is a tile that the droid can enter TilePassable // TileWall is a tile that is an impassable wall TileWall // TileDestination is the tile with the goal TileDestination // TileStart is the location where the droid started TileStart )