Skip to content

ironwolf-2000/Sudoku-Games

Repository files navigation

Sudoku Games

A classic Sudoku game offering a range of game modes and preset clues. Developed using React and Redux, with all algorithms for grid generation and uniqueness checks implemented from scratch.

Demo

https://sudoku-nine-kappa.vercel.app/

Features

Game Mode

  • Classic Mode: Follows traditional Sudoku rules, filling a 9x9 grid with digits from 1 to 9, ensuring each row, column, and 3x3 subgrid contains each digit once.

  • Diagonals Mode: Similar to Classic Sudoku but adds the requirement that each of the two main diagonals of the grid also contains digits from 1 to 9 once.

  • Even-Odd Mode: Like Classic Sudoku, players fill a 9x9 grid with digits from 1 to 9. However, there is an extra requirement: darker cells are for even numbers, while lighter cells are for odd numbers.

Grid Size

Each game mode offers four different grid sizes: 4x4, 6x6, 8x8, and 9x9.

In-game Assistance

  • Checks: Clears erroneous cells from the grid. There are at most 3 checks per game.

  • Hints: Reveals the correct value of a randomly selected empty cell. There can be up to 5 hints per game.

  • Notes: Enables users to record potential values for each cell, without limitations.

Difficulty

The level of difficulty is determined flexibly based on the initial number of clues present in the Sudoku grid. You can specify up to $N^2-1$ clues where $N$ represents the size of the grid.

Game Score

As you solve the puzzle, you accumulate points. The base score multiplier is determined by various factors, including the grid size and the quantity of selected hints. Additionally, completing multiple boxes, rows, or columns simultaneously results in a greater contribution to the total score.

Other Functionality

  • Game Restart: Resets the grid to its initial state.
  • Game Pause: Temporarily halts the game, blurring the grid in the process.

Algorithms

The Sudoku Grid generation can be broken down into two steps:

  1. Create a fully filled grid: This step involves generating a Sudoku grid that is completely filled and represents the solution to the puzzle.

  2. Elimination Of Clues: Once the fully filled grid is generated, clues are systematically eliminated to create a playable grid that will be presented to the user.

Grid Generation

To generate the Sudoku grid, we employ a backtracking algorithm, meticulously filling each cell step by step. An optimization strategy is implemented, attempting to solve the Sudoku grid using traditional methods first. For further details, refer to the code.

Elimination Of Clues

After creating a fully-filled grid, begin the process of elimination. Grid clues are removed one at a time. At each step, we ensure that the puzzle maintains a unique and solvable solution. For more information, refer to the code here.

Built With

Built With

Setup

To run this project, follow these steps:

  1. Clone the repository to your local machine:
git clone https://github.com/ironwolf-2000/Sudoku-Games.git
  1. Navigate to the project directory:
cd Sudoku-Games
  1. Install dependencies using npm:
npm install
  1. Run the development server:
npm run dev
  1. Open your browser and visit http://localhost:5173/ to view the project.

Resources

About

Various Sudoku Games with underlying algorithms built from scratch.

Topics

Resources

License

Stars

Watchers

Forks

Languages