Show / Hide Table of Contents

Class StandardPuzzleGenerator

Generates standard Sudoku puzzles.

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

Constructors

| Improve this Doc View Source

StandardPuzzleGenerator()

Declaration
public StandardPuzzleGenerator()

Methods

| Improve this Doc View Source

Generate(Int32, Int32, 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
System.Int32 puzzleSize

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

System.Int32 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

System.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
System.ArgumentOutOfRangeException

Thrown if numSquaresToSet is impossible for the given puzzle size.

System.TimeoutException

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

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX