takuzu

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: 13 Imported by: 0

README

Takuzu

Fill the grid with two symbols following three simple rules.

Takuzu gameplay

How to Play

Fill every empty cell with either a filled circle (●) or an open circle (○) so that the grid satisfies three rules:

  1. No triple: No three consecutive identical symbols in any row or column.
  2. Equal count: Each row and column must contain exactly N/2 of each symbol.
  3. Unique lines: No two rows may be identical; no two columns may be identical.

Pre-filled cells (shown in bold) cannot be changed. The puzzle is solved when every cell is filled and all three rules are satisfied.

Controls

Key Action
Arrow keys / WASD / hjkl Move cursor
z / 0 Place ●
x / 1 Place ○
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 Clues Techniques Required
Beginner 6x6 ~50% Doubles and sandwich patterns
Easy 6x6 ~40% Counting required
Medium 8x8 ~40% Moderate deduction
Tricky 10x10 ~38% Uniqueness rule needed
Hard 10x10 ~32% Long deduction chains
Very Hard 12x12 ~30% Deep logic required
Extreme 14x14 ~28% Maximum challenge

Quick Start

puzzletea new takuzu beginner
puzzletea new takuzu medium
puzzletea new takuzu extreme
puzzletea new binairo hard       # alias

Documentation

Overview

Package takuzu implements the binary (Binairo) puzzle game.

Index

Constants

This section is empty.

Variables

View Source
var DailyModes = []list.Item{
	Modes[2],
	Modes[3],
}
View Source
var DefaultKeyMap = KeyMap{
	CursorKeyMap: game.DefaultCursorKeyMap,
	PlaceZero: key.NewBinding(
		key.WithKeys("z", "0"),
		key.WithHelp("z/0", "Place ●"),
	),
	PlaceOne: key.NewBinding(
		key.WithKeys("x", "1"),
		key.WithHelp("x/1", "Place ○"),
	),
	Clear: key.NewBinding(
		key.WithKeys("backspace", "delete"),
		key.WithHelp("bkspc", "Clear"),
	),
}
View Source
var Definition = game.Definition{
	Name:        "Takuzu",
	Description: "Fill the grid with ● and ○.",
	Aliases:     []string{"binairo", "binary"},
	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("Beginner", "6×6 grid, ~50% clues. Doubles and sandwich patterns.", 6, 0.50),
	NewMode("Easy", "6×6 grid, ~40% clues. Counting required.", 6, 0.40),
	NewMode("Medium", "8×8 grid, ~40% clues. Larger grid, moderate deduction.", 8, 0.40),
	NewMode("Tricky", "10×10 grid, ~38% clues. Uniqueness rule needed.", 10, 0.38),
	NewMode("Hard", "10×10 grid, ~32% clues. Long deduction chains.", 10, 0.32),
	NewMode("Very Hard", "12×12 grid, ~30% clues. Deep logic required.", 12, 0.30),
	NewMode("Extreme", "14×14 grid, ~28% clues. Maximum challenge.", 14, 0.28),
}

Functions

func New

func New(mode TakuzuMode, puzzle grid, provided [][]bool) (game.Gamer, error)

New creates a new Takuzu game model.

Types

type KeyMap

type KeyMap struct {
	game.CursorKeyMap
	PlaceZero key.Binding
	PlaceOne  key.Binding
	Clear     key.Binding
}

type Model

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

Model implements game.Gamer for Takuzu.

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 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 Save

type Save struct {
	Size      int    `json:"size"`
	State     string `json:"state"`
	Provided  string `json:"provided"`
	ModeTitle string `json:"mode_title"`
}

Save represents the serialized state of a Takuzu game.

type TakuzuMode

type TakuzuMode struct {
	game.BaseMode
	Size      int
	Prefilled float64
}

func NewMode

func NewMode(title, desc string, size int, prefilled float64) TakuzuMode

func (TakuzuMode) Spawn

func (t TakuzuMode) Spawn() (game.Gamer, error)

func (TakuzuMode) SpawnSeeded added in v1.3.0

func (t TakuzuMode) SpawnSeeded(rng *rand.Rand) (game.Gamer, error)

Jump to

Keyboard shortcuts

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