puzzle

package
v0.0.0-...-4684404 Latest Latest
Warning

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

Go to latest
Published: May 1, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintPuzzle

func PrintPuzzle(puzzle Puzzle)

PrintPuzzle prints the grid of the puzzle one row at a time. It takes in a parameter puzzle of type Puzzle.

func ReadWordsFromFile

func ReadWordsFromFile(filePath string) ([]string, error)

func SavePuzzleToFile

func SavePuzzleToFile(puzzle Puzzle, filename string, includeSolution bool) error

SavePuzzleToFile saves the puzzle grid to a file with the specified filename.

Types

type Dictionary

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

func LoadDictionary

func LoadDictionary(dictionaryPath string) (*Dictionary, error)

func (*Dictionary) CloseMatches

func (d *Dictionary) CloseMatches(word string) []string

func (*Dictionary) RandomWord

func (d *Dictionary) RandomWord() string

func (*Dictionary) RandomWords

func (d *Dictionary) RandomWords(count int) []string

type Grid

type Grid [][]rune

type Puzzle

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

func GeneratePDF

func GeneratePDF(puzzle Puzzle, title string, words []string, columns int, outputFile string,
	backgroundFile string) (Puzzle, error)

func GeneratePuzzle

func GeneratePuzzle(gridSize int, words []string, columns int, difficulty int, dictionaryPath string,
	verbose bool) (Puzzle, error)

GeneratePuzzle creates a Word Search puzzle based on the provided gridSize, words, columns, and difficulty. The dictionaryPath is used to load the dictionary for generating random letters in the grid.

type PuzzleConfig

type PuzzleConfig struct {
	Title          string   `yaml:"title"`
	Size           int      `yaml:"size"`
	Columns        int      `yaml:"columns"`
	Difficulty     int      `yaml:"difficulty"`
	Words          []string `yaml:"words"`
	OutputBasename string   `yaml:"output_basename"`
	Background     string   `yaml:"background"`
}

func ParseConfig

func ParseConfig(filename string) (*PuzzleConfig, error)

Jump to

Keyboard shortcuts

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