nonogram

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package nonogram implements the grid-based picture logic puzzle.

Index

Constants

This section is empty.

Variables

View Source
var DefaultKeyMap = KeyMap{
	CursorKeyMap: game.DefaultCursorKeyMap,

	FillTile: key.NewBinding(
		key.WithKeys("z"),
		key.WithHelp("z", "Fill"),
	),
	MarkTile: key.NewBinding(
		key.WithKeys("x"),
		key.WithHelp("x", "Mark"),
	),
	ClearTile: key.NewBinding(
		key.WithKeys("backspace"),
		key.WithHelp("⌫", "Clear"),
	),
}
View Source
var Modes = []list.Item{

	NewMode("Easy 5x5", "5x5 grid, ~35% filled. Simple hints.", 5, 5, 0.35),
	NewMode("Medium 5x5", "5x5 grid, ~50% filled. Balanced challenge.", 5, 5, 0.50),
	NewMode("Hard 5x5", "5x5 grid, ~65% filled. Dense hints.", 5, 5, 0.65),

	NewMode("Easy 10x10", "10x10 grid, ~35% filled. Simple hints.", 10, 10, 0.35),
	NewMode("Medium 10x10", "10x10 grid, ~50% filled. Balanced challenge.", 10, 10, 0.50),
	NewMode("Hard 10x10", "10x10 grid, ~65% filled. Dense hints.", 10, 10, 0.65),

	NewMode("Easy 15x15", "15x15 grid, ~35% filled. Simple hints.", 15, 15, 0.35),
	NewMode("Medium 15x15", "15x15 grid, ~50% filled. Balanced challenge.", 15, 15, 0.50),
	NewMode("Hard 15x15", "15x15 grid, ~65% filled. Dense hints.", 15, 15, 0.65),

	NewMode("Easy 20x20", "20x20 grid, ~35% filled. Simple hints.", 20, 20, 0.35),
	NewMode("Medium 20x20", "20x20 grid, ~50% filled. Balanced challenge.", 20, 20, 0.50),
	NewMode("Hard 20x20", "20x20 grid, ~65% filled. Dense hints.", 20, 20, 0.65),
}

Functions

func New

func New(mode NonogramMode, hints Hints) (game.Gamer, error)

Types

type Hints

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

func GenerateRandomTomography

func GenerateRandomTomography(mode NonogramMode) Hints

type KeyMap

type KeyMap struct {
	game.CursorKeyMap
	FillTile  key.Binding
	MarkTile  key.Binding
	ClearTile key.Binding
}

type Model

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

func ImportModel

func ImportModel(data []byte) (*Model, error)

func (Model) GetDebugInfo

func (m Model) GetDebugInfo() string

func (Model) GetFullHelp

func (m Model) GetFullHelp() [][]key.Binding

func (Model) GetSave

func (m Model) GetSave() ([]byte, error)

func (Model) GetTomography

func (m Model) GetTomography() Hints

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) IsSolved

func (m Model) IsSolved() bool

func (Model) SetTitle

func (m Model) SetTitle(t string) game.Gamer

func (Model) Update

func (m Model) Update(msg tea.Msg) (game.Gamer, tea.Cmd)

func (Model) View

func (m Model) View() string

type NonogramMode

type NonogramMode struct {
	game.BaseMode
	Width, Height int
	Density       float64 // target fill percentage, 0.0–1.0
}

func NewMode

func NewMode(title, description string, width, height int, density float64) NonogramMode

func (NonogramMode) Spawn

func (n NonogramMode) Spawn() (game.Gamer, error)

type Save

type Save struct {
	Solved   bool                 `json:"solved"`
	State    string               `json:"state"`
	Width    int                  `json:"width"`
	Height   int                  `json:"height"`
	RowHints TomographyDefinition `json:"row-hints"`
	ColHints TomographyDefinition `json:"col-hints"`
}

type TomographyDefinition

type TomographyDefinition [][]int

func (TomographyDefinition) RequiredLen

func (t TomographyDefinition) RequiredLen() int

func (TomographyDefinition) String

func (t TomographyDefinition) String() string

Jump to

Keyboard shortcuts

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