The wrong way

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: The wrong way

Post by Sven »

Henk wrote:Always wanted to develop a chess program maybe that's why I studied computer science.
Now you are kidding?
Henk
Posts: 7221
Joined: Mon May 27, 2013 10:31 am

Re: The wrong way

Post by Henk »

Sven Schüle wrote:
Henk wrote:Always wanted to develop a chess program maybe that's why I studied computer science.
Now you are kidding?

No but maybe otherwise I would also have studied computer science for actually I was only interested in mathematics, puzzles and chess of course. I don't know. Perhaps I was only interested in chess, chess and chess.
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: The wrong way

Post by Sven »

Henk wrote:
Sven Schüle wrote:
Henk wrote:Always wanted to develop a chess program maybe that's why I studied computer science.
Now you are kidding?

No but maybe otherwise I would also have studied computer science for actually I was only interested in mathematics, puzzles and chess of course. I don't know. Perhaps I was only interested in chess, chess and chess.
Slightly an OT question here: did you already finish studying CS?
Henk
Posts: 7221
Joined: Mon May 27, 2013 10:31 am

Re: The wrong way

Post by Henk »

Sven Schüle wrote:
Henk wrote:
Sven Schüle wrote:
Henk wrote:Always wanted to develop a chess program maybe that's why I studied computer science.
Now you are kidding?

No but maybe otherwise I would also have studied computer science for actually I was only interested in mathematics, puzzles and chess of course. I don't know. Perhaps I was only interested in chess, chess and chess.
Slightly an OT question here: did you already finish studying CS?
Yes in 1988. But diploma is out of date. So has no value anymore. Microsoft says you have to study all your life.
Henk
Posts: 7221
Joined: Mon May 27, 2013 10:31 am

Re: The wrong way

Post by Henk »

Rewritten non captures for bishops. Looks like it is not faster. Still need to get the location and iterate over the bishops.

Code: Select all

 
          ....
            ulong curBishops = curPieces & Board.Bishops;
            curPieces &= ~curBishops;
            while (curBishops != 0)
            {
                var bit = curBishops & (~curBishops + 1);
                curBishops &= curBishops - 1;

                var location = ChessBoard[bit];

                var locationDirMovesRD = location.RightDownMoves;
                var occupiedDirMovesRD = occupiers & locationDirMovesRD;
                var locationDirMovesLU = location.LeftUpMoves;
                var occupiedDirMovesLU = occupiers & locationDirMovesLU;
                var locationDirMovesLD = location.LeftDownMoves;
                var occupiedDirMovesLD = occupiers & locationDirMovesLD;
                var locationDirMovesRU = location.RightUpMoves;
                var occupiedDirMovesRU = occupiers & locationDirMovesRU;


                ulong moveBitsB =
                    (
                     (locationDirMovesRD ^ (
                                        (
                                              occupiedDirMovesRD >> 7
                                            | occupiedDirMovesRD >> 14
                                            | occupiedDirMovesRD >> 21
                                            | occupiedDirMovesRD >> 28
                                            | occupiedDirMovesRD >> 35
                                            | occupiedDirMovesRD >> 42
                                        ) & locationDirMovesRD
                                      )
                   )
                 |
                     (locationDirMovesLU ^ (
                                           (
                                                 occupiedDirMovesLU << 7
                                               | occupiedDirMovesLU << 14
                                               | occupiedDirMovesLU << 21
                                               | occupiedDirMovesLU << 28
                                               | occupiedDirMovesLU << 35
                                               | occupiedDirMovesLU << 42
                                           ) & locationDirMovesLU
                                         )
                      )
                 |
                    &#40;locationDirMovesLD ^ (
                                             (
                                                   occupiedDirMovesLD >> 9
                                                 | occupiedDirMovesLD >> 18
                                                 | occupiedDirMovesLD >> 27
                                                 | occupiedDirMovesLD >> 36
                                                 | occupiedDirMovesLD >> 45
                                                 | occupiedDirMovesLD >> 54
                                             ) & locationDirMovesLD
                                           )
                        )
                |
                   &#40;locationDirMovesRU ^ (
                                          (
                                                occupiedDirMovesRU << 9
                                              | occupiedDirMovesRU << 18
                                              | occupiedDirMovesRU << 27
                                              | occupiedDirMovesRU << 36
                                              | occupiedDirMovesRU << 45
                                              | occupiedDirMovesRU << 54
                                          ) & locationDirMovesRU
                                        )
                     )
                ) & emptySquares;


                var mvDictWB = colSign == ColorSign.White ? (&#40;Field&#41;location&#41;.WhiteBishopMovesDict&#58; (&#40;Field&#41;location&#41;.BlackBishopMovesDict;
                while &#40;moveBitsB != 0&#41;
                &#123;
                    var moveBit = moveBitsB & (~moveBitsB + 1&#41;;
                    moveBitsB &= moveBitsB - 1;
                    var move = mvDictWB&#91;moveBit&#93;;
                    move.Value = &#40;int&#41;&#40;HistoryTable&#91;move&#93;);
                    moves.Add&#40;move&#41;;
                &#125;
            &#125;
By the way which laws or rewrite rules hold for the exclusive or operator.
Last edited by Henk on Thu Dec 31, 2015 10:57 am, edited 1 time in total.
flok

Re: The wrong way

Post by flok »

Henk wrote:Rewritten non captures for bishops. Looks like it is not faster.
How do you test if things are faster?
Especially with parallel searches there's no guarantee that the search-tree will be the same. So then e.g. comparing 1 game won't tell you anything at all.
Or are you invoking the specific method at itself?
Henk
Posts: 7221
Joined: Mon May 27, 2013 10:31 am

Re: The wrong way

Post by Henk »

Yes I can only tell if something is significantly faster or not. Usually I run some perfts and a few games. But this time if I look at the code I can't believe this can be much faster.

I also run test positions.
Last edited by Henk on Thu Dec 31, 2015 11:08 am, edited 1 time in total.
Henk
Posts: 7221
Joined: Mon May 27, 2013 10:31 am

Re: The wrong way

Post by Henk »

Same question for >> operator. (bitwise shift operator)
User avatar
Desperado
Posts: 879
Joined: Mon Dec 15, 2008 11:45 am

Re: The wrong way

Post by Desperado »

Sven Schüle wrote:
Henk wrote:I think looping (iterating) again over the bitboard moves is too slow. Also function calls are too slow on this level. By the way I found another simple optimization so I have to rewrite it anyhow. It is all about speed now. Every instruction counts.

I agree writing out loops makes no sense for compiler does that better.

Also iterating the bits per piece type is extra work and therefor too slow. I already tried something like that before.
Henk, unfortunately you haven't understood anything of what I wrote. For now I give up.
Hello Henk.

here is a proposal for a speed optimized Skipper version.

Code: Select all

int main&#40;) &#123;
    return RESIGN;
&#125;
Ok, to be more serious, just a very simple question for you.

What do you want to reach with all your speed optimizations ?

It is pointless ! Even if you double the speed or make it 4x to 8x faster than it is, it won't make a 2800 Elo engine out of it if you are at the level of 1800 Elo engine.
Just think of making 50-100 Elo gain, with a good branching factor and an engine which is very slow at some point.

So many professional or experienced programmes gave you a lot of useful advices, please do not ignore them, it is a waste of time for everyone.

Chess programming is a big puzzle today, a lot of techniques are known, so it is a lot easier to get a level between 2300 and 2800 Elo.
Anyway it is not easy to reach 2800 elo level, it is a level that only some years back was the top level for a handful of engines.

I don't want discourage you, but if you won't accept that it takes a lot of patience and you need to start with easy and robust techniques you will not be able to learn anything about chess programming.

All advices given to you, don't work for themselves, you need to learn to handle them all together. Then you make progress.

So, if you want to have a propper base for a stronger engine, your goal could be to write a poor iterative+alphaBeta+simpleQs+material+mobility and some basic move ordering like mvv/lva, based engine.
Without any tricks it easily will be within the range of (1900)2000 and 2200 Elo (or even stronger)

Hidden implentation will allow you to replace complete parts of your engine.

So, just start with something easy "you" can handle and you do understand very well. Don't care about Stockfishes, Houdinis, Fruits and so on...

All that was said a lot of times to you, by different people, for many years now. I don't want to say that you should not waste the time of people in this community, but I want to say,

don't waste your own time. :wink:

So, wish you a happy new year.

Regards.
Henk
Posts: 7221
Joined: Mon May 27, 2013 10:31 am

Re: The wrong way

Post by Henk »

ok thank you.

Well it can never be bad if your move generator is 10% faster. So all my perft tests will run 10% faster too and how often do I run perft tests.

[By the way I don't have much time on 31 december as well. For I have to bake 'oliebollen' (Dutch donuts) and that's a tradition in Holland. Last year I bought them but they were not very tasty. So I can't do worse.]