TL;DR
A programmer has built a minimal chess engine that plays using a sequence of 84,688 regular expressions. This demonstrates an innovative, though impractical, method of programming game logic with regexes. The project highlights the versatility of regex but raises questions about efficiency and applicability.
A developer has constructed a functional chess engine that plays using a sequence of 84,688 regular expressions, marking an unconventional use of regex for game programming. This demonstrates that complex decision-making can be encoded in pattern matching, though the approach is largely experimental and not practical for real-world use.
The project, shared on Hacker News, involves a list of 84,688 regex patterns that, when executed in order, interpret a chessboard state and generate moves. You can see a similar example of regex-based game engines. The developer describes it as a ‘regex computer’ designed to interpret instructions similar to a GPU or CPU instruction set, but using only regex transformations. The code is minimal and intentionally designed to show that regex can be used to simulate a chess engine’s move selection process.
According to the developer, the engine processes a string representing the chessboard and applies each regex pattern sequentially to modify the board state, effectively playing a move. The entire implementation is surprisingly short, with the core logic embedded in a list of regex transformations, which are run in sequence to produce a valid move.
Why It Matters
This project illustrates the theoretical versatility of regular expressions, pushing the boundaries of their typical use cases. While it is not intended for practical chess playing, it opens discussions on the limits of pattern matching in computational logic and demonstrates an artistic or conceptual exploration of programming languages and computational models. It also challenges assumptions about the complexity needed to implement game engines.

Advanced Chess Programming: How Strong Chess Engines Work
As an affiliate, we earn on qualifying purchases.
As an affiliate, we earn on qualifying purchases.
Background
Traditional chess engines rely on algorithms like minimax, alpha-beta pruning, and heuristic evaluation functions to decide moves efficiently. This project, by contrast, encodes move logic in a static sequence of regex patterns, effectively creating a ‘regex computer.’ The developer previously engaged in building unconventional computational devices, such as a game of life computer and a printf computer, emphasizing experimental programming approaches. The project was shared publicly over the holidays, sparking interest in the programming community.
“This is MY WEBSITE and I MAKE THE RULES HERE and so today you’re learning about RegexChess whether you like it or not.”
— the developer
“Expressions is possible, and also what the specific regular expressions do.”
— the developer

Mastering Regular Expressions
Used Book in Good Condition
As an affiliate, we earn on qualifying purchases.
As an affiliate, we earn on qualifying purchases.
What Remains Unclear
It remains unclear how effective or accurate the regex-based engine is in actual gameplay, as no detailed evaluation or comparison with standard engines has been provided. The practical limits of this approach, such as speed and scalability, are not addressed and are presumed to be poor.

Chess
12 levels of difficulty and a 2-player option
As an affiliate, we earn on qualifying purchases.
As an affiliate, we earn on qualifying purchases.
What’s Next
The developer may continue refining the project or explore similar computational models. Further analysis by the community could evaluate the engine’s performance, accuracy, and potential for educational or artistic purposes. No official plans for deployment or broader use have been announced.
coding chess algorithms
As an affiliate, we earn on qualifying purchases.
As an affiliate, we earn on qualifying purchases.
Key Questions
Can this regex chess engine actually play a game?
It appears to be capable of making moves based on the sequence of regex transformations, but its effectiveness and correctness in gameplay are not formally tested or verified.
Is this approach practical for real chess engines?
No, this method is primarily an artistic or experimental demonstration. It is highly inefficient and not suitable for competitive or real-time play.
Why use regex for a chess engine?
The project aims to explore the boundaries of what can be achieved with pattern matching and to challenge assumptions about programming language limitations.
How many regex patterns does it use?
The engine uses a total of 84,688 regular expressions to interpret and execute moves.
Source: Hacker News