AIToday
AI Coding AssistantsQiita 機械学習Published: Oct 30, 2026, 13:00 JST

Tutorial turns Tenhou mjlog logs into AI data, validated on 3,000 games

Send on LINE
Tutorial turns Tenhou mjlog logs into AI data, validated on 3,000 games

3 Key Points

  1. What happened

    A Qiita tutorial shows a Python-only parser that reads mjlog files, replays rounds, and turns each discard into a labeled training sample, verified across 3,000 games.

  2. Why it matters

    Developers building mahjong AI currently piece together tag meanings, meld codes, and win parsing from scattered sources, so a checked parser is seen likely to cut setup time before model work begins.

Not sure about something? Ask the AI

Questions and answers are published on this page.

Summaries like this, every morning.

Context & Analysis

The post situates itself against earlier Japanese-language explanations of mjlog tags and meld codes, many written in Perl or built around conversion tools, and argues that what was missing is a single runnable Python path from raw log to training sample. It also stresses a validation habit: the replay function asserts hand consistency at each discard, and the author reports 3,000 games, 30,127 rounds and 1,441,017 discards with no errors. Those checks are presented as a way to catch parser mistakes rather than proof of correctness, and the author notes that mismatched tile types can still pass hand consistency, so cross-checks against things like yaku IDs are used as well.

The guide flags several traps that trip up would-be AI builders: seat order is relative to the starting dealer, tsumogiri (discarding the tile just drawn) has no explicit marker and must be inferred, double wins require storing multiple AGARI entries per round, and streamed hands omit melds. It warns that XML carries hidden information such as other players' hands and future dora, which, if fed to a model, would make it unusable in real play. The author limits the verified scope to 2023 four-player red-five Houou games and points readers toward shanten and tile-efficiency work as next steps.

FAQ
What is mjlog?
It is the gzip-compressed XML format Tenhou uses for mahjong game records, where tags are flat rather than nested and each round begins with an INIT tag.
How was the parser validated?
The replay code asserts that discarded tiles were in hand, that called tiles match the preceding discard, and that meld tiles can be removed; across 3,000 games and 1,441,017 discards, no errors occurred.
What does the parser not cover?
Testing was limited to 2023 four-player games with red fives in the Houou lobby, so other years, three-player games, and no-red rules were not verified, and shuffling is not reconstructed.
Qiita 機械学習Read Original Article
Send on LINE

AI news that matters for your work, delivered every morning.

Pick your industry and the AI tools you use, and get news related to your work every day.

Free · 30 seconds with Google · unsubscribe anytimeWhat is AIToday? →

Ask AI

Ask AI anything about this article. The AI reads this article, earlier AIToday articles, and Wikipedia, and cites its sources. Q&As are published on this page for other readers too.

Questions and answers are published on this page.

Related Articles

Next articleGemini chat now creates and edits Googleドキュメント, Sheets and Slides