generator

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2022 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generators

func Generators() []string

Generators returns the names of all available Generators.

func Seed

func Seed(n int64)

Seed seeds the random number Generator. MarkUsed this to reproduce results when needed. Default seed is the time at the start of execution.

Types

type Generator

type Generator interface {
	Debug() bool
	Name() string
	Generate(grid *sudoku.Grid) (*sudoku.Grid, error)
	RNG() *rand.Rand
}

Generator defines a method to take Difficulty as input and generate a valid and solvable Sudoku Grid.

func BackTrackingGenerator

func BackTrackingGenerator(opts ...Option) Generator

BackTrackingGenerator generates a Grid with the back-tracking algorithm.

func BruteForceGenerator

func BruteForceGenerator(opts ...Option) Generator

BruteForceGenerator generates a Grid with brute-force. There is no intelligent algorithm to it and this has a chance to fail and hence the obscene amount of retries that are attempted.

type Option

type Option func(g Generator)

Option customized the behavior of one or more Generators.

func WithBlockOrder

func WithBlockOrder(order []int) Option

WithBlockOrder customizes the order of priority of blocks to be filled.

Applies to:

  • BackTrackingGenerator

func WithDebug

func WithDebug() Option

WithDebug enables debug logging.

Applies to:

  • BackTrackingGenerator
  • BruteForceGenerator

func WithProgress

func WithProgress() Option

WithProgress enables the Generators to show each step of the solution. The 'waitInterval' value dictates how long to wait between each cycle.

Applies to:

  • BackTrackingGenerator
  • BruteForceGenerator

func WithRNG

func WithRNG(rng *rand.Rand) Option

WithRNG customizes the WithRNG used by the Generator.

Applies to:

  • BackTrackingGenerator
  • BruteForceGenerator

func WithSubGridOrder

func WithSubGridOrder(order [][]int) Option

WithSubGridOrder customizes the order of priority of SubGirds to be filled.

Applies to:

  • BruteForceGenerator

Jump to

Keyboard shortcuts

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