Use this simple Sudoku game as a starting point to practice your skills with GitHub Copilot. The goal is to refactor the code to use modern technologies, while also adding new features and improving the overall user experience.
Follow these instructions to get a copy of the project up and running on your local machine.
- Modern web browser (Chrome, Firefox, Edge, etc.)
- Python 3
-
Fork this repository to your GitHub account. (You can use the "Fork" button on the top right corner of the repository page.)
-
Clone your forked repository to your local machine.
-
Open a terminal window and navigate to the "github-copilot-python/starter" directory.
-
Create a Python virtual environment and activate it (optional but highly recommended).
python3 -m venv .venv
source .venv/bin/activate- Install required Python packages.
pip install -r requirements.txt- Run the Flask app.
python app.py- Open http://127.0.0.1:5000 in your browser.
Use GitHub Copilot to refactor the code for this game to add more advanced features. The goal is to create a more modern and maintainable codebase and add additional functionality to the final product. You can use any combination of code completion and chat features, like Ask, Edit, or Agent modes.
- Errors should be handled gracefully with appropriate messages to the user.
- Implement a Sudoku board generator that creates a valid Sudoku puzzle with a unique solution.
- Add a timer to track how long it takes to solve the puzzle.
- Implement a solution checker that verifies if the user's solution is correct using event delegation.
- Add a difficulty selector to allow users to choose between easy, medium, and hard puzzles.
- Add a hint feature that provides clues for the user that are noted with unique colors.
- Add a check puzzle button that checks the current state of the board against the solution.
- User should get immediate feedback on their input, such as highlighting invalid entries.
- Top 10 scores should be saved in local storage and displayed on the page with the user's name, time taken, hints used, and difficulty level.
- The game should be responsive and work well on both desktop and mobile devices.
- UI colors should be visually appealing and accessible.
- Completed and correct puzzles should display a congratulatory message with the time taken and hints used and ask for the user's name for Top 10 times.
A modern Flask-based Sudoku game refactored from legacy Python code with GitHub Copilot.
The project adds Sudoku generation and validation, difficulty levels, hints, puzzle checking, a timer, a persistent Top 10 leaderboard, dark mode, responsive styling, and accessibility improvements.
- Generates valid Sudoku puzzles.
- Ensures each generated puzzle has exactly one unique solution.
- Supports Easy, Medium, and Hard difficulty levels.
- Difficulty levels change the number of prefilled cells.
- Prefilled cells are locked and cannot be edited.
- Provides immediate feedback for invalid entries.
- Check Puzzle button highlights incorrect entries.
- Detects when the puzzle has been correctly completed.
- Displays a congratulatory completion message.
- Hint button fills one correct empty cell.
- Hint-filled cells are visually distinguished.
- Hint-filled cells are locked.
- Tracks the number of hints used.
- Starts when a new puzzle begins.
- Tracks elapsed solving time.
- Stops when the puzzle is completed.
- Stores completed scores in browser localStorage.
- Records player name.
- Records completion time.
- Records difficulty level.
- Records number of hints used.
- Sorts scores by fastest completion time.
- Keeps only the top 10 scores.
- Scores persist between browser sessions.
- Light and dark mode.
- Responsive desktop and mobile layout.
- Alternating styles for the 3x3 Sudoku regions.
- Accessible and readable controls.
- Keyboard-friendly interface and visible focus states.
Run the following command from the starter directory:
pytest
- Select a difficulty level: Easy, Medium, or Hard.
- Start a new puzzle.
- Fill the empty Sudoku cells.
- Prefilled cells cannot be edited.
- Use the Check Puzzle button to identify incorrect entries.
- Use Hint when assistance is needed.
- The timer tracks the solving time.
- Complete the puzzle correctly to finish the game.
- Enter your name when prompted after completing a puzzle.
- Completed scores are stored in the Top 10 leaderboard.
The application was reviewed for:
- Keyboard navigation
- Visible focus states
- Accessible button and control labels
- Readable text
- Color contrast
- Error and success feedback
- Dark mode readability
- Responsive desktop and mobile layouts
The Sudoku grid and controls are designed to remain usable across different screen sizes and themes.