TL;DR

A programmer has built a chess engine that plays using a sequence of 84,688 regular expressions. This demonstrates a creative, if impractical, method of implementing game logic with regex. The development raises questions about the boundaries of regex and computational creativity.

A developer has constructed a chess engine that operates entirely through a sequence of 84,688 regular expressions, effectively playing a 2-ply minimax game. This project, shared via a blog post and GitHub, demonstrates an unconventional use of regex for game logic, highlighting both technical curiosity and computational creativity.

The developer created a list of 84,688 regular expressions that, when executed sequentially, interpret and modify a chess board state represented as a string. The approach involves designing a custom instruction set encoded within regex patterns, effectively turning regex into a simple CPU capable of running a minimax algorithm for move selection. The implementation is intentionally minimalistic and experimental, not optimized for performance or practical use.

The project was shared publicly on GitHub, with the developer emphasizing that the primary goal was to explore the theoretical boundaries of regex as a computational tool, rather than creating a competitive chess engine. The code interprets a chessboard string and applies regex transformations to simulate move generation and evaluation, culminating in a move decision based on a 2-ply minimax search.

Why It Matters

This project pushes the boundaries of what is considered feasible with regular expressions, a tool typically used for pattern matching rather than computation. You can see a chess puzzle I found in my dad’s old book as an example of strategic thinking. It highlights how regex can be repurposed for Turing-complete tasks in highly contrived scenarios, sparking discussions about the limits of pattern-based programming and creative problem-solving. While impractical for real chess engines, it serves as a proof of concept and a thought experiment about computational universality.

MASTERING REGEX WITH PYTHON: Search, Match, and Manipulate Text

MASTERING REGEX WITH PYTHON: Search, Match, and Manipulate Text

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Background

Traditional chess engines rely on complex algorithms, heuristics, and optimized data structures to evaluate positions and generate moves. This project diverges radically by encoding game logic within regex patterns, a method inspired by the idea of a regex-based computer. The concept was shared over the holidays, building on previous experiments with unconventional computation, such as cellular automata and custom CPUs built from simple instruction sets. You might find this chess puzzle I found in my dad’s old book interesting for understanding complex game logic.

The developer described the process as a playful exploration rather than a serious attempt at chess AI, emphasizing the novelty of using regex as a programming paradigm. For more on chess strategies, see this chess puzzle I found in my dad’s old book. Prior to this, regex has been shown to be Turing-complete in theory, but practical applications are rare and usually limited to pattern matching tasks. For a deep dive into complex problem-solving, see this chess puzzle I found in my dad’s old book.

“This sequence of regular expressions demonstrates that you can, in fact, use regex as a computational engine for something as complex as chess.”

— Developer

“The goal was to see if regex could interpret and execute a simple minimax algorithm, and the answer is yes — with a lot of regexes.”

— GitHub post

Advanced Chess Programming: How Strong Chess Engines Work

Advanced Chess Programming: How Strong Chess Engines Work

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

What Remains Unclear

It is not yet clear how well this regex-based engine performs in terms of move quality or speed. The project is primarily a proof of concept rather than a practical chess engine, and its scalability or adaptability to more complex scenarios remains untested.

Regex Pocket Guide: Quick Reference to Regular Expressions for Developers & Tech Professionals

Regex Pocket Guide: Quick Reference to Regular Expressions for Developers & Tech Professionals

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

What’s Next

Further exploration may involve optimizing the regex sequence, testing the engine against other chess programs, or extending the approach to deeper search depths. The developer may also publish more detailed technical insights or experiment with other games and computational tasks using regex as a core tool.

Fritz 20 Chess Software – Exclusive Expanded Edition: Train Smarter. Play Stronger. Dominate Faster. PC Download Plus ChessCentral's Exclusive Chess Success II

Fritz 20 Chess Software – Exclusive Expanded Edition: Train Smarter. Play Stronger. Dominate Faster. PC Download Plus ChessCentral's Exclusive Chess Success II

Included in the Fritz 20 Expended Edition: * Fritz 20 Chess Playing Softwar * Chess Success II

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Key Questions

Is this regex chess engine practical for playing real games?

No, this project is primarily a proof of concept demonstrating how regex can be used for computation, not a practical chess engine.

How does the engine evaluate moves?

It uses a sequence of regex transformations to simulate a 2-ply minimax algorithm, interpreting a string representation of the chessboard and applying move logic encoded as regex patterns.

Can this method be scaled to deeper search depths?

Currently, it is highly impractical due to the enormous number of regex patterns required; scaling would require significant re-engineering and likely surpass reasonable computational limits.

Why use regex for such a task?

The developer aimed to explore the theoretical limits of regex as a universal computational tool, rather than seeking efficiency or practicality.

Source: Hacker News

You May Also Like

Gyroflow: Video stabilization using gyroscope data

Gyroflow introduces a new application that stabilizes videos by utilizing gyroscope data from cameras and external sources, enhancing footage quality.

Instructure pays ransom to Canvas hackers

Instructure has paid a ransom to ShinyHunters after their Canvas LMS was hacked twice, with data of 275 million users compromised; full details are emerging.

Dust Collection for CNC: Your Lungs Will Thank You

A well-designed dust collection system for CNC machines protects your lungs and workspace—discover essential tips to ensure safety and cleanliness.

Forza Horizon 6 boots up in just 4 seconds instead of 90 with new Advanced Shader Delivery tech and AMD GPUs — Microsoft claims 95% reduction in gaming load times

Microsoft’s Advanced Shader Delivery reduces Forza Horizon 6 load time from 90 seconds to 4 seconds on supported GPUs, marking a major performance breakthrough.