Documentation
¶
Overview ¶
Package takuzu implements the binary (Binairo) puzzle game.
Index ¶
- Constants
- Variables
- func CanPlaceInGrid(g [][]rune, size, x, y int, val rune) bool
- func CheckConstraintsGrid(g [][]rune, size int) bool
- func CloneGrid(g [][]rune) [][]rune
- func CountSolutionsGrid(g [][]rune, size, limit int) int
- func CreateEmptyGrid(size int) [][]rune
- func GenerateCompleteGrid(size int) [][]rune
- func GenerateCompleteGridSeeded(size int, rng *rand.Rand) [][]rune
- func GeneratePuzzleFromComplete(complete [][]rune, size int, prefilled float64) ([][]rune, [][]bool)
- func GeneratePuzzleFromCompleteSeeded(complete [][]rune, size int, prefilled float64, rng *rand.Rand) ([][]rune, [][]bool)
- func HasUniqueLinesGrid(g [][]rune, size int) bool
- func New(mode TakuzuMode, puzzle grid, provided [][]bool) (game.Gamer, error)
- func RenderTakuzuPDFBody(pdf *fpdf.Fpdf, data *pdfexport.TakuzuData)
- func RenderTakuzuPDFBodyWithRules(pdf *fpdf.Fpdf, data *pdfexport.TakuzuData, rules []string)
- type KeyMap
- type Model
- func (m Model) GetDebugInfo() string
- func (m Model) GetFullHelp() [][]key.Binding
- func (m Model) GetSave() ([]byte, error)
- func (m Model) Init() tea.Cmd
- func (m Model) IsSolved() bool
- func (m Model) Reset() game.Gamer
- func (m Model) SetTitle(t string) game.Gamer
- func (m Model) Update(msg tea.Msg) (game.Gamer, tea.Cmd)
- func (m Model) View() string
- type Save
- type TakuzuMode
Constants ¶
View Source
const ( EmptyCell = emptyCell ZeroCell = zeroCell OneCell = oneCell )
Variables ¶
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 = puzzle.NewDefinition(puzzle.DefinitionSpec{ Name: "Takuzu", Description: "Fill the grid with ● and ○. No 3 in a row.", Aliases: []string{"binairo", "binary"}, Modes: ModeDefinitions, DailyModeIDs: puzzle.SelectModeIDsByIndex(ModeDefinitions, 2, 3), })
View Source
var Entry = gameentry.NewEntry(gameentry.EntrySpec{ Definition: Definition, Help: HelpContent, Import: game.AdaptImport(ImportModel), Modes: Modes, Print: PDFPrintAdapter, })
View Source
var HelpContent string
View Source
var ModeDefinitions = gameentry.BuildModeDefs(Modes)
View Source
var Modes = []game.Mode{ 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), }
View Source
var PDFPrintAdapter = printAdapter{}
Functions ¶
func CanPlaceInGrid ¶ added in v1.8.0
func CheckConstraintsGrid ¶ added in v1.8.0
func CountSolutionsGrid ¶ added in v1.8.0
func CreateEmptyGrid ¶ added in v1.8.0
func GenerateCompleteGrid ¶ added in v1.8.0
func GenerateCompleteGridSeeded ¶ added in v1.8.0
func GeneratePuzzleFromComplete ¶ added in v1.8.0
func GeneratePuzzleFromCompleteSeeded ¶ added in v1.8.0
func HasUniqueLinesGrid ¶ added in v1.8.0
func New ¶
func New(mode TakuzuMode, puzzle grid, provided [][]bool) (game.Gamer, error)
New creates a new Takuzu game model.
func RenderTakuzuPDFBody ¶ added in v1.8.0
func RenderTakuzuPDFBody(pdf *fpdf.Fpdf, data *pdfexport.TakuzuData)
func RenderTakuzuPDFBodyWithRules ¶ added in v1.8.0
func RenderTakuzuPDFBodyWithRules(pdf *fpdf.Fpdf, data *pdfexport.TakuzuData, rules []string)
Types ¶
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model implements game.Gamer for Takuzu.
func ImportModel ¶
ImportModel reconstructs a Model from saved JSON data.
func (Model) GetDebugInfo ¶
func (Model) GetFullHelp ¶
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 ¶
func (TakuzuMode) SpawnSeeded ¶ added in v1.3.0
Click to show internal directories.
Click to hide internal directories.
