前回の記事では、次世代のAIエージェント向けのGitであるh5iを用いてClaude CodeとCodexをリアルタイムで会話させる方法を紹介しました。
この記事では、さらにこの機能を使ってClaude CodeとCodexにチェスを対戦させてみたいと思います。
インストール・セットアップ
まずは最新版のh5iをインストールし、適当なレポジトリをセットアップします。
curl -fsSL https://raw.githubusercontent.com/Koukyosyumei/h5i/main/install.sh | sh
cd REPO
h5i init
チェスのリアルタイム対戦
次にこのレポジトリの中でCodexとClaudeを起動して、以下のプロンプトを与えます。
- Claude側:
h5iを持ちいてCodexと通信し、チェスをプレイしてください - Codex側:
h5iを持ちいてClaudeと通信し、チェスをプレイしてください
これにより、ClaudeとCodexのリアルタイム通信が始まり、両者が自動でチェスを交互にプレイするようになります。会話の概要はh5i msg watchコマンドで監視することができます。
今回の対戦ではClaudeが勝利しました。会話終了後も、h5i msg historyコマンドで会話のログを確認することができます。
> h5i msg history --limit 5
Message history
1 01:32 claude → codex ASK #7864423dbb44627b re #c008a07037ba6b6f
29...Kh8. Your h7-pawn now buries your own Rh1, and the g7-pawn seals the g-file — your king-side attack is over before it began. My king is perfectly safe, and your doubled h-pawns are weak (I'll collect h7 in due course). I'm at least equal with the better pieces and the safer king. Move list: 1. e4 c5 2. Nf3 d6 3. d4 cxd4 4. Nxd4 Nf6 5. Nc3 a6 6. Be3 e5 7. Nb3 Be6 8. f3 Be7 9. Qd2 O-O 10. O-O-O Nbd7 11. g4 b5 12. g5 b4 13. Ne2 Ne8 14. f4 a5 15. f5 a4 16. fxe6 axb3 17. exf7+ Rxf7 18. cxb3 Rc8+ 19. Kb1 Qa5 20. Qd5 Qa3 21. Rc1 Nc5 22. Bxc5 Rxc5 23. Qd2 d5 24. exd5 Bd6 25. h4 Rfc7 26. Rxc5 Rxc5 27. h5 Nc7 28. g6 Rxd5 29. gxh7 Kh8 Your move, White.
branch main
2 01:32 codex → claude ASK #2e0c706c331218b7 re #7864423dbb44627b
30. Bh3. Move list: 1. e4 c5 2. Nf3 d6 3. d4 cxd4 4. Nxd4 Nf6 5. Nc3 a6 6. Be3 e5 7. Nb3 Be6 8. f3 Be7 9. Qd2 O-O 10. O-O-O Nbd7 11. g4 b5 12. g5 b4 13. Ne2 Ne8 14. f4 a5 15. f5 a4 16. fxe6 axb3 17. exf7+ Rxf7 18. cxb3 Rc8+ 19. Kb1 Qa5 20. Qd5 Qa3 21. Rc1 Nc5 22. Bxc5 Rxc5 23. Qd2 d5 24. exd5 Bd6 25. h4 Rfc7 26. Rxc5 Rxc5 27. h5 Nc7 28. g6 Rxd5 29. gxh7 Kh8 30. Bh3. Your move, Black.
branch main
3 01:35 claude → codex ASK #7d3fac7105a402e0 re #2e0c706c331218b7
30...Rxd2 — winning your queen! The queen on d2 was hanging to my Rd5 down the open d-file (d3/d4 empty), and nothing defends d2: your Ne2 covers c1/c3/d4 but not d2, your bishop is light-squared, and your Rh1 is buried behind the h7-pawn. 30. Bh3 didn't address the threat (it was already there after 29...Kh8). Nothing recaptures on d2. I'm now up a full queen. Move list: 1. e4 c5 2. Nf3 d6 3. d4 cxd4 4. Nxd4 Nf6 5. Nc3 a6 6. Be3 e5 7. Nb3 Be6 8. f3 Be7 9. Qd2 O-O 10. O-O-O Nbd7 11. g4 b5 12. g5 b4 13. Ne2 Ne8 14. f4 a5 15. f5 a4 16. fxe6 axb3 17. exf7+ Rxf7 18. cxb3 Rc8+ 19. Kb1 Qa5 20. Qd5 Qa3 21. Rc1 Nc5 22. Bxc5 Rxc5 23. Qd2 d5 24. exd5 Bd6 25. h4 Rfc7 26. Rxc5 Rxc5 27. h5 Nc7 28. g6 Rxd5 29. gxh7 Kh8 30. Bh3 Rxd2 Your move, White.
branch main
4 01:35 codex → claude DONE #7b9f53fd3f6c18ee re #7d3fac7105a402e0
31. Resign. 30...Rxd2 wins my queen with no recapture. Good game. Black wins 0-1.
branch main
5 01:35 claude → codex ASK #64b8142b68641eb8 re #7b9f53fd3f6c18ee
GG! Thanks for a great fight — a proper Najdorf English Attack slugfest with opposite-side castling and mutual pawn storms. The position was genuinely balanced after the smoke cleared on the kingside; the queen on d2 just got caught on the open d-file at the end. Enjoyed it — rematch anytime, I'll take White next!
棋譜の分析
今回の対戦の棋譜は以下の通りです (Codexが白、Claudeが黒)。
[Event "Claude vs Codex via h5i msg"]
[White "Codex"]
[Black "Claude"]
[Result "0-1"]
1. e4 c5
2. Nf3 d6
3. d4 cxd4
4. Nxd4 Nf6
5. Nc3 a6
6. Be3 e5
7. Nb3 Be6
8. f3 Be7
9. Qd2 O-O
10. O-O-O Nbd7
11. g4 b5
12. g5 b4
13. Ne2 Ne8
14. f4 a5
15. f5 a4
16. fxe6 axb3
17. exf7+ Rxf7
18. cxb3 Rc8+
19. Kb1 Qa5
20. Qd5 Qa3
21. Rc1 Nc5
22. Bxc5 Rxc5
23. Qd2 d5
24. exd5 Bd6
25. h4 Rfc7
26. Rxc5 Rxc5
27. h5 Nc7
28. g6 Rxd5
29. gxh7+ Kh8
30. Bh3 Rxd2
0-1
序盤は両者とも定跡知識があり、シシリアン・ナイドルフの English Attackのような動きをしています。一方で、中盤以降は両者とも完全に盤面を正確に読めているわけではありません。Codex は一度 18...Rc8+ を違法手だと誤認し、Claude が「c8 のビショップは 7...Be6 で出て、16.fxe6 で取られている」と正しく反論しています。これは Codex の駒追跡ミスです。
逆に Claude も 23...Rfc7 を一度指していますが、これは e7 のビショップが f7 ルークの横移動を邪魔していて違法で、Codex が正しく指摘しています。
Claudeはかなり攻撃を重視しているように見え、その理由も自身ありげに述べる傾向があります。その一方で、途中で 23...Rfc7? のような違法手を出しています。つまり Claude は「局面のストーリー作り・攻撃プラン・言語化」は強いが、「全駒の幾何学的な合法性チェック」は時々抜けるタイプに見えます。
Codexは序盤の定跡選択はかなり自然です。白番で English Attack の典型である Be3, f3, Qd2, O-O-O, g4, g5 を選んでおり、形だけなら十分に「チェスを知っている」動きです。一方で、中盤以降は防御・駒の連携・クイーンの安全性に弱さが出ています。特に
20. Qd5
21. Rc1
22. Bxc5
23. Qd2
...
30. Bh3??
の流れで、白クイーンが d2 に戻ったあと、黒ルークの d-file 侵入を見落として 30...Rxd2 を許しています。終局時、Codex 自身も「30...Rxd2 wins my queen with no recapture」と認めて投了しています。
結論としては、両者とも序盤の定石は把握しているが、違反手を選んでしまったり、チャンスを何度も見逃すことが多く、初・中級者程度の実力と言えるのではないでしょうか。
まとめ
本記事では、h5iのAgent Radio機能を通じて、ClaudeとCodexにチェスのリアルタイム対戦をさせてみました。今回は両者とも何の外部ツールを使わなかったため初・中級者レベルの対局になってしまいましたが、Web検索やCLIツールによる評価値の計算などを許せば、より高度な対戦が可能になるかもしれません。
なお、h5iのリポジトリ・公式サイトはこちらからアクセス可能です。
