A Reverse Hex Solver

Kenny Young, Ryan B. Hayward

Abstract

We present Solrex, an automated solver for the game of Reverse Hex (also known as Rex or Misère Hex). In this variant, the player who completes a connection between their two sides loses. Solrex utilizes a Scalable Parallel Depth First Proof Number (SP-DFPN) search, enhanced by Rex-specific pruning theorems and early detection of winning strategies. Implemented on the same codebase as the Hex solver Solhex, Solrex successfully solves arbitrary positions on board sizes up to 6x6. The most challenging 6x6 position was solved in under four hours using four threads.

Introduction

Hex is a classic connection game played on a rhombic board of hexagons, famous for the impossibility of a draw. Reverse Hex (Rex) flips the objective: players strive to avoid connecting their sides. This "misère" version is significantly more complex and counter-intuitive than standard Hex. Martin Gardner once highlighted the 4x4 Rex board as a problem of unknown complexity, where a winning line of play remained elusive for decades.

The primary challenge in Rex is that standard Hex heuristics, such as "virtual connections," are often counterproductive. In Rex, adding a stone to the board is generally a disadvantage, and games typically last longer as players avoid completing paths.

Methodology

Solrex adapts the high-performance architecture of Solhex but introduces logic specific to the misère objective.

Search and Pruning

The core of Solrex is the Scalable Parallel Depth First Proof Number (SP-DFPN) Search. This algorithm prioritizes nodes that are most likely to prove or disprove a win/loss state. To manage the search space, the authors established new pruning theorems. For instance, an uncolored cell is considered "dead" if it cannot contribute to a connection for either player, allowing the solver to ignore it.

A 5x5 board illustrating Rex-specific pruning, where shaded cells represent 'dead' areas that do not contribute to connections.

Instead of seeking winning paths, Solrex identifies "pairing strategies." If a player can ensure they occupy at most one cell in a specific pair, they can force the opponent to eventually occupy losing cells. This is powered by an Augmented H-Search, a deduction algorithm modified to find "pre-join-pairing" strategies—moves that trap the opponent into completing a connection.

Results and Discussion

Solrex was evaluated on small Rex boards, focusing on previously unsolved positions and complete board suites.

Solving the 4x4 and 6x6 Boards

The solver successfully "closed" the 4x4 game by finding the winning line for the 1.Bd1 opening, a position that had remained unsolved in previous literature. Furthermore, Solrex solved all 18 unique 6x6 openings. The entire 6x6 suite was completed in approximately 7 hours, with the hardest single position taking less than 4 hours on a quad-core machine.

The 4x4 Rex board with coordinate labels, used to identify the 1.Bd1 opening and other strategic positions.

Ablation studies revealed that H-search is the most critical component of the solver. Disabling H-search resulted in the solver being approximately 90 times slower on 5x5 boards, demonstrating its necessity in avoiding combinatorial explosion.

Insights into Rex Complexity

The research confirms that Rex is "deeper" than standard Hex. In Hex, strong connections often allow for early victory detection. In Rex, the loser can often force the game to continue until the board is nearly full, leading to significantly deeper search trees. The authors also proved that adding a stone of one's own color is generally a disadvantage, a fundamental reversal of standard Hex strategy.

Conclusion

Solrex represents the first automated solver to successfully tackle the complexities of Reverse Hex up to 6x6. By combining SP-DFPN search with specialized pruning and pairing strategies, the authors transformed a game once thought "too complex" into a solved problem. Future work includes scaling to 7x7 boards and adapting these pairing strategies to other connection games like Havannah or Twixt.

Summary updated

Abstract

We present Solrex,an automated solver for the game of Reverse Hex.Reverse Hex, also known as Rex, or Misere Hex, is the variant of the game of Hex in which the player who joins her two sides loses the game. Solrex performs a mini-max search of the state space using Scalable Parallel Depth First Proof Number Search, enhanced by the pruning of inferior moves and the early detection of certain winning strategies. Solrex is implemented on the same code base as the Hex program Solver, and can solve arbitrary positions on board sizes up to 6x6, with the hardest position taking less than four hours on four threads.
BibTeX
@inproceedings{young2016reverse,
  author = {Kenny Young and Ryan B. Hayward},
  title = {{A Reverse Hex Solver}},
  booktitle = {Computers and Games},
  year = {2016},
  doi = {10.1007/978-3-319-50935-8\_13},
}
Figure