Class Creator

java.lang.Object
de.sfuhrm.sudoku.Creator

public final class Creator extends Object
Creates a fully filled sudoku.
Author:
Stephan Fuhrmann
  • Field Details

    • RIDDLE_4X4_EMPTY_FIELDS_VERY_EASY

      public static final int RIDDLE_4X4_EMPTY_FIELDS_VERY_EASY
      Sample value for 4x4 and difficulty very easy.
      See Also:
    • RIDDLE_4X4_EMPTY_FIELDS_EASY

      public static final int RIDDLE_4X4_EMPTY_FIELDS_EASY
      Sample value for 4x4 and difficulty easy.
      See Also:
    • RIDDLE_4X4_EMPTY_FIELDS_MEDIUM

      public static final int RIDDLE_4X4_EMPTY_FIELDS_MEDIUM
      Sample value for 4x4 and difficulty medium.
      See Also:
    • RIDDLE_4X4_EMPTY_FIELDS_HARD

      public static final int RIDDLE_4X4_EMPTY_FIELDS_HARD
      Sample value for 4x4 and difficulty hard.
      See Also:
    • RIDDLE_4X4_EMPTY_FIELDS_VERY_HARD

      public static final int RIDDLE_4X4_EMPTY_FIELDS_VERY_HARD
      Sample value for 4x4 and difficulty very hard.
      See Also:
    • RIDDLE_9X9_EMPTY_FIELDS_VERY_EASY

      public static final int RIDDLE_9X9_EMPTY_FIELDS_VERY_EASY
      Sample value for 9x9 and difficulty very easy.
      See Also:
    • RIDDLE_9X9_EMPTY_FIELDS_EASY

      public static final int RIDDLE_9X9_EMPTY_FIELDS_EASY
      Sample value for 9x9 and difficulty easy.
      See Also:
    • RIDDLE_9X9_EMPTY_FIELDS_MEDIUM

      public static final int RIDDLE_9X9_EMPTY_FIELDS_MEDIUM
      Sample value for 9x9 and difficulty medium.
      See Also:
    • RIDDLE_9X9_EMPTY_FIELDS_HARD

      public static final int RIDDLE_9X9_EMPTY_FIELDS_HARD
      Sample value for 9x9 and difficulty hard.
      See Also:
    • RIDDLE_9X9_EMPTY_FIELDS_VERY_HARD

      public static final int RIDDLE_9X9_EMPTY_FIELDS_VERY_HARD
      Sample value for 9x9 and difficulty very hard.
      See Also:
    • RIDDLE_16X16_EMPTY_FIELDS_VERY_EASY

      public static final int RIDDLE_16X16_EMPTY_FIELDS_VERY_EASY
      Sample value for 16x16 and difficulty very easy. (needs to be adjusted)
      See Also:
    • RIDDLE_16X16_EMPTY_FIELDS_EASY

      public static final int RIDDLE_16X16_EMPTY_FIELDS_EASY
      Sample value for 16x16 and difficulty easy. (needs to be adjusted)
      See Also:
    • RIDDLE_16X16_EMPTY_FIELDS_MEDIUM

      public static final int RIDDLE_16X16_EMPTY_FIELDS_MEDIUM
      Sample value for 16x16 and difficulty medium. (needs to be adjusted)
      See Also:
    • RIDDLE_16X16_EMPTY_FIELDS_HARD

      public static final int RIDDLE_16X16_EMPTY_FIELDS_HARD
      Sample value for 16x16 and difficulty hard. (needs to be adjusted)
      See Also:
    • RIDDLE_16X16_EMPTY_FIELDS_VERY_HARD

      public static final int RIDDLE_16X16_EMPTY_FIELDS_VERY_HARD
      Sample value for 16x16 and difficulty very hard. (needs to be adjusted)
      See Also:
    • RIDDLE_25X25_EMPTY_FIELDS_VERY_EASY

      public static final int RIDDLE_25X25_EMPTY_FIELDS_VERY_EASY
      Sample value for 25x25 and difficulty very easy. (needs to be adjusted)
      See Also:
    • RIDDLE_25X25_EMPTY_FIELDS_EASY

      public static final int RIDDLE_25X25_EMPTY_FIELDS_EASY
      Sample value for 25x25 and difficulty easy. (needs to be adjusted)
      See Also:
    • RIDDLE_25X25_EMPTY_FIELDS_MEDIUM

      public static final int RIDDLE_25X25_EMPTY_FIELDS_MEDIUM
      Sample value for 25x25 and difficulty medium. (needs to be adjusted)
      See Also:
    • RIDDLE_25X25_EMPTY_FIELDS_HARD

      public static final int RIDDLE_25X25_EMPTY_FIELDS_HARD
      Sample value for 25x25 and difficulty hard. (needs to be adjusted)
      See Also:
    • RIDDLE_25X25_EMPTY_FIELDS_VERY_HARD

      public static final int RIDDLE_25X25_EMPTY_FIELDS_VERY_HARD
      Sample value for 25x25 and difficulty very hard. (needs to be adjusted)
      See Also:
  • Method Details

    • createFull

      public static GameMatrix createFull()
      Creates a valid fully setup sudoku.
      Returns:
      a fully filled sudoku board. No fields are unset.
    • createFull

      public static GameMatrix createFull(GameSchema schema)
      Creates a valid fully setup sudoku.
      Parameters:
      schema - the dimensions of the game to create.
      Returns:
      a fully filled sudoku board. No fields are unset.
    • createVariant

      public static GameMatrix createVariant(GameMatrix fullyFilled)
      Creates a variant of a fully-filled game matrix. The variant is calculated very efficiently by applying simple transformations.
      Parameters:
      fullyFilled - the input matrix to transform. All fields need to be filled.
      Returns:
      a transformed variant of the input game matrix.
      Throws:
      IllegalArgumentException - if there are unset fields in the GameMatrix.
    • createRiddle

      public static Riddle createRiddle(GameMatrix fullMatrix)
      Creates a riddle setup sudoku.
      Parameters:
      fullMatrix - a fully set up (solved) and valid sudoku. Can be created using createFull() or createVariant(de.sfuhrm.sudoku.GameMatrix) of a full matrix.
      Returns:
      a maximally cleared sudoku. Contains unset value fields for places where the user/player needs to guess values.
      See Also:
    • createRiddle

      public static Riddle createRiddle(GameMatrix fullMatrix, int maxNumbersToClear)
      Creates a riddle setup sudoku.
      Parameters:
      fullMatrix - a fully set up (solved) and valid sudoku. Can be created using createFull() or createVariant(de.sfuhrm.sudoku.GameMatrix) of a full matrix.
      maxNumbersToClear - maximum amount of numbers to clear. 9x9 Sudoku:

      Total number of valid 9x9 Sudoku grids is 6,670,903,752,021,072,936,960.

      Minimal amount of givens in an initial Sudoku puzzle that can yield a unique solution is 17 (64 empty cells).

      Sample difficulty levels:

      • VERY_EASY: more than 50 given numbers, remove less than 31 numbers
      • EASY: 36-49 given numbers, remove 32-45 numbers
      • MEDIUM: 32-35 given numbers, remove 46-49 numbers
      • HARD: 28-31 given numbers, remove 50-53 numbers
      • EXPERT: 22-27 given numbers, remove 54-59 numbers
      The average maximum amount of numbers to clear with the current algorithm and 9x9 Sudoku is 56.

      16x16 Sudoku:

      The maximum amount of numbers to remove with the current algorithm in a reasonably good time is ~140.

      25x25 Sudoku:

      The maximum amount of numbers to remove with the current algorithm in a reasonably good time is ~280.

      Returns:
      a sudoku with the given amount of cleared fields (or less if clearing more cells would endanger the unique solvability of the sudoku) Contains unset value fields for places where the user/player needs to guess values.
      See Also: