Purpose of this post

This post publishes the full MariaGO source code that implements what posts 1–7 explained step by step. There are many files, so they are folded by folder, and the code is loaded only when you open a file.

Models used

  • Production model: Qwen3-VL-8B-Instruct + LoRA adapter lora_mix_qwen_r5 (rank 16, alpha 32)
  • Input: text-only mode that feeds a two-digit aligned text board instead of a board image
  • Training and inference: LoRA training and serving with MLX (mlx-vlm) on a Mac Studio (Apple Silicon)
  • Training data: KGS 4-dan-and-above SGF records from u-go.net, focusing on the winner's moves with extra weight on atari and capture positions, mixed with coordinate-reading data
  • Training order: starting from the coordinate-only adapter, five rounds from r1 to r5 while changing the ratio of coordinate and move data. Only adapters that passed 90% or more on the coordinate test moved on to the next round

The first model we tried

At first we attached LoRA (rank 8, later 16) to Gemma 4 E4B-it 4bit (mlx-community). We observed the model reading coordinates skewed to one side, so we unified the board format for training and serving to aligned and switched the base model to Qwen3-VL-8B.

Supporting pieces

  • KataGo (b18c384nbt): position analysis, and an ensemble-judging experiment that picks one of the candidates proposed by several adapters
  • NumPy two-layer MLP policy: a REINFORCE self-play experiment with a legal-move mask (rl_env)
  • C++ heuristic AI: a safety net for answering atari, and a fallback move when the model fails to respond

Folder layout

  • src, tests: Qt6/C++ Go client, rule engine (goboard), scoring (gamejudge), heuristic AI
  • vlm_server: SGF parsing, training data generation, LoRA training, coordinate tests, move recommendation server
  • rl_env: NumPy reinforcement learning experiments
  • mariago-web: Next.js web game screen and game record API

Server deployment settings, remote access and monitoring scripts, training automation and experiment scripts, and the training data and model weights (hundreds of GB) are excluded from the release. Web operation code and configuration such as ads, login and rankings, debugging tools and the old Gemma model download script are also left out, so some imports point to unpublished files. Paths in the code such as /Volumes/MY_WORK/... refer to the author's Mac, so replace them with your own paths when running.

Full source

76 files · 18,629 lines — open a folder and click a file to load its code.

Project root2 files
CMakeLists.txttext · 34 lines · 759B

Loading code…

README.mdmarkdown · 63 lines · 5KB

Loading code…

mariago-web/25 files
mariago-web/app/api/analyze/route.tstypescript · 86 lines · 2KB

Loading code…

mariago-web/app/api/game/[code]/route.tstypescript · 57 lines · 2KB

Loading code…

mariago-web/app/api/game/list/route.tstypescript · 17 lines · 545B

Loading code…

mariago-web/app/api/game/route.tstypescript · 24 lines · 914B

Loading code…

mariago-web/app/api/player/route.tstypescript · 12 lines · 420B

Loading code…

mariago-web/app/globals.csscss · 53 lines · 995B

Loading code…

mariago-web/app/kibo/kibo.module.csscss · 149 lines · 2KB

Loading code…

mariago-web/app/kibo/page.tsxtsx · 115 lines · 4KB

Loading code…

mariago-web/app/layout.tsxtsx · 33 lines · 935B

Loading code…

mariago-web/app/page.tsxtsx · 40 lines · 982B

Loading code…

mariago-web/app/play/page.tsxtsx · 1,104 lines · 34KB

Loading code…

mariago-web/app/play/play.module.csscss · 252 lines · 4KB

Loading code…

mariago-web/components/GoBoard.module.csscss · 115 lines · 2KB

Loading code…

mariago-web/components/GoBoard.tsxtsx · 71 lines · 3KB

Loading code…

mariago-web/components/ModelSelector.module.csscss · 38 lines · 636B

Loading code…

mariago-web/components/ModelSelector.tsxtsx · 53 lines · 1KB

Loading code…

mariago-web/lib/board.tstypescript · 260 lines · 7KB

Loading code…

mariago-web/lib/db.tstypescript · 431 lines · 13KB

Loading code…

mariago-web/lib/gameTypes.tstypescript · 67 lines · 1KB

Loading code…

mariago-web/lib/guest.tstypescript · 40 lines · 1KB

Loading code…

mariago-web/lib/katagoTypes.tstypescript · 14 lines · 284B

Loading code…

mariago-web/lib/vlmClient.tstypescript · 98 lines · 3KB

Loading code…

mariago-web/lib/vlmModels.tstypescript · 39 lines · 2KB

Loading code…

mariago-web/package.jsonjson · 28 lines · 708B

Loading code…

mariago-web/README.mdmarkdown · 53 lines · 2KB

Loading code…

rl_env/11 files
rl_env/__init__.pypython · 18 lines · 500B

Loading code…

rl_env/board.pypython · 196 lines · 6KB

Loading code…

rl_env/env.pypython · 79 lines · 2KB

Loading code…

rl_env/eval_policy.pypython · 68 lines · 2KB

Loading code…

rl_env/policy_numpy.pypython · 157 lines · 5KB

Loading code…

rl_env/requirements-train.txttext · 2 lines · 104B

Loading code…

rl_env/test_legal.pypython · 76 lines · 2KB

Loading code…

rl_env/test_phase2.pypython · 34 lines · 917B

Loading code…

rl_env/test_phase3.pypython · 35 lines · 1003B

Loading code…

rl_env/train_reinforce.pypython · 90 lines · 3KB

Loading code…

rl_env/train_selfplay.pypython · 137 lines · 5KB

Loading code…

src/13 files
src/aiplayer.cppc++ · 531 lines · 20KB

Loading code…

src/aiplayer.hc++ · 26 lines · 1KB

Loading code…

src/boardwidget.cppc++ · 309 lines · 10KB

Loading code…

src/boardwidget.hc++ · 72 lines · 3KB

Loading code…

src/gamejudge.cppc++ · 427 lines · 15KB

Loading code…

src/gamejudge.hc++ · 95 lines · 4KB

Loading code…

src/goboard.cppc++ · 419 lines · 12KB

Loading code…

src/goboard.hc++ · 189 lines · 7KB

Loading code…

src/main.cppc++ · 23 lines · 662B

Loading code…

src/mainwindow.cppc++ · 2,698 lines · 107KB

Loading code…

src/mainwindow.hc++ · 288 lines · 12KB

Loading code…

src/tcpvlmclient.cppc++ · 469 lines · 15KB

Loading code…

src/tcpvlmclient.hc++ · 91 lines · 4KB

Loading code…

tests/4 files
tests/atari_smoketest.cppc++ · 341 lines · 13KB

Loading code…

tests/test_cross_lessons.pypython · 129 lines · 4KB

Loading code…

tests/test_monitor_heuristic.pypython · 135 lines · 5KB

Loading code…

tests/test_pass_guard.pypython · 192 lines · 6KB

Loading code…

vlm_server/21 files
vlm_server/__init__.pypython · 6 lines · 202B

Loading code…

vlm_server/__main__.pypython · 372 lines · 13KB

Loading code…

vlm_server/cross_lessons.pypython · 428 lines · 13KB

Loading code…

vlm_server/dataset_baduk.pypython · 734 lines · 26KB

Loading code…

vlm_server/dataset_coords.pypython · 190 lines · 6KB

Loading code…

vlm_server/dataset_hogu.pypython · 214 lines · 8KB

Loading code…

vlm_server/dataset_ladder.pypython · 396 lines · 16KB

Loading code…

vlm_server/dataset_opening.pypython · 127 lines · 4KB

Loading code…

vlm_server/eval_vlm_vs_vlm.pypython · 458 lines · 16KB

Loading code…

vlm_server/ladder.pypython · 322 lines · 10KB

Loading code…

vlm_server/policy_backend.pypython · 164 lines · 5KB

Loading code…

vlm_server/README.mdmarkdown · 91 lines · 3KB

Loading code…

vlm_server/requirements.txttext · 7 lines · 195B

Loading code…

vlm_server/server.pypython · 2,474 lines · 99KB

Loading code…

vlm_server/sgf_download.pypython · 215 lines · 7KB

Loading code…

vlm_server/sgf_parser.pypython · 196 lines · 6KB

Loading code…

vlm_server/shapes.pypython · 83 lines · 3KB

Loading code…

vlm_server/train_lora.pypython · 294 lines · 11KB

Loading code…

vlm_server/TRAINING.mdmarkdown · 437 lines · 18KB

Loading code…

vlm_server/verify_board.pypython · 331 lines · 11KB

Loading code…

vlm_server/verify_coords.pypython · 418 lines · 13KB

Loading code…