How to write 2200+ elo chess engine within 500 to 1000 lines of code with pure evaluation(No NNUE or EGTB)?

Discussion of chess software programming and technical issues.

Moderator: Ras

shahil4242
Posts: 30
Joined: Thu Sep 28, 2017 5:20 pm

Re: How to write 2200+ elo chess engine within 500 to 1000 lines of code with pure evaluation(No NNUE or EGTB)?

Post by shahil4242 »

abulmo2 wrote: Wed Nov 17, 2021 2:01 pm You may have a look at dumb, it is about 1200 lines of code and 2677 Elo at CCRL 40/4.
You can also give a look at OliThink which is very strong (2867 Elo for version 5.9.7 on CCRL 40/4) with a very compact source code (1033 lines of code for version 5.10.1).
Thank you.The souce code is easy to understand.
User avatar
hgm
Posts: 28353
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: How to write 2200+ elo chess engine within 500 to 1000 lines of code with pure evaluation(No NNUE or EGTB)?

Post by hgm »

Rotated bitboard was what people used before magic bitboard was invented.
shahil4242
Posts: 30
Joined: Thu Sep 28, 2017 5:20 pm

Re: How to write 2200+ elo chess engine within 500 to 1000 lines of code with pure evaluation(No NNUE or EGTB)?

Post by shahil4242 »

hgm wrote: Sat Nov 20, 2021 9:51 am Rotated bitboard was what people used before magic bitboard was invented.
Now i got it.Just curious to know what are the disadvantages of rotated bitboard?
User avatar
hgm
Posts: 28353
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: How to write 2200+ elo chess engine within 500 to 1000 lines of code with pure evaluation(No NNUE or EGTB)?

Post by hgm »

Slower, I suppose. For one, you have to update 4 'occupied' boards in stead of 1, one for each orientation, during MakeMove/UnMake. Secondly, in magic bitboards you look up moves in 4 directions at once. The rotated bitboards are still of the variety where you have to generate the moves along each orientation separately, and OR them together. Advantage is that the involved tables are far smaller.
shahil4242
Posts: 30
Joined: Thu Sep 28, 2017 5:20 pm

Re: How to write 2200+ elo chess engine within 500 to 1000 lines of code with pure evaluation(No NNUE or EGTB)?

Post by shahil4242 »

hgm wrote: Sat Nov 20, 2021 1:47 pm Slower, I suppose. For one, you have to update 4 'occupied' boards in stead of 1, one for each orientation, during MakeMove/UnMake. Secondly, in magic bitboards you look up moves in 4 directions at once. The rotated bitboards are still of the variety where you have to generate the moves along each orientation separately, and OR them together. Advantage is that the involved tables are far smaller.
Thank you very much.
dangi12012
Posts: 1062
Joined: Tue Apr 28, 2020 10:03 pm
Full name: Daniel Infuehr

Re: How to write 2200+ elo chess engine within 500 to 1000 lines of code with pure evaluation(No NNUE or EGTB)?

Post by dangi12012 »

shahil4242 wrote: Sat Nov 20, 2021 1:41 pm
hgm wrote: Sat Nov 20, 2021 9:51 am Rotated bitboard was what people used before magic bitboard was invented.
Now i got it.Just curious to know what are the disadvantages of rotated bitboard?
You want to have the operations you need to do "each and every move" absolutely minimal.
With rotated boards you have to maintain 4x the boards and there is no single x64 instruction to "rotate a 8x8 board inside this register"

BUT: You get the fastest sliding lookup possible because there are 2 or 3 bit algorithms that work extremely well - but only in lsb-msb direction.
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer
shahil4242
Posts: 30
Joined: Thu Sep 28, 2017 5:20 pm

Re: How to write 2200+ elo chess engine within 500 to 1000 lines of code with pure evaluation(No NNUE or EGTB)?

Post by shahil4242 »

dangi12012 wrote: Sat Nov 20, 2021 3:24 pm
shahil4242 wrote: Sat Nov 20, 2021 1:41 pm
hgm wrote: Sat Nov 20, 2021 9:51 am Rotated bitboard was what people used before magic bitboard was invented.
Now i got it.Just curious to know what are the disadvantages of rotated bitboard?
You want to have the operations you need to do "each and every move" absolutely minimal.
With rotated boards you have to maintain 4x the boards and there is no single x64 instruction to "rotate a 8x8 board inside this register"

BUT: You get the fastest sliding lookup possible because there are 2 or 3 bit algorithms that work extremely well - but only in lsb-msb direction.
Is there fastest way other than magic bitboard to generate moves for sliding pieces?
dangi12012
Posts: 1062
Joined: Tue Apr 28, 2020 10:03 pm
Full name: Daniel Infuehr

Re: How to write 2200+ elo chess engine within 500 to 1000 lines of code with pure evaluation(No NNUE or EGTB)?

Post by dangi12012 »

shahil4242 wrote: Sat Nov 20, 2021 3:31 pm
dangi12012 wrote: Sat Nov 20, 2021 3:24 pm
shahil4242 wrote: Sat Nov 20, 2021 1:41 pm
hgm wrote: Sat Nov 20, 2021 9:51 am Rotated bitboard was what people used before magic bitboard was invented.
Now i got it.Just curious to know what are the disadvantages of rotated bitboard?
You want to have the operations you need to do "each and every move" absolutely minimal.
With rotated boards you have to maintain 4x the boards and there is no single x64 instruction to "rotate a 8x8 board inside this register"

BUT: You get the fastest sliding lookup possible because there are 2 or 3 bit algorithms that work extremely well - but only in lsb-msb direction.
Is there fastest way other than magic bitboard to generate moves for sliding pieces?
Sure they are. L2 array lookups are not free you know.
Some under "By Calculation"
https://www.chessprogramming.org/Sliding_Piece_Attacks
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer
shahil4242
Posts: 30
Joined: Thu Sep 28, 2017 5:20 pm

Re: How to write 2200+ elo chess engine within 500 to 1000 lines of code with pure evaluation(No NNUE or EGTB)?

Post by shahil4242 »

dangi12012 wrote: Sat Nov 20, 2021 3:47 pm
shahil4242 wrote: Sat Nov 20, 2021 3:31 pm
dangi12012 wrote: Sat Nov 20, 2021 3:24 pm
shahil4242 wrote: Sat Nov 20, 2021 1:41 pm
hgm wrote: Sat Nov 20, 2021 9:51 am Rotated bitboard was what people used before magic bitboard was invented.
Now i got it.Just curious to know what are the disadvantages of rotated bitboard?
You want to have the operations you need to do "each and every move" absolutely minimal.
With rotated boards you have to maintain 4x the boards and there is no single x64 instruction to "rotate a 8x8 board inside this register"

BUT: You get the fastest sliding lookup possible because there are 2 or 3 bit algorithms that work extremely well - but only in lsb-msb direction.
Is there fastest way other than magic bitboard to generate moves for sliding pieces?
Sure they are. L2 array lookups are not free you know.
Some under "By Calculation"
https://www.chessprogramming.org/Sliding_Piece_Attacks
I had tried the classical approach before it works
nicely.

In my experimental chess engine of bitboard i had used in between squares for movegen but it is much slower than mailbox approach which uses piece list.It is 80 times slower.
OliverBr
Posts: 797
Joined: Tue Dec 18, 2007 9:38 pm
Location: Munich, Germany
Full name: Dr. Oliver Brausch

Re: How to write 2200+ elo chess engine within 500 to 1000 lines of code with pure evaluation(No NNUE or EGTB)?

Post by OliverBr »

shahil4242 wrote: Sat Nov 20, 2021 5:10 am
OliverBr wrote: Thu Nov 18, 2021 11:40 pm
abulmo2 wrote: Wed Nov 17, 2021 2:01 pm You may have a look at dumb, it is about 1200 lines of code and 2677 Elo at CCRL 40/4.
You can also give a look at OliThink which is very strong (2867 Elo for version 5.9.7 on CCRL 40/4) with a very compact source code (1033 lines of code for version 5.10.1).
Actually dumb is really intriguing. It's very compact and well written.
I think one of the version of OliThink had uses rotated bitboard.What is the result of perft? Does it is faster than magic bitboard?is it is woth learning about rotated bitboard.
Yes. OliThink4 (https://github.com/olithink/olithink4)
had rotated bitboards. And it had good results and caught the attention of many chess pioneers. One of them them is a Stockfish developer.

The Kindergarten bitboards of OliThink5 (https://github.com/olithink/OliThink)
was another independent development of my own without looking into other sources. I got the name many years after its creation.

The perft of OliThink5 (https://github.com/olithink/OliThink/tree/oliperft)
is better than OliThink4.
But this is still no decisive argument which to use, because the move generation is supposed to be compatable with the rest of the programm.
Chess Engine OliThink: http://brausch.org/home/chess
OliThink GitHub:https://github.com/olithink