Live data from Hacker News

A minimax chess engine in regular expressions

nicholas.carlini.com

41–50 of 103 posts

Re: A minimax chess engine in regular expressions

#42

This point was where this changed from crazy/fun to absolutely extraordinary, where calculations of multiple possible positions all occurred in parallel, running a regex over an increasing series of state & variable sets, aka threads: > And now for my absolute favorite part of the language we've developed. By the magic of regular expressions (and the fact that they perform substitution globally over the entire string…

This makes me wonder whether I could achieve such a thing if I removed all my preoccupations of other stuff.

For me what I take out of it is the power to sit down, focus your mind on something then who knows the lengths of what is possible. That, and the author is clearly very talented/skilled and creative.

Re: A minimax chess engine in regular expressions

#43
Kudoa for this, but it feels like there should be a more direct way? I mean, he first invented basically a general-purpose execution platform. That in itself is cool, but the fact that it then can execute a chess program is not actually that surprising.

What about directly encoding the rules of the game plus some basic strategy?

Re: A minimax chess engine in regular expressions

#45
post #26

Earlier quoted context omitted.

Humans can't see the balance at a glance, but we can still easily check the balance of arbitrarily complex nested parenthesis because we are not limited in the same way an FSM is. We're just way way way slower than a computer.

Yeah, I agree that humans can indeed check some non-regular languages. That doesn't however mean that humans are inherently capable for checking all non-regular languages, as they are severely limited in the working memory size. Most if not all divisibility rules are a set of least significant digits or weighted running sums because they are subject to the same constraint, so they are indeed necessarily regular.

I'll happily admit that there is (to me) no reason to believe that humans can do things that a Turing machine could not, or that we are magically exempt from stuff like the halting theorem or have special insights in NP-complete problems. I am only arguing that we are unarguably more powerful than FSMs, and with some pen and paper (or perhaps an endless string of tape...) we are not as limited by our working memory size. But we are very slow.

Re: A minimax chess engine in regular expressions

#46

Earlier quoted context omitted.

> demonstrated that printf() is Turing complete and wrote a first person shooter in ... Not gonna lie, I thought that sentence would end with the FPS being done in printf.

This guy wrote tic-tac-toe in a single call to printf for IOCCC 2020 competition: https://github.com/carlini/printf-tac-toe

It’s very fun and impressive but it’s absolutely not a single call.

Re: A minimax chess engine in regular expressions

#47
This is truly impressive, I'm in complete awe.

I do think there are some bugs based on playing a game against it. It has a tendency to give up its queen and other pieces. and it blundered mate in 1 at the end of the game when it had moves that led to mate in 2 or 3.

Usually even a 2-ply engine should avoid these mistakes unless the evaluation function is completely silly, which may be the case here, I don't know. I tried looking at the code but it didn't make much sense to me, I'm not smart enough to understand this regex "runtime" based code. Could also be a bug of using somewhere, or vice versa, making it choose the worst move instead of the best one.

Re: A minimax chess engine in regular expressions

#49

This point was where this changed from crazy/fun to absolutely extraordinary, where calculations of multiple possible positions all occurred in parallel, running a regex over an increasing series of state & variable sets, aka threads: > And now for my absolute favorite part of the language we've developed. By the magic of regular expressions (and the fact that they perform substitution globally over the entire string…

This makes me wonder whether I could achieve such a thing if I removed all my preoccupations of other stuff. For me what I take out of it is the power to sit down, focus your mind on something then who knows the lengths of what is possible. That, and the author is clearly very talented/skilled and creative.

Apparently it takes more than skill but also persistence and concentration. Not many schools of thought explain this well .

Re: A minimax chess engine in regular expressions

#50
post #46

Earlier quoted context omitted.

This guy wrote tic-tac-toe in a single call to printf for IOCCC 2020 competition: https://github.com/carlini/printf-tac-toe

It’s very fun and impressive but it’s absolutely not a single call.

Maybe a generous interpretation of the comment and a realisation that common language isn't always 100% precise would be better than pointless arguments about semantics.

There is only a single printf written in the source code.

Post reply on HN