Posts

Showing posts from November, 2022

Check Sudoku - Unity Tutorial - 5. Game rules

Image
In the previous step we have implemented setting board cell values . In this one, we will add checking Sudoku rules, to prevent user from "clicking" illegal Sudoku board: Implementation At this stage, we need to create the game model. In order to do that, we create three classes: BoardModel  for storing the whole board model CellModel  for storing single cell model CellSetModel  for storing a set of cells (e.g. column, row, or 3x3 square) Question 1: Which element should store the board model? Options: Game manager ( GameManager ) The board ( BoardImage ) The work cell ( WorkCellImage ) Decision: Since we need to join the model with board images anyway, it's easiest if the board ( BoardImage ) creates the model upon creation and feeds all its cells into it. In order to simplify testing, we set the initial values for some of the board cells, getting a solvable Sudoku: public class BoardImage : MonoBehaviour { ... private BoardModel model; private void Aw...