Advice on making a Sudoku like win condition for a game

Hello everyone.

I was wondering the best way to set up a UI trigger to enable if, say, all 9 numbers exist on a 3x3 grid in any given order, but no number repeats itself(like one 3x3 in sudoku) The puzzle part I can take care of, its the idea of how to trigger a condition if 1-9 sows up in any given order on a 3x3 space/grid/3x3 objects, etc.

Any advice, links or tutorials would help me greatly and be appreciated.

You can have an object-like class that handles the win checking per square. It may have 9 slots (3x3 square) and can have a value from 1-9, or null if not filled yet. Every move, you might check the array of slots and check if it isn’t missing any number from 1-9. If it is, then it is either not filled yet, or multiple entries of the same number have been entered. I don’t want to write code for this, but I can help you if you need it. Just some advice from me. @etnom22000

Personally I would think of your data-structure as something separate from your ui. The optimal way of storing and working on your data is rarely 100% synonymous with the interface you expose to the user.

Maybe using something like a multi dimensional array for the entire grid and then just bounding the search within a certain range of those arrays.

For example (and excuse the contrived example):

int[,] board = new int[,] { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } };

Would allow you to index a value in the array like board[0, 0]

What this means is that you can iterate over the rows or columns one at a time by incrementing either the “x” or “y” indexes checking that each of the values are distinct and that you have all of them.

That will give you the win condition regardless of the third condition i.e. that each square will have unique values which is an implied emergent property of the other.