tile

package
v0.0.0-...-39567c2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EdgeDual

func EdgeDual(a int) int

EdgeDual returns the "dual" of a given edge value (i.e. its value with bits read in the other direction).

func ReadLine

func ReadLine(ch chan readinp.Line[string]) (string, error)

ReadLine reads a single line from the given channel and trims it. Returns EOF error on eof, or any other errors.

Types

type Map

type Map struct {
	// contains filtered or unexported fields
}

Map is the structure of a set of tiles.

func ReadFile

func ReadFile(filename string) (*Map, error)

ReadFile reads an input file and produces a tile Map.

func (Map) GetTile

func (tm Map) GetTile(tileNum int) *Tile

GetTile returns the numbered tile.

func (*Map) Rotate

func (tm *Map) Rotate(tileNum, rotate int)

Rotate rotates the given tile n times counterclockwise.

type Tile

type Tile struct {
	// contains filtered or unexported fields
}

Tile is a tile from day 20 of advent of code 2020.

func ParseLines

func ParseLines(lines []string) (*Tile, error)

ParseLines parses a number of lines to produce a single tile.

func Read

func Read(ch chan readinp.Line[string]) (*Tile, error)

Read reads a tile from the given readinp channel and returns it.

func (Tile) EdgeMatches

func (t Tile) EdgeMatches(e, val int) bool

EdgeMatches determines whether the edge matches the given value.

func (*Tile) Flip

func (t *Tile) Flip()

Flip flips the tile across y axis.

func (Tile) Get

func (t Tile) Get(y, x int) bool

Get tells whether the given pixel is set, based on the contents of the tile and its rotation state.

func (Tile) GetNeighbor

func (t Tile) GetNeighbor(e int) int

GetNeighbor returns the neighbor number on the given edge, after rotation/flip (0 if none)

func (Tile) HasNeighbor

func (t Tile) HasNeighbor(e int) bool

HasNeighbor returns whether there is a

func (Tile) ID

func (t Tile) ID() int

ID returns the ID of the tile.

func (*Tile) MatchEdge

func (t *Tile) MatchEdge(e, val int)

MatchEdge flips and rotates the tile until the given value is on the given edge.

func (Tile) NumNeighbors

func (t Tile) NumNeighbors() int

NumNeighbors returns the number of matched neighbors.

func (Tile) ReadEdge

func (t Tile) ReadEdge(e int) int

ReadEdge reads the binary value of the bits on the given edge. edges are: 0(top), 1(left), 2(bottom), 3(right)

func (*Tile) Rotate

func (t *Tile) Rotate(n int)

Rotate rotates the tile counterclockwise n times.

func (*Tile) SetNeighborFromEdgeMap

func (t *Tile) SetNeighborFromEdgeMap(edgeMap map[int][]int)

SetNeighborFromEdgeMap sets the neighbors from a collected map of edge value to matching tiles.

func (Tile) String

func (t Tile) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL