Purpose of this post

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

Models used

  • VLM: 25,413 game moves were played with Qwen3-VL-8B-Instruct from Hugging Face. The server currently runs the default, Qwen3-VL-2B-Instruct. It receives a board image and a text board together and returns two numbers, "row col".
  • LoRA: peft, r=8, alpha=16. It trains only on the winning side's moves. On MPS it ran in fp16 and the loss became NaN.
  • Local AI: the C++ AiPlayer in the Qt app and ai.ts on the web. A heuristic that first looks for winning moves and moves that must be blocked, and otherwise picks by adding up scores in four directions.
  • Engine: the same forbidden moves for Black and White (double-three and overline forbidden, double-four allowed); only exactly five wins.

Folder layout

  • src: Qt6/C++ Gomoku engine, local AI, board screen, TCP client that talks to the VLM server
  • .py files at the root: VLM inference server (vlm_pva_server.py), dataset_omook.py that turns logs into training data, LoRA training train_vlm.py, model download
  • scripts: VLM coordinate checks and a text board client
  • omook-web: Next.js web game screen, engine (board.ts), local AI (ai.ts), game record storage (db.ts), VLM connection

Server deployment settings, monitoring and automation scripts, game logs and the game record DB, 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

38 files · 8,212 lines — open a folder and click a file to load its code.

Project root7 files
CMakeLists.txttext · 30 lines · 663B

Loading code…

dataset_omook.pypython · 347 lines · 12KB

Loading code…

download_qwen3vl.pypython · 42 lines · 1KB

Loading code…

requirements.txttext · 20 lines · 725B

Loading code…

train_vlm.pypython · 360 lines · 13KB

Loading code…

TRAINING.mdmarkdown · 136 lines · 6KB

Loading code…

vlm_pva_server.pypython · 1,475 lines · 54KB

Loading code…

omook-web/18 files
omook-web/app/api/game/[code]/route.tstypescript · 59 lines · 2KB

Loading code…

omook-web/app/api/game/route.tstypescript · 32 lines · 1KB

Loading code…

omook-web/app/api/vlm/move/route.tstypescript · 58 lines · 2KB

Loading code…

omook-web/app/globals.csscss · 48 lines · 864B

Loading code…

omook-web/app/layout.tsxtsx · 33 lines · 944B

Loading code…

omook-web/app/page.tsxtsx · 71 lines · 2KB

Loading code…

omook-web/app/play/page.tsxtsx · 773 lines · 23KB

Loading code…

omook-web/app/play/play.module.csscss · 189 lines · 3KB

Loading code…

omook-web/components/OmokBoard.module.csscss · 116 lines · 2KB

Loading code…

omook-web/components/OmokBoard.tsxtsx · 85 lines · 3KB

Loading code…

omook-web/lib/ai.tstypescript · 160 lines · 4KB

Loading code…

omook-web/lib/board.tstypescript · 337 lines · 9KB

Loading code…

omook-web/lib/db.tstypescript · 190 lines · 6KB

Loading code…

omook-web/lib/gameTypes.tstypescript · 43 lines · 855B

Loading code…

omook-web/lib/guest.tstypescript · 48 lines · 2KB

Loading code…

omook-web/lib/omk3Client.tstypescript · 184 lines · 5KB

Loading code…

omook-web/lib/renderBoardPng.tstypescript · 118 lines · 3KB

Loading code…

omook-web/lib/vlmClient.tstypescript · 104 lines · 3KB

Loading code…

scripts/2 files
scripts/probe_vlm_coords.pypython · 182 lines · 5KB

Loading code…

scripts/vlm_text_client.pypython · 418 lines · 15KB

Loading code…

src/11 files
src/aiplayer.cppc++ · 136 lines · 4KB

Loading code…

src/aiplayer.hc++ · 9 lines · 237B

Loading code…

src/boardmodel.cppc++ · 505 lines · 16KB

Loading code…

src/boardmodel.hc++ · 127 lines · 6KB

Loading code…

src/boardwidget.cppc++ · 198 lines · 6KB

Loading code…

src/boardwidget.hc++ · 45 lines · 1KB

Loading code…

src/main.cppc++ · 21 lines · 543B

Loading code…

src/mainwindow.cppc++ · 962 lines · 35KB

Loading code…

src/mainwindow.hc++ · 90 lines · 3KB

Loading code…

src/tcpvlmclient.cppc++ · 386 lines · 12KB

Loading code…

src/tcpvlmclient.hc++ · 75 lines · 3KB

Loading code…