[{"data":1,"prerenderedAt":13},["ShallowReactive",2],{"$fhkKyY1CgO82Y9gr_z4MVZVQwsRYQPWOseTwpOdOuzKo":3},{"title":4,"description":5,"date":6,"category":7,"icon":8,"coverImage":9,"contentHtml":10,"_path":11,"_id":12},"Sudoku - AI-Assisted Development Log","How I built a classic 9x9 Sudoku puzzle game with AI — from number placement logic, conflict detection, note-taking mode, to difficulty levels and mobile optimization.","2026-05-15","Tutorial","🧩","\u002Fblog\u002Fsudoku-dev-cover.svg","\u003Ch1>Sudoku - AI-Assisted Development Log\u003C\u002Fh1>\n\u003Cp>A complete record of developing a classic 9x9 Sudoku puzzle game using AI tools — from puzzle generation algorithms to polished UI and mobile touch support.\u003C\u002Fp>\n\u003Ch2>Project Overview\u003C\u002Fh2>\n\u003Cp>\u003Cstrong>Sudoku\u003C\u002Fstrong> is a classic number puzzle game built entirely with AI assistance. Players fill a 9x9 grid so that each row, column, and 3×3 box contains all digits from 1 to 9 exactly once.\u003C\u002Fp>\n\u003Cp>\u003Cstrong>Tech Stack:\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cul>\n\u003Cli>Vanilla JavaScript (ES6+)\u003C\u002Fli>\n\u003Cli>HTML5 Canvas\u003C\u002Fli>\n\u003Cli>CSS3 Responsive Design\u003C\u002Fli>\n\u003Cli>Web Audio API (sound effects)\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Cp>\u003Cstrong>Core Features:\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cul>\n\u003Cli>Classic 9x9 Sudoku gameplay with three difficulty levels (Easy, Medium, Hard)\u003C\u002Fli>\n\u003Cli>Smart puzzle generation with backtracking solver algorithm\u003C\u002Fli>\n\u003Cli>Note-taking (pencil marks) mode for advanced players\u003C\u002Fli>\n\u003Cli>Hint system with one correct cell reveal\u003C\u002Fli>\n\u003Cli>Conflict highlighting to show row\u002Fcolumn\u002Fbox errors\u003C\u002Fli>\n\u003Cli>Undo support with move history\u003C\u002Fli>\n\u003Cli>Number fill count progress bar\u003C\u002Fli>\n\u003Cli>Timer and mistake tracking\u003C\u002Fli>\n\u003Cli>Mobile-first responsive design\u003C\u002Fli>\n\u003Cli>Touch-optimized number pad\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Chr>\n\u003Ch2>AI Usage Workflow\u003C\u002Fh2>\n\u003Ch3>Phase 1: Creating the Base Game\u003C\u002Fh3>\n\u003Cp>\u003Cstrong>Goal:\u003C\u002Fstrong> Get AI to help build a fully playable Sudoku prototype\u003C\u002Fp>\n\u003Cp>\u003Cstrong>Prompt Example:\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cpre>\u003Ccode>Help me create a Sudoku game using HTML5 Canvas and JavaScript.\nIt needs:\n1. A 9x9 grid with cell selection\n2. Puzzle generation using backtracking algorithm\n3. Three difficulty levels (Easy: 35 empty, Medium: 45, Hard: 52)\n4. Number input via on-screen number pad\n5. Conflict detection (row, column, box)\n6. Inherit from the existing GameBase class\n\nPlease provide the complete game logic code.\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>\u003Cstrong>AI Output Highlights:\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cul>\n\u003Cli>Created the backtracking Sudoku solver and puzzle generator\u003C\u002Fli>\n\u003Cli>Implemented the 9x9 grid renderer with cell selection\u003C\u002Fli>\n\u003Cli>Built the number pad with fill count progress bars\u003C\u002Fli>\n\u003Cli>Added conflict detection and visual highlighting\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Cp>\u003Cstrong>Key Takeaway:\u003C\u002Fstrong> The AI generated a production-ready core. The backtracking algorithm worked correctly on the first pass, producing valid puzzles for all three difficulty levels.\u003C\u002Fp>\n\u003Chr>\n\u003Ch3>Phase 2: Note-Taking &amp; Hint System\u003C\u002Fh3>\n\u003Cp>\u003Cstrong>Goal:\u003C\u002Fstrong> Add advanced features for a richer gameplay experience\u003C\u002Fp>\n\u003Cp>\u003Cstrong>Prompt:\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cpre>\u003Ccode>Now I want to add:\n1. A note-taking mode where players can pencil-mark candidate numbers\n2. A hint system that reveals the correct number for the selected cell\n3. Undo support to revert the last move\n4. Visual highlight for cells that share the same number as the selected cell\n5. Error highlighting toggle\n\nPlease implement these features.\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>\u003Cstrong>AI Solutions:\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Ctable>\n\u003Cthead>\n\u003Ctr>\n\u003Cth>Feature\u003C\u002Fth>\n\u003Cth>Implementation\u003C\u002Fth>\n\u003Cth>Notes\u003C\u002Fth>\n\u003C\u002Ftr>\n\u003C\u002Fthead>\n\u003Ctbody>\u003Ctr>\n\u003Ctd>Note Mode\u003C\u002Ftd>\n\u003Ctd>Toggle button; tap number pad to add\u002Fremove candidate marks\u003C\u002Ftd>\n\u003Ctd>Pencil marks shown as small 3×3 grid in each cell\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>Hint System\u003C\u002Ftd>\n\u003Ctd>Uses the pre-computed solution array to fill one cell\u003C\u002Ftd>\n\u003Ctd>Increases hint counter\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>Undo\u003C\u002Ftd>\n\u003Ctd>Move history stack with board\u002Fnotes\u002Fmistakes state snapshots\u003C\u002Ftd>\n\u003Ctd>Limited to 100 history entries\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>Same-Number Highlight\u003C\u002Ftd>\n\u003Ctd>All cells with the same value as the selected cell get a darker background\u003C\u002Ftd>\n\u003Ctd>Makes pattern matching easier\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>Error Highlight\u003C\u002Ftd>\n\u003Ctd>Optional toggle to shade cells with conflicts in red\u003C\u002Ftd>\n\u003Ctd>Helps beginners learn\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003C\u002Ftbody>\u003C\u002Ftable>\n\u003Chr>\n\u003Ch3>Phase 3: UI Polish &amp; Mobile Optimization\u003C\u002Fh3>\n\u003Cp>\u003Cstrong>Problem:\u003C\u002Fstrong>\nThe initial UI was functional but lacked visual polish, and touch targets were too small on mobile.\u003C\u002Fp>\n\u003Cp>\u003Cstrong>How to Describe to AI:\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cpre>\u003Ccode>Please improve the UI and mobile experience:\n1. Make the number pad buttons easier to tap on mobile\n2. Add a difficulty selection modal before the game starts\n3. Show number fill count as progress bars on each digit button\n4. Add smooth animations for modal transitions\n5. Improve the game-over screen with detailed stats\n6. Make sure touch events work smoothly without delays\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>\u003Cstrong>AI Results:\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cul>\n\u003Cli>Redesigned the layout with a dark gradient theme and gold accent colors\u003C\u002Fli>\n\u003Cli>Created a pre-game difficulty modal with animated entrance\u003C\u002Fli>\n\u003Cli>Added fill-count progress bars on each number button showing how many of 9 cells are placed\u003C\u002Fli>\n\u003Cli>Built a detailed game-over overlay showing time, mistakes, and hints used\u003C\u002Fli>\n\u003Cli>Optimized touch handling with \u003Ccode>touch-action: none\u003C\u002Fcode> and proper event binding\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Chr>\n\u003Ch2>Key Algorithms\u003C\u002Fh2>\n\u003Ch3>Backtracking Solver\u003C\u002Fh3>\n\u003Cp>The puzzle generator uses a randomized backtracking algorithm:\u003C\u002Fp>\n\u003Col>\n\u003Cli>Find the first empty cell\u003C\u002Fli>\n\u003Cli>Try numbers 1-9 in random order\u003C\u002Fli>\n\u003Cli>Check if the placement is valid (row, column, box)\u003C\u002Fli>\n\u003Cli>Recurse — if a solution is found, return it\u003C\u002Fli>\n\u003Cli>If no number works, backtrack and try the next number\u003C\u002Fli>\n\u003C\u002Fol>\n\u003Cpre>\u003Ccode>function solveSudoku(grid):\n    for each empty cell (row, col):\n        for num in shuffled([1..9]):\n            if isValidPlacement(grid, row, col, num):\n                grid[row][col] = num\n                if solveSudoku(grid):\n                    return true\n                grid[row][col] = 0\n        return false\n    return true\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch3>Conflict Detection\u003C\u002Fh3>\n\u003Cp>Three rules checked when placing a number:\u003C\u002Fp>\n\u003Cul>\n\u003Cli>\u003Cstrong>Row constraint:\u003C\u002Fstrong> No duplicate in the same row\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Column constraint:\u003C\u002Fstrong> No duplicate in the same column\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Box constraint:\u003C\u002Fstrong> No duplicate in the same 3×3 box\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Ch3>Difficulty Levels\u003C\u002Fh3>\n\u003Ctable>\n\u003Cthead>\n\u003Ctr>\n\u003Cth>Level\u003C\u002Fth>\n\u003Cth>Empty Cells\u003C\u002Fth>\n\u003Cth>Description\u003C\u002Fth>\n\u003C\u002Ftr>\n\u003C\u002Fthead>\n\u003Ctbody>\u003Ctr>\n\u003Ctd>Easy\u003C\u002Ftd>\n\u003Ctd>~35\u003C\u002Ftd>\n\u003Ctd>Suitable for beginners, ~20 min\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>Medium\u003C\u002Ftd>\n\u003Ctd>~45\u003C\u002Ftd>\n\u003Ctd>Moderate challenge, ~30 min\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>Hard\u003C\u002Ftd>\n\u003Ctd>~52\u003C\u002Ftd>\n\u003Ctd>Expert level, ~45+ min\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003C\u002Ftbody>\u003C\u002Ftable>\n\u003Chr>\n\u003Ch2>Lessons Learned\u003C\u002Fh2>\n\u003Col>\n\u003Cli>\u003Cp>\u003Cstrong>Backtracking is reliable for Sudoku:\u003C\u002Fstrong> The algorithm is fast enough (&lt; 50ms) to generate any 9×9 puzzle instantly, even on mobile devices.\u003C\u002Fp>\n\u003C\u002Fli>\n\u003Cli>\u003Cp>\u003Cstrong>Note-taking is essential:\u003C\u002Fstrong> Pencil marks are a core feature of Sudoku. The 3×3 mini-grid display per cell was the right approach for showing candidate numbers.\u003C\u002Fp>\n\u003C\u002Fli>\n\u003Cli>\u003Cp>\u003Cstrong>Touch optimization matters:\u003C\u002Fstrong> Setting \u003Ccode>touch-action: none\u003C\u002Fcode> and using \u003Ccode>touchstart\u003C\u002Fcode> events directly (instead of click) eliminated the 300ms tap delay on mobile browsers.\u003C\u002Fp>\n\u003C\u002Fli>\n\u003Cli>\u003Cp>\u003Cstrong>Fill count progress bars:\u003C\u002Fstrong> Showing how many cells are filled for each number gives players a useful visual hint for strategy planning.\u003C\u002Fp>\n\u003C\u002Fli>\n\u003Cli>\u003Cp>\u003Cstrong>Undo with state snapshots:\u003C\u002Fstrong> Storing full board state snapshots is simpler and more reliable than storing individual moves, especially when notes are involved.\u003C\u002Fp>\n\u003C\u002Fli>\n\u003C\u002Fol>\n\u003Chr>\n\u003Ch2>Try It Yourself\u003C\u002Fh2>\n\u003Cp>Play the Sudoku game here: \u003Ca href=\"\u002Fplay\u002Fsudoku-mini\">Sudoku Puzzle\u003C\u002Fa>\u003C\u002Fp>\n\u003Cp>Or open it directly in your browser.\u003C\u002Fp>\n","\u002Fblog\u002Fsudoku-dev","sudoku-dev",1778833534702]