Show / Hide Table of Contents

Class StandardPuzzleGenerator

Generates standard Sudoku puzzles.

Inheritance
object
PuzzleGenerator<PuzzleWithPossibleValues>
StandardPuzzleGenerator
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: SudokuSpice.RuleBased
Assembly: SudokuSpice.dll
Syntax
public class StandardPuzzleGenerator : PuzzleGenerator<PuzzleWithPossibleValues>

Constructors

| Edit this page View Source

StandardPuzzleGenerator()

Declaration
public StandardPuzzleGenerator()

Methods

| Edit this page View Source

Generate(int, int, TimeSpan)

Generates a puzzle that has a unique solution with the given number of squares set.

Be careful calling this with low values, as it can take a very long time to generate unique puzzles as the value of numSquaresToSet approaches the minimum number of clues necessary to provide a unique puzzle of the given puzzleSize.

Declaration
public PuzzleWithPossibleValues Generate(int puzzleSize, int numSquaresToSet, TimeSpan timeout)
Parameters
Type Name Description
int puzzleSize

The size (i.e. side-length) of the puzzle to generate.

int numSquaresToSet

The number of squares that will be preset in the generated puzzle.

Valid ranges are 0-1 for puzzles of size 1, 4-16 for puzzles of size 4, 17-81 for puzzles of size 9, 55-256 for puzzles of size 16, and 185 - 625 for puzzles of size 25. Note that the lower bounds for puzzles sized 16 or 25 are estimates from this forum: http://forum.enjoysudoku.com/minimum-givens-on-larger-puzzles-t4801.html

TimeSpan timeout

The maximum timeout during which this function can search for a unique puzzle. Especially useful when trying to generate puzzles with low numSquaresToSet.

Returns
Type Description
PuzzleWithPossibleValues

A standard Sudoku puzzle with a unique solution and numSquaresToSet preset squares.

Exceptions
Type Condition
ArgumentOutOfRangeException

Thrown if numSquaresToSet is impossible for the given puzzle size.

TimeoutException

Thrown if no valid unique puzzle is found within the specified timeout.

  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX