hitori

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 17 Imported by: 0

README

Hitori

Shade cells to eliminate duplicate numbers in every row and column.

Hitori gameplay

How to Play

The grid starts filled with numbers. Shade some cells black so that three rules are satisfied:

  1. No duplicates: No number appears more than once in any row or column among the unshaded (white) cells.
  2. No adjacent shading: No two shaded cells share an edge (diagonal is fine).
  3. White connectivity: All unshaded cells must form a single orthogonally connected region.

The puzzle is solved when all three rules hold simultaneously.

Controls

Key Action
Arrow keys / WASD / hjkl Move cursor
Mouse left-click Focus a cell
x Shade cell (toggle)
z Circle cell as confirmed white (toggle)
Backspace Clear cell to unmarked
Ctrl+H Toggle full help
Ctrl+R Reset puzzle
Escape Return to main menu

Modes

Mode Grid Description
Mini 5x5 Gentle introduction
Easy 6x6 Straightforward logic
Medium 8x8 Moderate challenge
Tricky 9x9 Requires careful deduction
Hard 10x10 Advanced logic chains
Expert 12x12 Maximum challenge

Quick Start

puzzletea new hitori mini
puzzletea new hitori medium
puzzletea new hitori expert

Documentation

Overview

Package hitori implements the Hitori number puzzle game.

Index

Constants

This section is empty.

Variables

View Source
var DefaultKeyMap = KeyMap{
	CursorKeyMap: game.DefaultCursorKeyMap,
	ShadeCell: key.NewBinding(
		key.WithKeys("x"),
		key.WithHelp("x", "Shade"),
	),
	CircleCell: key.NewBinding(
		key.WithKeys("z"),
		key.WithHelp("z", "Circle"),
	),
	ClearCell: key.NewBinding(
		key.WithKeys("backspace", "delete"),
		key.WithHelp("bkspc", "Clear"),
	),
}
View Source
var Definition = puzzle.NewDefinition(puzzle.DefinitionSpec{
	Name:         "Hitori",
	Description:  "Shade the cells to eliminate duplicates.",
	Modes:        ModeDefinitions,
	DailyModeIDs: puzzle.SelectModeIDsByIndex(ModeDefinitions, 1, 2),
})
View Source
var HelpContent string
View Source
var ModeDefinitions = gameentry.BuildModeDefs(Modes)
View Source
var Modes = []game.Mode{
	NewMode("Mini", "5\u00d75 grid, gentle introduction.", 5, 0.32),
	NewMode("Easy", "6\u00d76 grid, straightforward logic.", 6, 0.32),
	NewMode("Medium", "8\u00d78 grid, moderate challenge.", 8, 0.30),
	NewMode("Tricky", "9\u00d79 grid, requires careful deduction.", 9, 0.30),
	NewMode("Hard", "10\u00d710 grid, advanced logic chains.", 10, 0.30),
	NewMode("Expert", "12\u00d712 grid, maximum challenge.", 12, 0.28),
}
View Source
var PDFPrintAdapter = printAdapter{}

Functions

func Generate

func Generate(size int, blackRatio float64) (grid, error)

Generate creates a Hitori puzzle of the given size. Returns the puzzle numbers grid or an error if generation fails after all attempts.

func GenerateSeeded

func GenerateSeeded(size int, blackRatio float64, rng *rand.Rand) (grid, error)

func New

func New(mode HitoriMode, numbers grid) (game.Gamer, error)

New creates a new Hitori game model.

Types

type HitoriMode

type HitoriMode struct {
	game.BaseMode
	Size       int
	BlackRatio float64
}

func NewMode

func NewMode(title, desc string, size int, blackRatio float64) HitoriMode

func (HitoriMode) Spawn

func (h HitoriMode) Spawn() (game.Gamer, error)

func (HitoriMode) SpawnSeeded

func (h HitoriMode) SpawnSeeded(rng *rand.Rand) (game.Gamer, error)

type KeyMap

type KeyMap struct {
	game.CursorKeyMap
	ShadeCell  key.Binding
	CircleCell key.Binding
	ClearCell  key.Binding
}

type Model

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

Model implements game.Gamer for Hitori.

func ImportModel

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

ImportModel reconstructs a Model from saved JSON data.

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

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 Save

type Save struct {
	Size      int    `json:"size"`
	Numbers   string `json:"numbers"`
	Marks     string `json:"marks"`
	ModeTitle string `json:"mode_title"`
}

Save represents the serialized state of a Hitori game.

Jump to

Keyboard shortcuts

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