- Introduction
- Features
- Requirements
- Installation
- How to Play
- Project Structure
- Code Overview
- Future Enhancements
- Contributing
- License
This project is an implementation of the classic Sudoku puzzle game using Python and Pygame. It offers a graphical user interface for playing Sudoku, with features such as a menu system, difficulty levels, and the ability to play puzzles from the New York Times website.
- Graphical user interface built with Pygame
- Main menu with options to start a new game or exit
- Ability to play randomly generated Sudoku puzzles
- Option to play Sudoku puzzles from the New York Times website
- Three difficulty levels for NYT puzzles: Easy, Medium, and Hard
- Interactive gameplay with mouse and keyboard input
- Automatic validation of completed puzzles
- Python 3.7+
- Pygame
- Requests library
-
Clone this repository:
git clone https://github.com/choppystick/PyDoku.git cd sudoku-game
-
Create a virtual environment (optional but recommended):
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install the required packages:
pip install -r requirements.txt
-
Run the game:
python main.py
- Launch the game by running
main.py
. - In the main menu, you can choose to:
- Play a randomly generated Sudoku puzzle
- Play a puzzle from the New York Times (with difficulty selection)
- Exit the game
- During gameplay:
- Click on a cell to select it
- Use number keys (1-9) to input a number into the selected cell
- Press ESC to return to the main menu
- The game will automatically validate your solution when the board is filled.
The project is structured into several Python classes:
SudokuBoard
: Represents the Sudoku board and handles puzzle generation and validationSudokuGame
: Manages the game state and user interactionsSudokuRenderer
: Handles the drawing of the Sudoku board on the screenMenu
: Manages the main menu and NYT difficulty selection menuGameController
: Orchestrates the overall game flow
This class is responsible for generating and managing the Sudoku board. It includes methods for:
- Generating a new Sudoku puzzle
- Validating moves
- Fetching puzzles from the New York Times website
This class manages the game state, including:
- Starting a new game
- Handling user input (cell selection and number input)
- Checking if the puzzle is completed
This class is responsible for drawing the Sudoku board on the screen, including:
- Drawing the grid
- Rendering numbers
- Highlighting the selected cell
This class manages the menu system, including:
- Drawing the main menu and NYT difficulty selection menu
- Handling button clicks
This class orchestrates the overall game flow, managing transitions between the menu and gameplay states.
- Add a scoring system
- Improve graphics and add animations
- Add sound effects and background music
- Implement the LP solver but I honestly I have no idea how.
- Hint is bugged. Idk why.
- When game is paused, user should not be able to do anything.
Contributions to this project are welcome!
This project is licensed under the MIT License - see the LICENSE file for details.
Enjoy playing PyDoku! If you encounter any issues or have suggestions for improvements, please open an issue on the GitHub repository.