A fully-featured Java Sudoku game with intelligent puzzle generation, backtracking solver, hint system, and a rich performance analytics dashboard.
This project is a complete Sudoku Solver Game built in Java with a Swing-based GUI. It was developed as a course project for Software Construction & Development, demonstrating key software engineering principles including:
- Separation of Concerns โ Board logic, solver, generator, and GUI are each in their own class
- Object-Oriented Design โ Clean encapsulation and responsibility delegation
- Algorithm Design โ Backtracking-based puzzle solving and generation
- User Experience โ Real-time feedback, error highlighting, hints, and a post-game analytics dashboard
- Generate puzzles at three difficulty levels: Easy, Medium, and Hard
- Manual puzzle entry support
- Real-time error highlighting for invalid number placements
- Row, column, and 3ร3 box cell highlighting on focus
- Hint system that reveals the correct number for any empty cell
- Auto-solve button that completes the puzzle instantly
- Board validation to check if a completed puzzle is correct
- Live game timer tracking time elapsed
- Hints used counter
- Mistakes made counter
- Key Performance Indicators: accuracy, efficiency, correct moves
- Donut chart visualization of performance breakdown
- Achievements system with unlockable badges
- Game history comparison across multiple sessions (Overview, Detailed, Charts, Statistics tabs)
- Report generation โ export a
.txtperformance report - CSV data export for game history
- Practice mode with targeted improvement tips
- Share results dialog
sudoku-solver-game/
โ
โโโ SudokuGUI.java # Main application window and game controller
โโโ SudokuBoard.java # Board state management and game logic
โโโ SudokuSolver.java # Backtracking solver and solution counter
โโโ PuzzleGenerator.java # Random puzzle generation by difficulty
โโโ finalWindow.java # Post-game performance analytics dashboard
โ
โโโ README.md # Project documentation
โโโ .gitignore # Ignore compiled class files
โโโ LICENSE # MIT License
โ
โโโ screenshots/
โโโ 01_game_board.png
โโโ 02_easy_board.png
โโโ 03_medium_board.png
โโโ 04_hard_board.png
โโโ 05_hint.png
โโโ 06_mistake.png
โโโ 07_solve_automatically.png
โโโ 08_performance_dashboard.png
โโโ 09_performance_visualization.png
โโโ 10_additional_features.png
โโโ 11_generate_report.png
โโโ 12_compare_games_overview.png
โโโ 13_compare_games_detailed.png
โโโ 14_compare_games_stats.png
โโโ 15_compare_games_charts.png
โโโ 16_achievements.png
โโโ 17_practice_mode.png
โโโ 18_share_results.png
The project follows a clean layered architecture:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ SudokuGUI.java โ โ Presentation Layer (Swing UI)
โ (Game window, controls, events) โ
โโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโ
โ SudokuBoard.java โ โ Domain Layer (State & Rules)
โ (Board state, user moves, hints) โ
โโโโโโโโโโฌโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโ
โ โ
โโโโโโโโโโผโโโโโโโโโ โโโโโโโผโโโโโโโโโโโ
โ SudokuSolver โ โ PuzzleGenerator โ โ Logic Layer
โ (Backtracking) โ โ (Generation) โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโ
โ finalWindow.java โ โ Analytics Layer
โ (Dashboard, charts, history) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
- Java JDK 8 or higher
- Any Java IDE (IntelliJ IDEA, Eclipse, VS Code with Java extension) or command line
# Clone the repository
git clone https://github.com/YOUR_USERNAME/Sudoku-Solver-Game.git
cd Sudoku-Solver-Game
# Compile all Java files
javac *.java
# Run the application
java SudokuGUI- Open your IDE and import the project folder
- Make sure all 5
.javafiles are in the same package/directory - Run
SudokuGUI.javaas the main class
- Generate a Puzzle โ Click Easy, Medium, or Hard to generate a new puzzle
- Fill Cells โ Click any empty cell and type a number (1โ9)
- Use Hints โ Click "Get Hint" to auto-fill the next empty cell with the correct number
- Check Your Work โ Click "Check Board" when all cells are filled
- Win! โ If correct, the performance dashboard opens with your stats
- Click a cell to focus and highlight its row, column, and box
- Type
1โ9to enter a number;BackspaceorDeleteto clear - Puzzle clue cells (pre-filled, shaded blue) cannot be edited
| Color | Meaning |
|---|---|
| ๐ต Light Blue | Original puzzle clue (read-only) |
| โฌ White | Empty or valid user-entered cell |
| ๐ข Light Green | Hint-filled cell |
| ๐ด Light Red | Invalid/conflicting number |
| ๐ก Yellow | Highlighted row/column/box |
Manages the complete board state. Maintains three parallel grids:
board[][]โ current numbers (clues + user entries + hints)originalPuzzle[][]โ immutable clue valuesuserFilled[][]/hintCells[][]โ tracks cell origin
Key methods: putNumber(), setNumber(), putHint(), canPlace(), checkBoard(), isValidBoard(), clearUserCell(), clearAllUserCells()
Implements a recursive backtracking algorithm to solve any valid Sudoku puzzle.
Key methods:
solve(board)โ fills in a solution in-place; returnstrueif solvablecanPlace(board, row, col, num)โ validates Sudoku row/column/box constraintsgetHint(board, row, col)โ returns the correct value for a specific cellcountSolutionsLimited(board, limit)โ checks if puzzle has a unique solution (used during generation)
Creates random, valid Sudoku puzzles with guaranteed unique solutions.
Algorithm:
- Fill the three diagonal 3ร3 boxes with random shuffled numbers (they are independent)
- Use backtracking to fill remaining cells
- Remove cells one by one (random order), verifying uniqueness after each removal
- Stop when the target cell count for the chosen difficulty is reached
| Difficulty | Cells Removed | Empty Cells |
|---|---|---|
| ๐ข Easy | 25 | 25 |
| ๐ก Medium | 45 | 45 |
| ๐ด Hard | 57 | 57 |
The main application window built with Java Swing. Responsibilities:
- Renders the 9ร9 grid as
JTextFieldcells - Handles all user input events (key presses, mouse clicks, focus changes)
- Manages the game timer, hint counter, and mistake counter
- Coordinates between
SudokuBoard,SudokuSolver, andPuzzleGenerator - Launches
finalWindowupon successful puzzle completion
A rich post-game Performance Analytics Dashboard displayed after solving a puzzle.
Panels & Features:
- KPI Cards โ time, accuracy, efficiency, hints, mistakes, correct moves
- Donut Chart โ multi-ring visualization of performance metrics
- Game History Comparison โ tabbed view with Overview, Detailed Table, Progress Charts, and Advanced Statistics
- Achievements โ badge system (Perfect Game, Hintless Hero, Accuracy Master, etc.)
- Generate Report โ saves a formatted
.txtperformance report - Export CSV โ exports all game history data
- Practice Mode โ gives targeted tips based on your weak areas
- Share Results โ generates a shareable summary text
| Technology | Purpose |
|---|---|
| Java SE 8+ | Core programming language |
| Java Swing | GUI components โ JFrame, JPanel, JTextField, JButton |
| Java AWT | Custom charts โ Graphics2D, Arc2D, BasicStroke |
| Java Timer | Live game timer implementation |
| Java I/O | Report generation and CSV export |
| Java Collections | Game history and list management |
| Git | Source control |
| GitHub | Code hosting |
solve(board):
find first empty cell
for num in 1..9:
if canPlace(board, row, col, num):
place num
if solve(board): return true
undo placement (backtrack)
return false โ trigger backtrack in caller
During puzzle generation, countSolutionsLimited(puzzle, 1) is called after each cell removal. If more than 1 solution exists, the removal is undone โ guaranteeing every generated puzzle has exactly one solution.
This project is licensed under the MIT License โ see the LICENSE file for details.
Built with โ Java and a love for puzzles.
โญ If you found this project helpful, please consider giving it a star!