Now you are kidding?Henk wrote:Always wanted to develop a chess program maybe that's why I studied computer science.
The wrong way
Moderators: hgm, Rebel, chrisw
-
- Posts: 4052
- Joined: Thu May 15, 2008 9:57 pm
- Location: Berlin, Germany
- Full name: Sven Schüle
Re: The wrong way
-
- Posts: 7221
- Joined: Mon May 27, 2013 10:31 am
Re: The wrong way
Sven Schüle wrote:Now you are kidding?Henk wrote:Always wanted to develop a chess program maybe that's why I studied computer science.
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.
-
- Posts: 4052
- Joined: Thu May 15, 2008 9:57 pm
- Location: Berlin, Germany
- Full name: Sven Schüle
Re: The wrong way
Slightly an OT question here: did you already finish studying CS?Henk wrote:Sven Schüle wrote:Now you are kidding?Henk wrote:Always wanted to develop a chess program maybe that's why I studied computer science.
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.
-
- Posts: 7221
- Joined: Mon May 27, 2013 10:31 am
Re: The wrong way
Yes in 1988. But diploma is out of date. So has no value anymore. Microsoft says you have to study all your life.Sven Schüle wrote:Slightly an OT question here: did you already finish studying CS?Henk wrote:Sven Schüle wrote:Now you are kidding?Henk wrote:Always wanted to develop a chess program maybe that's why I studied computer science.
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.
-
- Posts: 7221
- Joined: Mon May 27, 2013 10:31 am
Re: The wrong way
Rewritten non captures for bishops. Looks like it is not faster. Still need to get the location and iterate over the bishops.
By the way which laws or rewrite rules hold for the exclusive or operator.
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
)
)
|
(locationDirMovesLD ^ (
(
occupiedDirMovesLD >> 9
| occupiedDirMovesLD >> 18
| occupiedDirMovesLD >> 27
| occupiedDirMovesLD >> 36
| occupiedDirMovesLD >> 45
| occupiedDirMovesLD >> 54
) & locationDirMovesLD
)
)
|
(locationDirMovesRU ^ (
(
occupiedDirMovesRU << 9
| occupiedDirMovesRU << 18
| occupiedDirMovesRU << 27
| occupiedDirMovesRU << 36
| occupiedDirMovesRU << 45
| occupiedDirMovesRU << 54
) & locationDirMovesRU
)
)
) & emptySquares;
var mvDictWB = colSign == ColorSign.White ? ((Field)location).WhiteBishopMovesDict: ((Field)location).BlackBishopMovesDict;
while (moveBitsB != 0)
{
var moveBit = moveBitsB & (~moveBitsB + 1);
moveBitsB &= moveBitsB - 1;
var move = mvDictWB[moveBit];
move.Value = (int)(HistoryTable[move]);
moves.Add(move);
}
}
Last edited by Henk on Thu Dec 31, 2015 10:57 am, edited 1 time in total.
Re: The wrong way
How do you test if things are faster?Henk wrote:Rewritten non captures for bishops. Looks like it is not 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?
-
- Posts: 7221
- Joined: Mon May 27, 2013 10:31 am
Re: The wrong way
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.
I also run test positions.
Last edited by Henk on Thu Dec 31, 2015 11:08 am, edited 1 time in total.
-
- Posts: 7221
- Joined: Mon May 27, 2013 10:31 am
Re: The wrong way
Same question for >> operator. (bitwise shift operator)
-
- Posts: 879
- Joined: Mon Dec 15, 2008 11:45 am
Re: The wrong way
Hello Henk.Sven Schüle wrote:Henk, unfortunately you haven't understood anything of what I wrote. For now I give up.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.
here is a proposal for a speed optimized Skipper version.
Code: Select all
int main() {
return RESIGN;
}
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.
So, wish you a happy new year.
Regards.
-
- Posts: 7221
- Joined: Mon May 27, 2013 10:31 am
Re: The wrong way
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.]
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.]