xwgen

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2025 License: MIT Imports: 8 Imported by: 0

README

Algorithmic Crossword Generator

This repository contains the code for generating crossword puzzles as discussed in the blog post: Algorithmically Generated Crosswords: Building something 'good enough' for an NP-Complete problem.

Usage

To generate a crossword grid:

go run ./cmd/xwcli/ --file=testdata/words.txt --width=5

Run with -help for all options.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Direction

type Direction int

Direction is an enum representing the direction of a line in a grid, either 'Horizontal' or 'Vertical'.

const (
	DirectionHorizontal Direction = iota
	DirectionVertical
)

type Generator

type Generator struct {
	LineLength     int
	PreferredWords []string
	ObscureWords   []string
	ExcludedWords  []string
	MinWordLength  *int
	MaxWordLength  *int
	// contains filtered or unexported fields
}

func CreateGenerator

func CreateGenerator(lineLength int, preferredWords, obscureWords, excludedWords []string, rand *rand.Rand, params GeneratorParams) *Generator

func (*Generator) PossibleGrids

func (g *Generator) PossibleGrids(ctx context.Context) iter.Seq[Grid]

type GeneratorParams

type GeneratorParams struct {
	MinWordLength int
	MaxWordLength int
}

type Grid

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

Grid is a 2D grid of runes.

It represents a 'definite' possible grid

func NewGrid

func NewGrid(g [][]rune) Grid

func (Grid) DebugString

func (g Grid) DebugString() string

func (Grid) Get

func (g Grid) Get(x, y int) rune

func (Grid) Height

func (g Grid) Height() int

func (Grid) Repr

func (g Grid) Repr() string

func (Grid) Width

func (g Grid) Width() int

Directories

Path Synopsis
cmd
xwcli command
pkg

Jump to

Keyboard shortcuts

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