Chess engine in braifuck

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Michael Sherwin
Posts: 3196
Joined: Fri May 26, 2006 3:00 am
Location: WY, USA
Full name: Michael Sherwin

Re: Chess engine in braifuck

Post by Michael Sherwin »

flok wrote: Tue May 21, 2019 11:18 amany news?
Yes! Brainfuck is quickly becoming the language of choice for programming neural networks.
If you are on a sidewalk and the covid goes beep beep
Just step aside or you might have a bit of heat
Covid covid runs through the town all day
Can the people ever change their ways
Sherwin the covid's after you
Sherwin if it catches you you're through
dmc75287
Posts: 5
Joined: Wed Mar 06, 2019 8:14 pm
Full name: David Conant

Re: Chess engine in brainfuck - update

Post by dmc75287 »

I am one of the original participants in this crazy project. As far as I can tell, the original project has been discontinued. That's ok, it was an unlikely undertaking in the first place, but I don't give up so easily. I no longer have access to the original files, discussions, chess engine examples. I have designed a very simple game for me to practice game engine design. The I will convert it to bf, and start to work on a very simple chess engine. It could take many years, but I'll continue to plodding along.
Michael Sherwin
Posts: 3196
Joined: Fri May 26, 2006 3:00 am
Location: WY, USA
Full name: Michael Sherwin

Re: Chess engine in braifuck

Post by Michael Sherwin »

This project may yet live!

In part one the author creates a simple BF interpreter that runs the Mandelbrot Generator BF code in 38.6 seconds. Although the MG code is pure BF the interpreter undergoes several optimization upgrades that results in times of 18.4, 11.9 and finally 3.9 seconds.

https://eli.thegreenplace.net/2017/adve ... terpreter/

In part two the author starts with an unoptimised x64 JIT version of the interpreter (making it into a compiler) that executes the MG in 2.89 seconds. After optimization the time is reduced to 0.93 seconds.

https://eli.thegreenplace.net/2017/adve ... n-x64-jit/

In part three LLVM is used, 0.92 seconds, however that is deceptive because LLVM does the JIT compiling at run time after analysis or whatever a step that using asmjit does not have to do. On say a chess engine the gains using LLVM would be substantial.

https://eli.thegreenplace.net/2017/adve ... rt-3-llvm/

In part four Python is used with an embedded assembler called PeachPy. However the author gives no time. He also mentions LLVMlite which is a Python wrapper.

https://eli.thegreenplace.net/2017/adve ... in-python/

So it would seem that a BF compiler could be written, quite easily, that can run BF code at least 80x faster than a simple interpreter could. That still does not alleviate the tedious writing of millions of BF characters to accomplish a worthwhile chess engine. An earlier suggestion to have a higher level language produce BF code might be the answer. But that would beg the question, why keep BF in the chain at all if the programmer never directly works with BF code. Maybe curiosity about how fast the BF compiled code would run compared to C/C++ could be one reason. Besides curiosity a real world reason could be for use on a massively parallel BF optimized cpu with a gazillion very tiny BF cores.
If you are on a sidewalk and the covid goes beep beep
Just step aside or you might have a bit of heat
Covid covid runs through the town all day
Can the people ever change their ways
Sherwin the covid's after you
Sherwin if it catches you you're through
dmc75287
Posts: 5
Joined: Wed Mar 06, 2019 8:14 pm
Full name: David Conant

Re: Chess engine in braifuck

Post by dmc75287 »

Michael Sherwin wrote: Sat Feb 29, 2020 8:13 pm This project may yet live!
...
I continue to work on this project. I will examine all of those links, but when I eventually start on the bf version, I will code it by hand in brainfuck. I don't plan to do any optimization or converting a high level language to bf.
User avatar
flok
Posts: 481
Joined: Tue Jul 03, 2018 10:19 am
Full name: Folkert van Heusden

Re: Chess engine in braifuck

Post by flok »

dmc75287 wrote: Tue Mar 10, 2020 6:24 pm
Michael Sherwin wrote: Sat Feb 29, 2020 8:13 pm This project may yet live!
...
I continue to work on this project. I will examine all of those links, but when I eventually start on the bf version, I will code it by hand in brainfuck. I don't plan to do any optimization or converting a high level language to bf.
What is the status?

I wrote a few compilers for brainfuck and I'd love to see the result of that with a chess-program! (https://vanheusden.com/compilers/brainfuck/)
dmc75287
Posts: 5
Joined: Wed Mar 06, 2019 8:14 pm
Full name: David Conant

Re: Chess engine in braifuck

Post by dmc75287 »

flok wrote: Fri Jul 29, 2022 8:47 am
dmc75287 wrote: Tue Mar 10, 2020 6:24 pm
Michael Sherwin wrote: Sat Feb 29, 2020 8:13 pm This project may yet live!
...
I continue to work on this project. I will examine all of those links, but when I eventually start on the bf version, I will code it by hand in brainfuck. I don't plan to do any optimization or converting a high level language to bf.
What is the status?

I wrote a few compilers for brainfuck and I'd love to see the result of that with a chess-program! (https://vanheusden.com/compilers/brainfuck/)
Short answer, very little. I'm not working on it full time, my first task is to write some non trivial chess engine in Python just to get a basic understanding of how chess engines work.

I think I will post a link to the brainfuck sub-Reddit. There are some very good bf programmers there. Maybe they will take the bait.