Live data from Hacker News

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

nicholas.carlini.com

31–40 of 56 posts

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

#31

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…

Hey! I had a very similar game

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

#33
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.

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

#34

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…

I was also thinking along the same lines. Interesting, but I'm not sure in which aspect it is an achievement, considering the loop isn't a regex.

Meanwhile, 1K ZX Chess takes fewer bytes of memory than the first four paragraphs from the post.

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

#35

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.”

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

#36

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.”

Out of curiosity, why wouldn't it work?

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

#37
post #19

Earlier quoted context omitted.

Depends on what you mean by that. You can convert every NFA into a DFA. That's a NP complete (IIRC), but running the DFA is O(n). Running the NFA without converting it is also NP complete. One isn't better than the other, but the costs vary for different expressions and usages.

Running NFA is O(nm) not NP.

So it is NP (in fact P)

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

#38
post #10

Earlier quoted context omitted.

It’s turing complete so you could compile almost any language to regex. You might have to build a vm for some languages, also in regex. The point is, it’s regex all the way down.

Regular expressions are not Turing-complete.

Javascript/PCRE/etc regexes have additional features (like backreferences) that give them strictly more computational power than a regular DFA/NFA. (Still not Turing complete though without external control flow to support arbitrary iteration/recursion, like is done here)

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

#39

Earlier quoted context omitted.

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.”

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..."

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

#40

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.

Yeesh, one illegal move attempt means you just lose? That's harsh...
Post reply on HN