Purpose of this post

This post publishes the source code used in the sudoku AI experiments. The code is loaded only when you open a file.

Models used

  • Qwen3-VL-2B-Instruct: used for the first training (lora_stoku), trial-and-error training (lora_move), certain-cell finding (lora_cell), and the 2B versions of board reading and digit-1 judgement.
  • Qwen3-VL-8B-Instruct: trained for board reading (lora_board_read_8b) and per-digit impossible cells (lora_digit1_illegal_8b). The solve in post 4 used the 15-cycle adapter, and photo import uses the board-reading adapter.
  • LoRA: peft, r=8, alpha=16. Every adapter uses the same settings.
  • Qwen2.5-1.5B-Instruct: tells whether a web chat message is a move request.
  • Gemma 4 (31B, E4B, mlx 4bit): only tested on whether it could read board coordinates.
  • Web moves: currently picked by code alone, without the VLM.

Folder layout

  • dataset_*.py at the root: training data generation
  • *_train_loop.py and train_vlm.py at the root: LoRA training and cycle loops
  • sudoku_engine.py, sudoku_human_solver.py, vlm_digit_strategy.py: puzzle generation, human-style solving, finding certain moves
  • human_judge_*.py: the judgement demo from post 4
  • sudoku_vlm_server.py, chat_bridge_server.py: VLM server and chat server
  • main.py, main_window.py, photo_board_*.py: PyQt6 app and photo import
  • web: Next.js web sudoku screen, solve records (db.ts), AI chat panel
  • solve.md: the document describing how people solve

Server deployment settings, monitoring and automation scripts, training data and logs, and model weights are excluded from the release. Web operation code such as ads and the list of other games, and configuration files are also left out, so some imports point to unpublished files.

Full source

75 files · 19,630 lines — open a folder and click a file to load its code.

Project root48 files
board_read_demo.pypython · 256 lines · 10KB

Loading code…

chat_bridge_server.pypython · 415 lines · 13KB

Loading code…

dataset_digit_illegal.pypython · 128 lines · 4KB

Loading code…

dataset_experience.pypython · 116 lines · 4KB

Loading code…

dataset_human_solver.pypython · 205 lines · 7KB

Loading code…

dataset_sudoku_coords.pypython · 159 lines · 5KB

Loading code…

dataset_sudoku_read.pypython · 147 lines · 5KB

Loading code…

dataset_sudoku.pypython · 104 lines · 3KB

Loading code…

human_judge_one_game.pypython · 369 lines · 14KB

Loading code…

human_judge_solve_cycle.pypython · 598 lines · 22KB

Loading code…

main_window.pypython · 1,348 lines · 47KB

Loading code…

main.pypython · 30 lines · 662B

Loading code…

make_board_snapshot.pypython · 107 lines · 3KB

Loading code…

photo_board_prep.pypython · 761 lines · 25KB

Loading code…

photo_board_read.pypython · 132 lines · 4KB

Loading code…

README.mdmarkdown · 70 lines · 2KB

Loading code…

requirements-train.txttext · 3 lines · 62B

Loading code…

requirements-vlm.txttext · 7 lines · 107B

Loading code…

requirements.txttext · 1 lines · 13B

Loading code…

solve.mdmarkdown · 45 lines · 6KB

Loading code…

sudoku_engine.pypython · 259 lines · 9KB

Loading code…

sudoku_human_solver.pypython · 997 lines · 33KB

Loading code…

sudoku_vlm_server.pypython · 825 lines · 30KB

Loading code…

sudoku_vlm_solver.pypython · 111 lines · 4KB

Loading code…

train_vlm.pypython · 491 lines · 17KB

Loading code…

vlm_agent.pypython · 212 lines · 7KB

Loading code…

vlm_board_read_sim.pypython · 527 lines · 18KB

Loading code…

vlm_board_read_train_loop.pypython · 767 lines · 23KB

Loading code…

vlm_board.pypython · 701 lines · 22KB

Loading code…

vlm_cell_train_loop.pypython · 852 lines · 28KB

Loading code…

vlm_coord_probe_gemma.pypython · 392 lines · 12KB

Loading code…

vlm_coord_sim.pypython · 349 lines · 12KB

Loading code…

vlm_curriculum_loop.pypython · 496 lines · 15KB

Loading code…

vlm_diag.pypython · 426 lines · 14KB

Loading code…

vlm_digit_illegal_sim.pypython · 181 lines · 5KB

Loading code…

vlm_digit_illegal_train_loop.pypython · 717 lines · 22KB

Loading code…

vlm_digit_strategy.pypython · 304 lines · 10KB

Loading code…

vlm_experience.pypython · 279 lines · 9KB

Loading code…

vlm_human_probe.pypython · 331 lines · 10KB

Loading code…

vlm_human_train_loop.pypython · 177 lines · 5KB

Loading code…

vlm_human.pypython · 137 lines · 4KB

Loading code…

vlm_loader.pypython · 95 lines · 3KB

Loading code…

vlm_play_sim.pypython · 454 lines · 14KB

Loading code…

vlm_play_train_loop.pypython · 380 lines · 13KB

Loading code…

vlm_prompt.pypython · 386 lines · 16KB

Loading code…

vlm_protocol.pypython · 310 lines · 8KB

Loading code…

vlm_qwen8b_base_probe.pypython · 274 lines · 9KB

Loading code…

vlm_stage_sim.pypython · 357 lines · 11KB

Loading code…

web/27 files
web/next.config.mjsjavascript · 4 lines · 92B

Loading code…

web/package.jsonjson · 26 lines · 569B

Loading code…

web/postcss.config.mjsjavascript · 8 lines · 135B

Loading code…

web/src/app/api/chat/route.tstypescript · 78 lines · 2KB

Loading code…

web/src/app/api/session/move/route.tstypescript · 60 lines · 2KB

Loading code…

web/src/app/api/session/route.tstypescript · 146 lines · 4KB

Loading code…

web/src/app/globals.csscss · 33 lines · 564B

Loading code…

web/src/app/layout.tsxtsx · 43 lines · 1KB

Loading code…

web/src/app/page.tsxtsx · 5 lines · 112B

Loading code…

web/src/components/AiChatPanel.tsxtsx · 117 lines · 4KB

Loading code…

web/src/components/BottomNav.tsxtsx · 65 lines · 2KB

Loading code…

web/src/components/GameScreen.tsxtsx · 382 lines · 13KB

Loading code…

web/src/components/HomeScreen.tsxtsx · 197 lines · 8KB

Loading code…

web/src/components/Logo.tsxtsx · 45 lines · 1KB

Loading code…

web/src/components/NumberPad.tsxtsx · 35 lines · 991B

Loading code…

web/src/components/SettingsScreen.tsxtsx · 63 lines · 3KB

Loading code…

web/src/components/SudokuApp.tsxtsx · 716 lines · 19KB

Loading code…

web/src/components/SudokuBoard.tsxtsx · 96 lines · 3KB

Loading code…

web/src/lib/db.tstypescript · 283 lines · 7KB

Loading code…

web/src/lib/device-id.tstypescript · 21 lines · 659B

Loading code…

web/src/lib/move-kinds.tstypescript · 1 lines · 60B

Loading code…

web/src/lib/notes.tstypescript · 31 lines · 916B

Loading code…

web/src/lib/sudoku.tstypescript · 232 lines · 6KB

Loading code…

web/src/lib/types.tstypescript · 73 lines · 2KB

Loading code…

web/src/types/node-sqlite.d.tstypescript · 13 lines · 326B

Loading code…

web/tailwind.config.tstypescript · 43 lines · 970B

Loading code…

web/tsconfig.jsonjson · 26 lines · 578B

Loading code…