Home›VS Code / Dev Env›VS Codeで動く推理ゲームエンジンを作った——AIが書いた事件が「ちゃんと解けるか」まで自動チェックする
VS Codeで動く推理エンジンを作った——AIが書いた事件が「本当に解けるか」を機械で検証する

VS Codeで動く推理ゲームエンジンを作った——AIが書いた事件が「ちゃんと解けるか」まで自動チェックするA developer built a VS Code extension that statically analyzes evidence…

元記事を読むRead original articleqiita.com(新しいタブで開きます)(opens in a new tab)
AI2 点サマリSummary highlight
  • 生成AIが作った推理ゲームの証拠依存関係を静的解析し、循環参照や解けない詰まりを自動検出するVS Code拡張を個人開発。
  • AIコンテンツの論理的整合性を機械的に保証する手法として注目される。

A developer built a VS Code extension that statically analyzes evidence dependency graphs in AI-generated mystery scenarios, automatically detecting circular dependencies and unsolvable dead ends to verify that cases are actually completable.

本ページの本文と要約は AI による自動生成です。日本語版と英語版は言語ごとに独立して生成されるため、表現や詳しさが異なる場合があります。正確性は元記事 (qiita.com) をご確認ください。The body and summaries are AI-generated independently for each language, so wording and detail may differ. Verify accuracy at the original source (qiita.com).

要約と収集メタデータに基づく AI 解説。元記事全文の転載・翻訳ではありません。AI explainer based on the summaries and collected metadata, not a copy or translation of the full source article.

生成AIに推理事件を書かせると、読み物としては成立していても、いざゲームとして遊ぶと途中で行き詰まる——。この課題に対し、ある開発者がVS Code拡張として、AIが生成した推理シナリオの「証拠の依存関係」を静的解析し、事件が本当に解けるかを機械的に検証する仕組みを個人開発した。

問題の核心は、証拠や手がかりの入手順序にある。生成AIは自然な文章を書くのは得意な一方で、ゲーム全体を貫く論理構造までは保証しない。たとえば「証拠Aを得るには証拠Bが必要で、証拠Bを得るには証拠Aが必要」という循環参照や、鍵のかかった箱の中にその箱の鍵が入っているような、原理的に到達できない状態が紛れ込むことがある。文章を読んでいるだけでは気づきにくく、実際にプレイして初めて詰まりが露呈する。

この拡張機能は、シナリオ内の証拠同士の前提条件をグラフとして捉え、循環参照や解けない行き止まりを自動で洗い出す。プログラムのソースコードを実行せずに解析する「静的解析」の考え方を、物語コンテンツの整合性チェックに応用した形だと言える。開発環境であるVS Code上で動くため、シナリオを執筆・編集しながら破綻を早期に発見できる点が実務的とみられる。

背景には、生成AIをゲーム制作に取り込む動きの広がりがある。テキスト生成は下書きやアイデア出しを大幅に効率化する一方、生成物が仕様として成立しているか、遊べる状態になっているかは別問題だ。人手のテストプレイに頼るとコストがかさむため、検証できる部分を機械的に切り出す発想は、他のインタラクティブコンテンツにも応用できる可能性がある。

もっとも、静的解析が保証できるのは依存関係の構造的な整合性であり、事件の面白さや推理の納得感まで機械が判定できるわけではない。それでも、AIが量産したコンテンツの「解けなさ」を早い段階で潰せる意義は小さくない。生成AIの出力を人間がどう検品するかという、より一般的な課題に対する一つの具体例として参考になりそうだ。

Generative AI has made it trivial to produce mystery-story text on demand, but a scenario that reads well is not the same as a puzzle that can actually be solved. A developer has released a VS Code extension that tackles exactly this gap, statically analyzing the evidence dependency graphs inside AI-generated mystery cases to automatically flag circular dependencies and unsolvable dead ends. The project is notable because it treats logical solvability as something a machine can verify, rather than something a human playtester must discover by getting stuck.

The problem the tool addresses is familiar to anyone who has asked a large language model to "write an interesting mystery case." The output often looks plausible and is pleasant enough to read, yet it falls apart the moment you try to play it as a game. The developer describes the canonical failure mode: obtaining evidence A requires evidence B, but obtaining evidence B requires evidence A. It is the logical equivalent of a locked box whose only key is sealed inside the box itself. On the page, these dependencies are easy to overlook because the prose flows smoothly; in play, they produce a point where progress simply halts and the player can go no further.

To catch these situations, the extension models a case as a dependency graph. Each piece of evidence, clue, or unlockable location becomes a node, and the prerequisites needed to reach it become directed edges. Once a scenario is expressed this way, well-established graph algorithms can be applied. Detecting a circular dependency, for example, reduces to finding a cycle in a directed graph, while identifying an unreachable "dead end" amounts to checking whether a node can be reached from the player's starting state. Because this analysis is static, it inspects the structure of the scenario without requiring anyone to actually play through every branching path, which is where the approach draws its leverage.

This is a practical application of static analysis, a technique more commonly associated with software engineering. Compilers and linters routinely examine source code without running it to surface problems such as unreachable statements, undeclared variables, or cyclic module imports. The extension appears to borrow that same mindset and point it at narrative content, treating a mystery scenario as a kind of program whose "bug" is an unwinnable state. Framing AI-generated content as something that can be checked against formal constraints is an increasingly discussed idea, since generative models optimize for text that reads convincingly rather than text that satisfies hidden structural rules.

Choosing VS Code as the host is a pragmatic decision. The editor has become a default workspace for many developers and, increasingly, for people authoring structured text and data files. Its extension marketplace is large and its extension API is mature, giving a solo developer a realistic path to distribute a niche tool and integrate feedback directly into an authoring loop. In principle, a writer could draft or paste an AI-produced case into the editor and receive immediate warnings about broken dependency chains, much as a programmer sees squiggly underlines beneath a syntax error. This tight edit-and-verify cycle is one of the main reasons editor extensions are an attractive delivery format for validation tools.

The broader context is the growing effort to make generative-AI output verifiable rather than merely fluent. Techniques such as constrained decoding, schema validation for structured outputs, and automated test harnesses all share the goal of ensuring that generated artifacts meet requirements a human might otherwise have to check by hand. A mystery game is a compact, well-defined domain for this idea, because "the case is completable" is a property that can be stated precisely and tested mechanically. For game designers experimenting with AI-assisted content, that kind of guarantee is valuable, since manual playtesting for logical soundness is slow and easy to get wrong.

It is worth keeping the scope realistic. Verifying that a case is structurally solvable is a different and narrower claim than verifying that it is fair, satisfying, or genuinely clever to play, and the developer's stated focus is on logical consistency rather than narrative quality. Whether the approach generalizes cleanly to more complex scenarios with conditional or optional clues likely depends on how faithfully those relationships can be encoded as a graph. Even so, as a personal project it demonstrates a concrete, reproducible method for holding AI-generated content to a checkable standard, and it points toward a wider pattern of pairing generative tools with automated verification.

ポコとTECHガイドPoko & TECH Guide

ポコと当サイトのTECHガイドが、記事の要約と収集した情報から読みどころを語るAI生成の対話です。Poko and TECH Dashboard's own TECH Guide discuss the article's highlights in an AI-generated conversation based on its summary and collected source details.

  1. ポコPoko証拠の依存関係を「静的解析」するって何? ゲームを実際に遊んで調べるのとは違うの?What does “static analysis” of evidence dependencies mean? Is that different from actually playing through the game?
  2. TECHガイドTECH Guide簡単に言うと、遊ぶ前に証拠同士のつながりを機械的に調べることじゃな。記事によれば、VS Code拡張が循環や詰まりを検出するんじゃよ。Simply put, it checks how clues connect before anyone plays. According to the article, the VS Code extension detects circular dependencies and dead ends.
  3. ポコPokoそれって何が嬉しいの? AIがそれらしい事件を書いても、解けないゲームになるのを見つけられるってこと?Why is that useful? Does it catch cases where AI writes a convincing mystery that turns out to be impossible to solve?
  4. TECHガイドTECH Guideその通りじゃ。証拠AにBが必要なのに、BにもAが必要、といった進めない構造を自動で見つけ、事件を完了できるか確かめられるんじゃよ。Exactly. It can automatically spot structures where clue A requires B while B requires A, helping verify whether the case can actually be completed.
  5. ポコPokoなるほど! AIの文章が自然かだけじゃなく、ゲームとして最後まで解ける構造かもチェックするんだね。Got it! It checks not just whether the AI’s writing sounds convincing, but whether the mystery is structured so players can solve it to the end.
  6. TECHガイドTECH Guideそうじゃな。記事が示すのは証拠依存関係の論理チェックなので、面白さの評価とは分けて見るのがポイントじゃよ。That’s right. The article focuses on logical checks of evidence dependencies, so it’s important to distinguish solvability from judging whether the mystery is entertaining.
記事情報・収集記録Article details & collection record
出典Source
Qiita VSCodeコミュニティCommunity
公開日時 (JST)Published (JST)
収集日時 (JST)Collected (JST)
配信形式Format
ブログBlog
原文言語Source language
JA
重要度の位置づけImportance in this lane
MediumMedium priority(VS Code / Dev Env 58件中、同等以上 39件)(39 of 58 VS Code / Dev Env entries are equal or higher)
出典の平均重要度(掲載直近 30 件・最大 30 件)Source average (last 30 listed, up to 30)
1.7 / 31=情報 · 2=中 · 3=高1=Info · 2=Medium · 3=High
情報の寿命Half-life
中期 (チュートリアル)Medium-term (tutorial)

🔷VS Code / Dev Env の他の記事More from VS Code / Dev Envもっと見る →View more →

ページ上部へScroll to top