Documentation
¶
Overview ¶
DayN is an empty day to be copy/pasted for a new day It contains an Init() function to load input, setup the day, and Run to run the puzzle
Index ¶
- Constants
- Variables
- func DensityColor(cellX, cellY int, dots [8]byte) (fg, bg int, ok bool)
- func FindValue[T int | uint | byte | rune | bool](board [][]T, c T) (x, y int)
- func GetBoardValue[T int | uint | byte | rune | bool](x, y int, board [][]T) T
- func MakeBoard[T any](width, height int) [][]T
- func MustAtoi[T string | []byte](s T) int
- func ReadInputAsIntBoard(filename string) ([][]int, error)
- func ReadInputAsRunes(filename string) ([][]rune, error)
- func RenderBraille(grid [][]byte) string
- func RenderBrailleWithColor(grid [][]byte, colorFn BrailleColorFunc) string
- func Run(d Day, filename string, opts ...Option) error
- func RunVisual(d Day, filename string, opts ...Option) error
- func ValidPosition(p Point, width, height int) bool
- type BrailleColorFunc
- type Day
- type Day1
- type Day2
- type Day3
- type Day4
- type Day5
- type Day6
- type Day7
- type Day8
- type Day9
- type Day10
- type Day11
- type Day12
- type DayN
- type DayUpdate
- type Direction
- type Matrix
- type Option
- type Options
- type Point
- type PositionDirection
- type Tetrimino
Constants ¶
const ( SideUp = 0x01 SideRight = 0x02 SideDown = 0x04 SideLeft = 0x08 )
Variables ¶
var AdjacentDirections = []Direction{ DirectionUp, DirectionUpRight, DirectionRight, DirectionDownRight, DirectionDown, DirectionDownLeft, DirectionLeft, DirectionUpLeft, }
var CardinalDirections = []Direction{ DirectionUp, DirectionRight, DirectionDown, DirectionLeft, }
var (
StepStyle = lipgloss.NewStyle().Foreground(color.LightYellow11)
)
Functions ¶
func DensityColor ¶
DensityColor colors cells based on how many dots are on. 0 dots -> gray 1–2 -> blue 3–4 -> green 5–6 -> yellow 7–8 -> red
func GetBoardValue ¶
GetBoardValue returns a rune/int/bool at x,y in the input or the empty value if out of bounds
func ReadInputAsIntBoard ¶
read input as a series of rune lines
func ReadInputAsRunes ¶
read input as a series of rune lines
func RenderBraille ¶
RenderBraille renders a grid of bytes as a string of Unicode braille cells. grid[y][x] == 0 => pixel off, != 0 => pixel on.
func RenderBrailleWithColor ¶
func RenderBrailleWithColor(grid [][]byte, colorFn BrailleColorFunc) string
RenderBrailleWithColor renders a grid of bytes as a string of Unicode braille cells and uses colorFn to optionally wrap each cell in ANSI color codes.
grid[y][x] == 0 => pixel off grid[y][x] != 0 => pixel "on" with that value (used only by colorFn)
func ValidPosition ¶
Types ¶
type BrailleColorFunc ¶
BrailleColorFunc decides how to color a single Braille cell.
cellX, cellY: braille cell coordinates (0-based) in the output grid dots: 8 bytes, one per dot (1..8), 0 = off, non-zero = whatever was in grid
Return values:
fg: 0–255 for 256-color foreground, or -1 for "no fg color" bg: 0–255 for 256-color background, or -1 for "no bg color" ok: if false, RenderBrailleWithColor will render without any color
type Day1 ¶
type Day1 struct {
*Options
// contains filtered or unexported fields
}
type Day2 ¶
type Day2 struct {
*Options
// contains filtered or unexported fields
}
type Day3 ¶
type Day3 struct {
*Options
// contains filtered or unexported fields
}
type Day4 ¶
type Day4 struct {
*Options
// contains filtered or unexported fields
}
type Day5 ¶
type Day5 struct {
*Options
// contains filtered or unexported fields
}
type Day6 ¶
type Day6 struct {
*Options
// contains filtered or unexported fields
}
type Day7 ¶
type Day7 struct {
*Options
// contains filtered or unexported fields
}
type Day8 ¶
type Day8 struct {
*Options
// contains filtered or unexported fields
}
type Day9 ¶
type Day9 struct {
*Options
// contains filtered or unexported fields
}
type Day10 ¶
type Day10 struct {
*Options
// contains filtered or unexported fields
}
type Day11 ¶
type Day11 struct {
*Options
// contains filtered or unexported fields
}
type Day12 ¶
type Day12 struct {
*Options
// contains filtered or unexported fields
}
type DayN ¶
type DayN struct {
*Options
// contains filtered or unexported fields
}
type Direction ¶
type Direction int
clockwise directions
func DirectionFromOffset ¶
func (Direction) OffsetMultiplier ¶
type Matrix ¶
type Matrix [][]byte
Matrix represents the board of cells on which the game is played.
type Option ¶
type Option func(*Options)
Option is a functional option type that modifies the Options.
type PositionDirection ¶
type Tetrimino ¶
type Tetrimino struct {
// Value is the character identifier for the Tetrimino (I, O, T, S, Z, J, L).
// This is used internally and may differ from the display representation.
Value byte
// Cells represents the shape of the Tetrimino as a 2D grid.
// True indicates a Mino is present in the cell, false indicates empty space.
Cells [][]bool
// Position tracks the coordinate of the Tetrimino's top-left corner in the game matrix.
// This serves as the reference point for all movement and rotation operations.
Position Point
// contains filtered or unexported fields
}
from https://github.com/Broderick-Westrope/tetrigo/blob/main/pkg/tetris/tetrimino.go A Tetrimino is a geometric Tetris piece formed by connecting four square blocks (Minos) along their edges. Each Tetrimino has a unique shape, position, rotation state, and rotation behavior defined by the Super Rotation System (SRS).