# Sudoku & Sudoku-Like Game - Options for Checking Puzzle Solution

#### ZombieKidzRule

##### Shh! My Zombiekids & I are playing BG3 right now.
I'm not sure if this is the best place for this. I am technically looking for MZ related options, but the mechanic itself is not MZ specific. Also, this might not even be considered a game mechanic. I'm not sure.

Anyway, as I referenced in a recent status post, I got it in my head that I could Event a Sudoku game. Which, as it turns out, I can. I am actively working on it right now and probably doing it the most complicated and inefficient way possible. But still having fun.

Now, I have been pondering how to Event check the solution to the puzzle and I have come up with a few different options. I am wondering what folks think and if anyone can think of a better and more efficient way that I just can’t see.

For background, from my research, apparently, a “proper” Sudoku puzzle is supposed to have only one solution. It also appears that it is possible for a puzzle to have more than one solution, especially the less starting hints are provided. There has actually been significant time and energy devoted to figuring out the minimum number of hints required for a “proper” Sudoku puzzle with only one solution. Apparently that minimum hint number is 17.

With that said, I am making a Sudoku and Sudoku-Like puzzle game. Because it seems like I can so why not? And I keep coming up with additional ways to massage the puzzle experience. And I have no intentions at this time of trying to make something like this commercial.

For me, Sudoku-Like means that it would be possible for the puzzle to have more than one solution. Because you could also play around with letting the player determine how many hints (with a minimum and maximum) and even let the player select their own hint spots. If the player selects the hint locations poorly, that just makes the puzzle harder to figure out with more initial guessing and trial and error.

Specifically regarding how to check the solution that the player submits. I will present the options I am considering with the Pros and Cons that I can see.

For additional background with the options below, please consider that in a Sudoku Puzzle, each Row, Column, and 3x3 group of squares must have the numbers 1-9 without any repeats. This also means that the total value of each Row, Column, and 3x3 group will be 45. And the total value of the entire puzzle would be 405 (45 x 9).

The way I am currently building the game, I allow the player to put whatever number from 1-9 that they want in any square. It isn’t until the player selects the option to check their solution that the numbers they placed are actually checked. I am using 81 Variables (9 x 9 Squares).

Also, the player would have no idea how the solutions are being checked so it would be less likely that a player could purposefully exploit any option. This relates to Option 1 below which isn't technically 100% accurate.

Option #1

Calculate the total value of the inputted Variables of each Row, Column, and 3x3 group to ensure that each one totals 45. Also, calculate the total value of the entire puzzle to ensure that it totals 405.

Pros:

Only requires 28 calculations. Any calculation that isn’t the correct total would result in an incorrect solution.

This appears to allow for multiple solutions to a Sudoku-Like puzzle.

This method would support reducing the number of starting hints or allowing the player to choose their hints.

Cons:

Technically, this method would not be 100% accurate. It is possible that a player could repeat numbers in a Row, Column, or 3x3 group that still add up to 45. However, the likelihood of that happening is incredibly remote. Especially with the addition of the total puzzle count of 405.

With this method, I couldn’t show the player that any particular Row, Column, or 3x3 group contains an error.

Option #2

Push the player inputted values into an Array for each Row, Column, and 3x3 group. Then check each Array to see if it contains the numbers 1-9.

Pros:

This only requires checks of 27 Arrays.

This method would appear to be 100% accurate.

I could use this method to highlight to the player what Row, Column, or 3x3 grid contains an error.

This appears to allow for multiple solutions to a Sudoku-Like puzzle.

This method would support reducing the number of starting hints or allowing the player to choose their hints.

Cons:

Requires 27 more Variables to use as Arrays.

Requires the extra step of adding all the player inputted Variable values into the appropriate Arrays.

Option #3

Have each of the 81 Variables for the puzzle be hard set with a correct value. Check each of the 81 Variables to confirm that the player inputted value is correct.

Pros:

This should be 100% accurate for only one solution (“proper” Sudoku).

This allows greatest accuracy in identifying to the player the squares that have incorrect values.

Cons:

Requires 81 checks to compare Variables. Or perhaps a Scripted Loop check that I would have to research how to implement.

Requires 81 additional Variables to store the correct values.

This method would not allow for multiple solutions for a Sudoku-Like puzzle.

This method would not support reducing the number of starting hints or allowing the player to choose their hints because the player could legitimately submit a correct solution that is not recognized.

Each unique puzzle requires coding the correct Variable values for 81 Variables.

Currently, after writing this out, I am leaning toward Option #2. That options seems to have the most Pros and the least Cons.

But I am interested in hearing other people’s thoughts.

Which option would you choose?

Are there other potential Pros and Cons that I haven’t noticed?

Is there another option that might be easier or more efficient to implement?

Thanks for taking the time to read through this and share your thoughts!

Making this Sudoku Game is surprisingly fun, if not a bit repetitive.

EDIT: I should clarify that this is entirely Evented/Scripted with NO plugins.

#### Mac15001900

##### JavaScript wild sorcerer
If you're able to go with option 2, then I'd definitely recommend that one - that's the way those puzzles are normally checked, and should be relatively simple. And I'm sure the player can figure out what's wrong if you highlight the invalid row/column/box.

You mention that option 3 would require you to research how to make a scripted loop - my recommendation would be to research it anyway, it will help you a lot with any of these options.

Now, I would also highly recommend you test this game out first. Before any eventing, just with pen and paper. Because, to be honest... it sounds really frustrating to play. The reason sudoku puzzles always have a single unique solution is because this way the solution is always deducible with just logic (now, ensuring this logic is always simple enough is another matter). With multiple possibilities, you'll never know whether there's some deduction you can make that you're not noticing, or if there just isn't any logic you can use at this point.
I'm not sure of this ofc, since I haven't played your variant. So I'd definitely recommend playing a few games of it and also a few regular sudoku puzzles for comparison, to see which one will be more fun.

Choosing your own locations for extra hints does sound interesting though, it might be an interesting twist on the puzzle. Though I'd personally keep that as an extra, with the existing hints being enough to constrain the puzzle to a single solution. And definitely allow those to be used during the puzzle - it might be an interesting tool for helping you when you get stuck.

The above is of course assuming that your goal is to make something fun; if it's just to practise eventing then I guess build whatever sounds interesting to build.

#### ZombieKidzRule

##### Shh! My Zombiekids & I are playing BG3 right now.
@Mac15001900 Thanks! I having been trying to fully understand scripting loops, but the full logic still escapes me. I keep going back to my Java Script course and other examples to try to apply what I see to different situations. I am sure I will get there, but for now, I rely on the more inefficient way that I know works!

Right now I am just getting the template and core mechanics built. Then I will actually test it multiple times with real Sudoku puzzles. Using the same starting hints that they do to see how it works.

I have never played an electronic Sudoku game. I have just completed the ones on paper.

Once I confirm that everything works and I have chosen/built a solution checker and I have tested the mechanics using real Sudoku puzzles, then I want to test to see what happens when you reduce the hints or let the player choose their own hints. I think that will be interesting.

I am sure it will be more difficult and frustrating. Which means it wouldn't be a primary aspect of any incorporated game. More like an option that a player could try if they wanted.

I want to experiment with some other aspects too, like using timers and any other weird things my imagination comes up with.

But first is to get the core mechanics down.

Thanks again for the input and points to ponder!

#### ZombieKidzRule

##### Shh! My Zombiekids & I are playing BG3 right now.
Bumping this within the rules (I think) to see if anyone else has an opinion they would like to offer.

I am almost done with Eventing the template. Next is Eventing the solution check.

Thanks!

### Latest Profile Posts

Meet my new mascot. He's also a mimic! No prizes for guessing this guy's name, though, haha

I put out a new pack and I swear, I did not realize how it looks like the ones on the right are scared/nervous of the one on the left until way after I just wanted to showcase some of them randomly xD
Well, if anyone has a funny, simple, easy RM game they want me to playtest/review, I would love it.
Someone close to me straight up told me they didn't think my relationship with my girlfriend would last. No lead up, very bluntly. Like it's obvious or something. Trying not to let it get to my head, but it's hard.
The distraction would be a life saver.

My first foray into a plugin that I plan to release. Working on something for those who want to set up a Dragon Quest style battle HUD with minimal fuss. Includes the ability to round the battleback corners to fit your windowskin and, of course, front-view animations.

Do you ever wonder where the heck everyone is going at 9:00 at night? Like... guys, go home! Get some sleep! Me? Oh, I'm out to get pizza 'cause I decided supper time was 9:30 tonight.