Skip to content

Commit

Permalink
Merge pull request #60 from teogor/enhancement/expose-generator
Browse files Browse the repository at this point in the history
Enable User-Driven Sudoku Generation with Public SudokuGenerator
  • Loading branch information
teogor committed Mar 2, 2024
2 parents af78838 + b530ab2 commit 841d6ac
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
6 changes: 6 additions & 0 deletions sudoklify-core/api/sudoklify-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ public final class dev/teogor/sudoklify/core/generation/ParamsBuilderKt {
public static final fun sudokuType (Ldev/teogor/sudoklify/core/generation/ParamsBuilder;Lkotlin/jvm/functions/Function0;)V
}

public final class dev/teogor/sudoklify/core/generation/SudokuGenerator {
public fun <init> ([Ldev/teogor/sudoklify/common/model/SudokuBlueprint;Lkotlin/random/Random;Ldev/teogor/sudoklify/common/types/SudokuType;Ldev/teogor/sudoklify/common/types/Difficulty;)V
public final fun composeSudokuPuzzle ()Ldev/teogor/sudoklify/common/model/Sudoku;
public final fun createPuzzle ()Ldev/teogor/sudoklify/common/model/SudokuPuzzle;
}

public final class dev/teogor/sudoklify/core/generation/SudokuGeneratorKt {
public static final fun createPuzzle (Ldev/teogor/sudoklify/common/model/SudokuParams;)Ldev/teogor/sudoklify/common/model/SudokuPuzzle;
public static final fun generateSudoku (Ldev/teogor/sudoklify/common/model/SudokuParams;)Ldev/teogor/sudoklify/common/model/Sudoku;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import dev.teogor.sudoklify.ktx.toJEncodedCell
import kotlin.math.sqrt
import kotlin.random.Random

internal class SudokuGenerator internal constructor(
class SudokuGenerator internal constructor(
private val seeds: Array<SudokuBlueprint>,
private val seed: Seed,
private val sudokuType: SudokuType,
Expand All @@ -48,14 +48,13 @@ internal class SudokuGenerator internal constructor(
private val tokenizer: Tokenizer = Tokenizer.create(boxDigits)

@Deprecated(
message =
"""
This constructor is deprecated. Use the primary constructor
`SudokuGenerator(seeds, seed, sudokuType, difficulty)` instead.
""",
message = """
|This constructor is deprecated. Use the primary constructor
|`SudokuGenerator(seeds, seed, sudokuType, difficulty)` instead.
|""",
replaceWith = ReplaceWith("SudokuGenerator(seeds, seed, sudokuType, difficulty)"),
)
internal constructor(
constructor(
seeds: Array<SudokuBlueprint>,
random: Random,
sudokuType: SudokuType,
Expand All @@ -70,16 +69,16 @@ internal class SudokuGenerator internal constructor(

@Deprecated(
message =
"""
The composeSudokuPuzzle() method is deprecated. To create a Sudoku puzzle, use the more
versatile and efficient createPuzzle() method, which returns a SudokuPuzzle object with
additional features and utility methods. For compatibility with existing code,
composeSudokuPuzzle() also returns a Sudoku object, but it's recommended to transition to
using the richer functionality of SudokuPuzzle.
"""
|The composeSudokuPuzzle() method is deprecated. To create a Sudoku puzzle, use the more
|versatile and efficient createPuzzle() method, which returns a SudokuPuzzle object with
|additional features and utility methods. For compatibility with existing code,
|composeSudokuPuzzle() also returns a Sudoku object, but it's recommended to transition to
|using the richer functionality of SudokuPuzzle.
""",
replaceWith = ReplaceWith("createPuzzle()"),
)
internal fun composeSudokuPuzzle(): Sudoku {
fun composeSudokuPuzzle(): Sudoku {
val seed = getSeed(seeds, difficulty)
val layout = getLayout(baseLayout)
val tokenMap = getTokenMap()
Expand All @@ -90,7 +89,7 @@ internal class SudokuGenerator internal constructor(
return Sudoku(puzzle, solution, seed.difficulty, sudokuType)
}

internal fun createPuzzle(): SudokuPuzzle {
fun createPuzzle(): SudokuPuzzle {
val seed = getSeed(seeds, difficulty)
val layout = getLayout(baseLayout)
val tokenMap = getTokenMap()
Expand Down

0 comments on commit 841d6ac

Please sign in to comment.