Regex Chess: A 2-ply minimax chess engine in 84,688 regular expressions
AIThis post was created with the assistance of artificial intelligence (AI).

TL;DR

A programmer has built a chess engine that plays a 2-ply minimax game using a sequence of 84,688 regular expressions. The project showcases an unconventional method of programming game logic with regex. The development raises questions about the efficiency and practicality of such approaches.

A developer has built a chess engine that operates entirely through a sequence of 84,688 regular expressions, effectively playing a 2-ply minimax game. This demonstrates an unconventional method of programming game logic using regex, highlighting both novelty and technical curiosity.

The project was shared publicly on GitHub by an individual programmer experimenting with regex as a computational tool. The engine interprets a chessboard state as a string and applies a long list of regular expressions to simulate moves. You can see a similar chess puzzle I found in my dad’s old book for understanding different chess positions. It is capable of playing a valid, though not highly optimized, game of chess by executing these expressions sequentially. The core idea involves encoding chess instructions and game state transformations within regex patterns, effectively creating a custom, regex-based CPU. The entire process is designed as a proof of concept rather than a practical chess engine, but it demonstrates the flexibility of regex in simulating computational processes.

Why It Matters

This development is notable because it pushes the boundaries of what can be achieved with regular expressions, a tool traditionally used for pattern matching rather than computation. It raises questions about the limits of regex-based programming, the potential for unconventional computing models, and the creative exploration of code as a form of computational art. For the broader programming community, it exemplifies how familiar tools can be repurposed in unexpected ways, potentially inspiring novel approaches to problem-solving or educational demonstrations.

Amazon

regex pattern matching tools

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Background

Regular expressions are widely used for string matching, data validation, and text processing. Using them as a basis for a chess engine is highly unconventional. Prior projects have explored esoteric computing models, but this is a rare example of applying regex at such a scale for a complex task like chess. The project was shared during the holiday season, reflecting a personal experimentation rather than a commercial or research-driven development. The approach involves encoding game rules, move generation, and evaluation within regex patterns, which are then executed in sequence to simulate gameplay. For more insights, check out this chess puzzle I found in my dad’s old book.

“Expressions is possible, and also what the specific regular expressions do.”

— the developer

“This is a fascinating demonstration of regex as a computational tool, even if not practical.”

— a programming enthusiast

Amazon

regular expressions for programming

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

What Remains Unclear

It remains unclear how efficient or scalable this regex-based engine is for longer or more complex games. The practical applications are limited, and the implementation is primarily a demonstration of concept rather than a competitive chess engine. The full extent of the computational limits of this approach has not been tested or documented. You might find this chess puzzle I found in my dad’s old book interesting for exploring different chess strategies.

Amazon

chess puzzle books for beginners

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

What’s Next

Further experimentation may explore optimizing the regex sequences, expanding the engine to deeper plies, or applying similar techniques to other games. The developer might also analyze the computational complexity and potential for practical use, though current indications suggest this is mainly a creative exploration rather than a practical tool.

Amazon

coding challenge books

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Key Questions

How does regex-based chess work?

The engine encodes the game state and rules as a sequence of regular expressions. Applying these expressions sequentially updates the game state, effectively simulating move generation and evaluation within regex patterns.

Is this approach practical for real chess engines?

No. The method is primarily a proof of concept demonstrating the flexibility of regex rather than a practical solution. It is computationally inefficient compared to traditional chess engines.

What inspired this project?

The developer was motivated by a desire to experiment with regex as a computational medium and to explore its limits in a playful, purpose-free project. For a related exploration, see this chess puzzle I found in my dad’s old book.

Could this method be extended to other games?

In theory, yes. The concept involves encoding game rules within regex patterns, which could be adapted to other turn-based or rule-based games, though practical limitations exist.

Source: Hacker News

You May Also Like

I Found 29 Early Prime Day Deals That Are Worth Shopping Now (2026)

Discover 29 confirmed Prime Day deals available early in 2026, including laptops, earbuds, and smart home devices, ahead of the official sale.

Report: Roughly half of the id Software team have been laid off

Approximately 1,000 employees at id Software have been laid off, marking a significant restructuring within the game developer.

Meta deletes popular 1M follower account after Kuwaiti request

Meta removed a popular account with 1 million followers after a request from Kuwaiti authorities, raising questions about content moderation and censorship.

Instagram Surges In Global Coverage

Instagram’s coverage has surged worldwide, with mentions increasing 2.5 times in recent monitoring, signaling a significant expansion in its global presence.