This Python-based Sudoku game provides a graphical interface using Pygame. Users can solve the Sudoku puzzle manually or allow the computer to solve it. The interface supports selecting cells, entering numbers, and validating the solution.
- Interactive GUI for playing Sudoku
- Manual entry of numbers
- Automatic solving of the Sudoku puzzle
- Highlighting of selected cells and incorrect placements
- Python 3.x
- Pygame
- Ensure you have Python 3.x installed on your system.
- Install Pygame using pip:
pip install pygame
- Download or clone the Sudoku script to your local machine.
- Open your terminal or command prompt.
- Navigate to the directory where the script is located.
- Run the script using Python:
python sudoku.py
- Select a Cell: Click on a cell to select it.
- Enter a Number: Use the number keys (1-9) to enter a number into the selected cell.
- Temporary Number: Sketch a temporary number by selecting a cell and pressing a number key.
- Confirm Entry: Press the Enter key to confirm the number in the selected cell.
- Clear Cell: Press the Delete key to clear the selected cell.
- Solve Automatically: Press the Spacebar to let the computer solve the Sudoku puzzle.
- Exit: Close the window to exit the game.
- Click on a cell to select it. The selected cell is highlighted in red.
- Enter a number into the selected cell as a temporary sketch.
- Confirm the number in the selected cell.
- Clear the selected cell if it contains a temporary number.
- Automatically solve the Sudoku puzzle using a graphical solving method.
- The Sudoku game uses Pygame for rendering the graphical interface and handling user input.
- The
Grid
class represents the Sudoku board and contains methods for drawing, selecting, and solving the puzzle. - The
Cube
class represents individual cells in the Sudoku grid, with methods for drawing the cell and handling temporary and permanent values. - The
solve
andsolve_gui
methods implement the backtracking algorithm to solve the puzzle. - The
find_empty
method uses a heuristic to find the cell with the fewest possible values for efficient solving.
- Add more Sudoku puzzles with varying difficulty levels.
- Implement a hint system to assist players.
- Add an option to highlight incorrect placements automatically.
- Improve the graphical interface with better visual feedback.
Enjoy playing the Sudoku game! If you encounter any issues or have suggestions for improvements, feel free to contribute or open an issue.