How Can I make a Sudoku Generator?

Hi, I’m working on my Sudoku game.
I planned it to make a Sudoku Generator instead of wasting time to use hand-make Sudoku.
And I grouped every Lines of blocks Named by the alphabet on the left side.
How can I do it?

Here’s my model:

I’m not a scripter, nor do I pretend to be. But I am an avid Sudoku fan, and I wanted to help by putting in my two cents.

First off(and you probably already know this), you can use an RNG with checks to create each number block. The following system is one I thought of(without regard to feasibility or efficiency) to create the puzzles.

  1. RNG generates a random number in a random square one at a time, checking against that number already being in the column, row, or box.
  2. RNG completes the puzzle, then second RNG removes random numbers until x amount remains(depending on difficulty).
  3. RNG is checked against making a truly impossible puzzle by being limited to no less than 17 clues for the hardest difficulty.

This is probably neither feasible nor efficient, but it is one way to do it. I’m not familiar with Lua to give you tips on how to accomplish this. Another possible method is to have a random generator do the same thing but create 100 puzzles for each difficult, then import those into the game with a RNG selecting which one is played by the player. Then every update cycle you can add more puzzles, as you check which ones are complete able and which ones are not.

I know this isn’t greatly helpful, but I wanted to try to give you a hand. At any rate, I wish you the best of luck and hope to play it often when it releases!!

1 Like

Although I generated the Sudoku, It was randomized and unable to solve.
(Because the Sudoku was already wrong)

I found a sudoku generator written in Lua on Github. I recommend checking that out. I can’t link it because of DevForum rules though. Just be warned, it’s over 1000 lines long.

Github should be fine. (The rule in question) is specific to #bulletin-board, but it whitelists Github anyway. I couldn’t find a vanilla Lua sudoku generator like the one you mentioned, (lots for LÖVE) though, so you should probably just link it.

1 Like

I don’t know what LÖVE is, but this is the one I found.

1 Like

LOVE is a 2D game engine for vanilla Lua.

1 Like