From Images to Connections: Can DQN with GNNs learn the Strategic Game of Hex?

Yannik Keller, Jannis Blüml, Gopika Sudhakaran, Kristian Kersting · DOI

Abstract

Traditional AI for board games relies heavily on Convolutional Neural Networks (CNNs), which excel at local pattern recognition but often struggle with long-range strategic dependencies. This paper explores replacing CNNs with Graph Neural Networks (GNNs) in the game of Hex. We demonstrate that GNNs better capture topological connections and exhibit superior zero-shot transfer capabilities across varying board sizes compared to traditional grid-based architectures.

Introduction

Most state-of-the-art AI for board games, such as AlphaZero, relies on CNNs. These networks have a built-in "relational inductive bias" toward locality—they assume that the most important information for any given square is located in its immediate neighborhood. While this works well for games like Go, many strategic games involve non-local dependencies that a simple grid-based approach may overlook.

The Challenge of Non-Local Dependencies

Strategic games often involve dependencies that span the entire board. In Chess, a bishop can influence a square on the opposite side of the board. In Hex, winning depends entirely on creating a continuous path of connections across the board. Treating a board as a simple grid of pixels (an image) ignores the underlying relational structure—the connections—that actually defines the game's strategy.

Figure 1: Non-local dependencies in Chess (a), Go (b), and Hex (c) illustrate why grid-based CNNs may struggle with global connectivity compared to graph-based approaches.

Methodology

The researchers focus on Hex, a game played on a hexagonal grid where players attempt to connect their two sides of the board. Hex is unique because it can be mathematically represented as a "Shannon vertex-switching game"—essentially, a graph problem. By passing messages between adjacent nodes in the graph, a GNN can propagate information about connectivity across the entire board much more naturally than a CNN.

Figure 2: The transformation of a Hex board (a) into its corresponding graph representation (b) for processing by Graph Neural Networks.

Two new models were introduced:

  1. GraphDQN: A combination of GNNs (using GraphSAGE layers for message passing) and the RainbowDQN reinforcement learning algorithm.
  2. GraphAra: An AlphaZero-inspired framework that replaces the standard Residual CNN (ResNet) with a GNN, combined with Monte-Carlo Tree Search (MCTS).

Key Insights and Ideas

Topology over Geometry

CNNs are sensitive to the exact "image" of the board. GNNs, however, care about the topology—how pieces are connected. This makes GNNs much more robust to "irrelevant" board details and allows them to handle "ladders" (long sequences of forced moves) naturally through iterative message passing.

Zero-Shot Scaling

Because GNNs operate on graphs rather than fixed-size pixel grids, a GNN trained on an $11 \times 11$ board can be deployed on a $24 \times 24$ board without any retraining. CNNs usually require a fixed input size or struggle to generalize when the board dimensions change significantly.

Key Results

  • Superior Global Strategy: In long-range dependency tests, GraphDQN made only one error across all board sizes. In contrast, the best CNN baseline made 31 errors, frequently failing to recognize winning connections on larger boards.
  • Resistance to Overfitting: CNNs (especially U-Net) showed a massive gap between training and validation accuracy, essentially memorizing board patterns. The GNN converged more slowly but generalized much better to unseen positions.
  • Playing Strength: The self-play agent, GraphAra-SP, achieved a 66.67% win rate against MoHex-1k (a strong heuristic-based search engine), proving that GNNs can reach competitive levels of play.
  • Board Size Transfer: When tested on board sizes different from their training ($8 \times 8$ to $15 \times 15$), GNNs maintained a much more stable win rate than CNNs, which saw performance plummet as board size increased.

Limitations and Future Work

While GNNs excel at global strategy, they are slightly less proficient than CNNs at discerning very fine-grained local patterns. Additionally, GNNs can be more computationally expensive than highly optimized CNNs. Future research should explore hybrid architectures or more sophisticated graph representations to bring these topological benefits to a wider variety of strategic domains like Go or Chess.

Summary updated

BibTeX
@misc{keller2023from,
  author = {Yannik Keller and Jannis Blüml and Gopika Sudhakaran and Kristian Kersting},
  title = {{From Images to Connections: Can DQN with GNNs learn the Strategic Game of Hex?}},
  year = {2023},
  eprint = {2311.13414},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2311.13414},
}
Figure