Live data from Hacker News

Regex Chess: A 2-ply minimax chess engine in 84,688 regular expressions

nicholas.carlini.com

41–50 of 56 posts

Re: Regex Chess: A 2-ply minimax chess engine in 84,688 regular expressions

#41

It would be different, if somehow all those 84688 regexes were coded by hand. Then it would be a piece of art. It would be different, if the number of regexes was maybe below 300, and it still plays acceptably. The sheer number of regexes kind of defeats the purpose. At that code size, a much better engine can be written, or other kind of code for an engine be generated. Regexes themselves are not really something we…

> Maybe its intentional badness kind of makes it art?

I guess it's the whole point of such type of blog posts. Similarly, some people write complicated interactive web pages without using JS, like this https://benjaminaster.com/css-minecraft/. But if you look at the HTML / CSS code size, it's usually huge, but still requires creativity to do that because of constraints. Obviously, it's not something practical or even optimal.

Re: Regex Chess: A 2-ply minimax chess engine in 84,688 regular expressions

#42

Not sure it's completely accurate. I played a standard queen's gambit accepted, took black's queen which it immediately blundered, then tried to move my queen from c5 -> e5 and the game ended immediately showing: *Illegal Move* You Lose. Game over. A little disappointed, since it's of course a valid move.

“then tried to move my queen from c5 -> e5”

Are you sure you typed “c5e5”?

It’s very picky about how you specify a move. “e2e4” is fine as a first move, for example, but auto-capitalized “E2e4” is losing immediately. Quite weird, given that there are guardrails against “e2-e4” and “E2-E4” (an alert pops up telling you how to write moves)

Re: Regex Chess: A 2-ply minimax chess engine in 84,688 regular expressions

#43
post #41

It would be different, if somehow all those 84688 regexes were coded by hand. Then it would be a piece of art. It would be different, if the number of regexes was maybe below 300, and it still plays acceptably. The sheer number of regexes kind of defeats the purpose. At that code size, a much better engine can be written, or other kind of code for an engine be generated. Regexes themselves are not really something we…

> Maybe its intentional badness kind of makes it art? I guess it's the whole point of such type of blog posts. Similarly, some people write complicated interactive web pages without using JS, like this https://benjaminaster.com/css-minecraft/ . But if you look at the HTML / CSS code size, it's usually huge, but still requires creativity to do that because of constraints. Obviously, it's not something practical or eve…

> Similarly, some people write complicated interactive web pages without using JS (…) Obviously, it's not something practical or even optimal.

There are people who navigate the web with JavaScript turned off, so those experiments do have practical applications.

There are entire projects around not using JavaScript.

https://theosoti.com/you-dont-need-js/

https://github.com/you-dont-need/You-Dont-Need-JavaScript

Re: Regex Chess: A 2-ply minimax chess engine in 84,688 regular expressions

#44
post #43
post #41

Earlier quoted context omitted.

> Maybe its intentional badness kind of makes it art? I guess it's the whole point of such type of blog posts. Similarly, some people write complicated interactive web pages without using JS, like this https://benjaminaster.com/css-minecraft/ . But if you look at the HTML / CSS code size, it's usually huge, but still requires creativity to do that because of constraints. Obviously, it's not something practical or eve…

> Similarly, some people write complicated interactive web pages without using JS (…) Obviously, it's not something practical or even optimal. There are people who navigate the web with JavaScript turned off, so those experiments do have practical applications. There are entire projects around not using JavaScript. https://theosoti.com/you-dont-need-js/ https://github.com/you-dont-need/You-Dont-Need-JavaScript

> There are people who navigate the web with JavaScript turned off, so those experiments do have practical applications.

This is practical (and necessary) for relatively basic stuff, such as text content, navigation, basic form / input validation, and things like that. But when people write more complicated things (requiring state management, logical branches, etc), like games, 3d programs, etc, it's much more challenging (also can be sub-optimal) and requires more creativity. I mean they are more of a demo art rather than some strong necessity.

Re: Regex Chess: A 2-ply minimax chess engine in 84,688 regular expressions

#45

For people who are interested, here is the solution. In standard PGN, the solution is: 1. e4 e5 2. Nf3 Nf6 3. Nxe5 Nxe4 4. Qe2 Nxd2 5. Nc6+ Ne4 6. Nxd8 Kxd8 7. Qxe4 a6 8. Bg5+ Be7 9. Qxe7# In the Stockfish notation this engine uses, White’s moves are: 1. e2e4 2. g1f3 3. f3e5 4. d1e2 5. e5c6 6. c6d8 7. e2e4 8. c1g5 9. e4e7 Here is a Lichess analysis of this game: https://lichess.org/WnMF3LpX (In terms of Regexes, Java…

I won faster than that:

1.d4 d5 2.c4 dxc4 3.Nc3 Qxd4 4.Qxd4 a6 5.Bf4 a5 6.Bxc7 a4 7.Qd8#

Re: Regex Chess: A 2-ply minimax chess engine in 84,688 regular expressions

#46

The technical write up is worth perusing but I played a game before reading and accidentally found a winning strategy immediately. I'm not sure if this is a result of the 2-ply nature of the engine or if the mentioned deficiencies account for this but the computer did not act to prevent checkmate in 1 (without any intervening check); the game I played was (in algebraic notation): 1. e4 e5 2. kf3 kf6 3. kxe5 kxe4 4. d…

Yep, the scoring function is just piece value difference, so it can only detect checkmate in 0 (i.e., when king capture is available).

Re: Regex Chess: A 2-ply minimax chess engine in 84,688 regular expressions

#47

Earlier quoted context omitted.

Out of curiosity, why wouldn't it work?

Oh, I didn't mean that this specific project wouldn't work. I just wish HN were a little friendlier towards projects that are primarily thought experiments. Some of the best things I've ever created started from, "I wonder what would happen if I tried this crazy approach..."

I think it’s because of agent involvement. It takes away the coolness.

Re: Regex Chess: A 2-ply minimax chess engine in 84,688 regular expressions

#49

It would be different, if somehow all those 84688 regexes were coded by hand. Then it would be a piece of art. It would be different, if the number of regexes was maybe below 300, and it still plays acceptably. The sheer number of regexes kind of defeats the purpose. At that code size, a much better engine can be written, or other kind of code for an engine be generated. Regexes themselves are not really something we…

This is a quintessential, crazy idea that used to be adored on HN. The author, obviously, didn't intend this to be a serious engine. I wish more submissions began with, “This might be a bit wild, but I wanted to see if it could actually work.”

> “This might be a bit wild, but I wanted to see if it could actually work.”

That is how esoteric programming languages start.

Re: Regex Chess: A 2-ply minimax chess engine in 84,688 regular expressions

#50

It would be different, if somehow all those 84688 regexes were coded by hand. Then it would be a piece of art. It would be different, if the number of regexes was maybe below 300, and it still plays acceptably. The sheer number of regexes kind of defeats the purpose. At that code size, a much better engine can be written, or other kind of code for an engine be generated. Regexes themselves are not really something we…

What a depressing way to view the world. Sorry this great project wasn't to your taste, but there's no reason to be a dick about it.
Post reply on HN