nonogram

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: MIT Imports: 19 Imported by: 0

README

Nonogram

Fill cells to match row and column hints, revealing a hidden pattern.

Nonogram gameplay

How to Play

Navigate the grid and fill or mark cells based on the numeric hints along each row and column. The hints tell you how many consecutive filled cells appear in that line, in order. Hints turn green when a row or column is correctly satisfied.

  • Filled cells count toward hint satisfaction.
  • Marked cells are visual reminders that a cell should stay empty.
  • The puzzle is solved when every row and column matches its hints.

Controls

Key Action
Arrow keys / WASD / hjkl Move cursor
z Fill cell
x Mark cell
Backspace Clear cell
Ctrl+R Reset puzzle
Ctrl+H Toggle full help
Ctrl+E Toggle debug overlay
Ctrl+N Return to main menu

Modes

Mode Grid Fill Description
Mini 5x5 ~65% Quick puzzle, straightforward hints
Pocket 5x5 ~50% Compact but balanced
Teaser 5x5 ~35% Small but tricky
Standard 10x10 ~67% Classic size, dense hints
Classic 10x10 ~52% The typical nonogram experience
Tricky 10x10 ~37% Sparse hints require reasoning
Large 15x15 ~69% Bigger grid, constraining hints
Grand 15x15 ~54% A substantial challenge
Epic 20x20 ~71% A epic undertaking
Massive 20x20 ~56% Truly massive puzzle

Quick Start

puzzletea new nonogram mini
puzzletea new nonogram classic
puzzletea new nonogram massive

Documentation

Overview

Package nonogram implements the grid-based picture logic puzzle.

Index

Constants

This section is empty.

Variables

View Source
var DailyModes = []list.Item{
	Modes[3],
	Modes[4],
}
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("bkspc", "Clear"),
	),
}
View Source
var Definition = game.Definition{
	Name:        "Nonogram",
	Description: "Fill cells to match row and column hints.",
	Modes:       Modes,
	DailyModes:  DailyModes,
	Help:        HelpContent,
	Import:      func(data []byte) (game.Gamer, error) { return ImportModel(data) },
}
View Source
var HelpContent string
View Source
var Modes = []list.Item{

	NewMode("Mini", "5x5 grid, ~65% filled. Quick puzzle, straightforward hints.", 5, 5, 0.65),
	NewMode("Pocket", "5x5 grid, ~50% filled. Compact but balanced.", 5, 5, 0.50),
	NewMode("Teaser", "5x5 grid, ~35% filled. Small but tricky.", 5, 5, 0.35),

	NewMode("Standard", "10x10 grid, ~67% filled. Classic size, dense hints.", 10, 10, 0.67),
	NewMode("Classic", "10x10 grid, ~52% filled. The typical nonogram experience.", 10, 10, 0.52),
	NewMode("Tricky", "10x10 grid, ~37% filled. Sparse hints require reasoning.", 10, 10, 0.37),

	NewMode("Large", "15x15 grid, ~69% filled. Bigger grid, constraining hints.", 15, 15, 0.69),
	NewMode("Grand", "15x15 grid, ~54% filled. A substantial challenge.", 15, 15, 0.54),

	NewMode("Epic", "20x20 grid, ~71% filled. A epic undertaking.", 20, 20, 0.71),
	NewMode("Massive", "20x20 grid, ~56% filled. Truly massive puzzle.", 20, 20, 0.56),
}

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

func GenerateRandomTomographySeeded added in v1.3.0

func GenerateRandomTomographySeeded(mode NonogramMode, rng *rand.Rand) 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) Init

func (m Model) Init() tea.Cmd

func (Model) IsSolved

func (m Model) IsSolved() bool

func (Model) Reset added in v1.3.0

func (m Model) Reset() game.Gamer

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)

func (NonogramMode) SpawnSeeded added in v1.3.0

func (n NonogramMode) SpawnSeeded(rng *rand.Rand) (game.Gamer, error)

type Save

type Save struct {
	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