EGTB value

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Uri Blass
Posts: 10267
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: EGTB value

Post by Uri Blass »

Jouni wrote:The Rybka test was repeated with another time control:

EGTB pruned book, Blitz:0'+1" ELO +12

Rybka 3 EGTB +502/=1978/-404 51.70% 1491.0/2884
Rybka 3 noEGTB +404/=1978/-502 48.30% 1393.0/2884

I have 2 questions about topic:

1) Can't You put 5 piece TBs to RAM to get very fast access?
2) When You have TBs can't You remove all redundant code from engine to speed up search? You don't need any code about mating with rook, queen and so on.

Jouni
for question 2
piece square table that encourage centralizing the king(and encouraging reducing the distance between the kings when one side has more non pawn material in endgames) is enough to mate with queen or rook or even with KQ vs KR and
I believe that you need this code also for non tablebases endgame and reducing the distance between the kings can help also
in KRBP vs KRPP and generally in endgames when one side has more material(not in pawns) so it is probably a bad idea to remove this knowledge.

Uri
jwes
Posts: 778
Joined: Sat Jul 01, 2006 7:11 am

Re: EGTB value

Post by jwes »

bob wrote:
michiguel wrote:
bob wrote:
Uri Blass wrote:
bob wrote:
rbarreira wrote:I haven't looked at this in detail, but it looks very weird to me that we have databases of perfect moves and we can't make use of them to improve play.

I realize that if the tablebases are used during search that would slow down the search, but as someone else said earlier it should be good to at least use them in the root (i.e. if current game position is in the tablebase, play the move suggested there).
There are several issues involved.

(1) probing in the search slows things down. 10 years ago, this was not so noticable. Today, with an effective branching factor of way less than 2.0 in endgames, it can be a huge loss.
I do not understand why probing in the search has to slow things down(assuming that you do not probe in every node in the search but only when the remaining depth is big enough so the time of searching the remaining depth is bigger than the time of probing the tablebases).

I think that the first test before playing games should be if you get the same depth faster in endgame analysis.

If you get the same depth faster but still do not earn rating points based on games then it is interesting(and maybe the reason can be that you are slightly slower in opening and middle game positions when you do not probe tablebases because checking that you do not need to probe tablebases after a capture cost time).
Simple math. On my 8-core box, Crafty searches about 20M nodes per second up to 30M in the endgame. On a good disk, you can do a read every 5ms, or about 200 reads per second. Compare the speeds. During the time I can do a single read, I can search 150K nodes. That is huge. For every 200 I/O accesses, I could search another 30M nodes. The cost to check for probes is roughly zero since in the opening and middlegame, that branch gets predicted 100% correctly. But when you get down to the 12-16 pieces total, you begin to see EGTB probes. Each successful probe costs about 5ms if a disk access is required, actually quite a bit more since you read in fairly large compressed blocks, and then have to spend time uncompressing a block before the probe can be completed...

Either you rarely probe, which doesn't help much, or you probe a lot, which starts to cost multiple plies.
Your 5ms figure assumes no cache. But if you have a cache that makes you read from disk only 5% of the time, a fast decompressing scheme that is effectively faster than reading uncompressed data, you will end up with an average figure of 0.3 ms (and we are not even talking about SSD). That means, if you probe in a node in which it is required to search deep enough to cost only 10k nodes, the effect on speed will be negligible. That means you can search "relatively" close to the leaves with no time-to-depth cost (in fact it should lower because of the pruning performed at nodes closer to the root). What is the depth you can reach with 10 k nodes? that is "approximately" the distance to the leaves you can _safely_ afford.

Of course, these numbers may not apply to Nalimov, but they do apply to the Gaviota TBs.

Miguel
The cache is much less significant when you factor in the 6-piece files that many are using. Suddenly the cache becomes almost useless due to the 2gb file sizes, and many files have to be broken into many 2gb chunks to work on 32 bit systems.


My observations are exactly that, observations. Here is one example, using just one CPU to avoid any SMP issues. This is fine #70, not a particularly good EGTB position since it takes a while to reach a position with just 5 pieces left (I am only using 3/4/5 piece files for this test). Both find the correct move, Kb1, at depth 24, same amount of time. But as the search progresses...First, normal Crafty, no egtbs, then same depth using EGTBs:

Code: Select all

               37->   0.16   4.27   1. Kb1 Kb7 2. Kc1 Kc7 3. Kd1 Kd7 4.
                                    Kc2 Kc7 5. Kd3 Kb7 6. Ke3 Kc7 7. Kf3
                                    Kd7 8. Kg3 Ke7 9. Kh4 Kf7 10. Kg5 Kg7
                                    11. Kxf5 Kf7 12. Kg5 Kg7 13. f5 Kf7
                                    14. f6 Kf8 15. Kg4 Kg8 16. Kf4 Kf8
                                    17. Kg5 Ke8 18. Kg4 Kf8 19. Kf5

               37->   3.20   4.27   1. Kb1 Kb7 2. Kc1 Kc7 3. Kd1 Kd7 4.
                                    Kc2 Kc7 5. Kd3 Kb7 6. Ke3 Kc7 7. Kf3
                                    Kd7 8. Kg3 Ke7 9. Kh4 Kf7 10. Kg5 Kg7
                                    11. Kxf5 Kf7 12. Kg5 Kg7 13. f5 Kf7
                                    14. f6 Kf8 15. Kg4 Kg8 16. Kf4 Kf8
                                    17. Kg5 Ke8 18. Kg4 Kf8 19. Kf5
20x _slower_ with EGTBs.

Code: Select all

               46->   2.06   7.11   1. Kb1 Kb7 2. Kc1 Kc7 3. Kd1 Kd7 4.
                                    Kc2 Kc7 5. Kd3 Kb7 6. Ke3 Kc7 7. Kf3
                                    Kd7 8. Kg3 Ke7 9. Kh4 Kf7 10. Kg5 Kg7
                                    11. Kxf5 Kf7 12. Kg5 Kg7 13. f5 Kf7
                                    14. f6 Kf8 15. Kg4 Kg8 16. Kf4 Kf8
                                    17. Kg5 Kf7 18. Kf5 Kf8 19. Ke6 Ke8
                                    20. Kxd6 Kf7 21. Ke5 Kf8 22. Ke6 Kg8
                                    23. d6 Kf8

               46->   1:00  16.73   1. Kb1 Kb7 2. Kc1 Kc7 3. Kd1 Kd7 4.
                                    Kc2 Kc7 5. Kd3 Kb7 6. Ke3 Kc7 7. Kf3
                                    Kd7 8. Kg3 Ke7 9. Kh4 Kf7 10. Kg5 Kg7
                                    11. Kxf5 Kf7 12. Ke4 Kf6 13. f5 Kg5
                                    14. Kd3 Kh5 15. Kc4 Kg5 16. f6 Kg6
                                    17. Kb5 Kf7 18. Kxa5 Ke8 19. f7+ Kf8
                                    20. Kb6 Kg7 21. f8=Q+ Kg6 22. Qxd6+
                                    Kf7 23. Qc7+ Ke8 24. Qc8+ Ke7 25. Qc5+
                                    Kd7 26. Qc7+ Ke8
30x slower there. Current Crafty is probing only up to 1/2 the normal iteration depth. For the 46 ply search, it only probes at plies <= 23. This is quite a ways from egtb probes at the root, and in fact:

predicted=0 evals=1.6M 50move=0 EGTBprobes=53K hits=53K

Is the the search statistics. 53K probes. 30x slower. NPS?

Code: Select all

              time=2.06  mat=1  n=8711502  fh=94%  nps=4.2M
              time=1&#58;00  mat=1  n=21506138  fh=92%  nps=356K
NPS dropped by 10x. That is why this is having a no-better result in cluster testing, whether I used very fast games or very slow games. The overall loss in NPS _really_ affects search depth when the middlegame branching factor is 2.0 or less. Enough so that the loss in depth offsets the gain in perfect knowledge...

Even fast disks don't save the day. And when you add the 6-piece files, boom.

For fun, on the fastest 64gb SSD I have:

Code: Select all

time=1.64  mat=1  n=8711502  fh=94%  nps=5.3M
time=12.99  mat=1  n=21506138  fh=92%  nps=1.7M
6x slower there. If the time limit was exactly 1 second, without, Crafty hits 44 plies, with, 38, before time runs out. 6 plies lost. This is with all 3-4-5 piece files, again on fine 70 for comparison. I can test any position you want, but egtbs really have a negative impact even on a laptop with 4 gigs of RAM for buffering, and a 64 gig SSD for storage.

....
I ran the same experiment you did and got very different results for Fine 70. Crafty 23.3 on an Amd64 3000 32 bit 512m hash. The first result is without egtbs, the second is USB flash EGTBS, the third is hard disk EGTBs.

Code: Select all

               37->   0.30   3.94   1. Kb1 Kb7 2. Kc1 Kc7 3. Kd1 Kd7 4. Kc2 Kc8 5. Kd2 Kb7 6. Ke2 Kc8 7. Kf2 Kd7 8. Kg3 Ke7 9. Kh4
                                    Kf7 10. Kg5 Kg7 11. Kxf5 Kf7 12. Kg5 Kg7 13. f5 Kf7 14. f6 Kf8 15. Kg4 Ke8 16. Kf4 Kd8 17. Kg5
                                    Kd7 18. Kg6 Ke8 19. f7+ Kf8
              time=0.30  mat=1  n=740213  fh=95%  nps=2.5M
              extensions=3K qchecks=5K reduced=231K pruned=85K
              predicted=0  evals=88K  50move=0  EGTBprobes=0  hits=0

               37->   0.64   3.94   1. Kb1 Kb7 2. Kc1 Kc7 3. Kd1 Kd7 4. Kc2 Kc8 5. Kd2 Kb7 6. Ke2 Kc8 7. Kf2 Kd7 8. Kg3 Ke7 9. Kh4
                                    Kf7 10. Kg5 Kg7 11. Kxf5 Kf7 12. Kg5 Kg7 13. f5 Kf7 14. f6 Kf8 15. Kg4 Ke8 16. Kf4 Kd8 17. Kg5
                                    Kd7 18. Kg6 Ke8 19. f7+ Kf8
              time=0.64  mat=1  n=749158  fh=95%  nps=1.2M
              extensions=4K qchecks=10K reduced=233K pruned=88K
              predicted=0  evals=95K  50move=0  EGTBprobes=1K  hits=1K

               37->   3.65   3.94   1. Kb1 Kb7 2. Kc1 Kc7 3. Kd1 Kd7 4. Kc2 Kc8 5. Kd2 Kb7 6. Ke2 Kc8 7. Kf2 Kd7 8. Kg3 Ke7 9. Kh4
                                    Kf7 10. Kg5 Kg7 11. Kxf5 Kf7 12. Kg5 Kg7 13. f5 Kf7 14. f6 Kf8 15. Kg4 Ke8 16. Kf4 Kd8 17. Kg5
                                    Kd7 18. Kg6 Ke8 19. f7+ Kf8
              time=3.65  mat=1  n=749158  fh=95%  nps=205K
              extensions=4K qchecks=10K reduced=233K pruned=88K
              predicted=0  evals=95K  50move=0  EGTBprobes=1K  hits=1K

2x slower with flash EGTBs, 12x slower with hard disk EGTBS. Note that it actually searched more nodes with EGTBs which suggests that it is a very bad case for EGTBs.

Code: Select all

               43->   2.16   6.38   1. Kb1 Kb7 2. Kc1 Kc7 3. Kd1 Kd7 4. Kc2 Kc8 5. Kd2 Kb7 6. Ke2 Kc8 7. Kf2 Kd7 8. Kg3 Ke7 9. Kh4
                                    Kf7 10. Kg5 Kg7 11. Kxf5 Kf7 12. Kg5 Kg7 13. f5 Kf7 14. f6 Kf8 15. Kg4 Ke8 16. Kf4 Kf8 17. Kg5
                                    Kf7 18. Kf5 Kf8 19. Ke6 Ke8 20. Kxd6 Kf7 21. Ke5 Ke8 22. d6
              time=2.16  mat=1  n=5363455  fh=96%  nps=2.5M
              extensions=124K qchecks=202K reduced=1.3M pruned=1.3M
              predicted=0  evals=375K  50move=0  EGTBprobes=0  hits=0

               43->   3.50   8.52   1. Kb1 Kb7 2. Kc1 Kc7 3. Kd1 Kd7 4. Kc2 Kc8 5. Kd2 Kb7 6. Ke2 Kc8 7. Kf2 Kd7 8. Kg3 Ke7 9. Kh4
                                    Kf7 10. Kg5 Kg7 11. Kxf5 Kf7 12. Ke4 Ke7 13. Kd3 Kd7 14. Kc4 Kc7 15. Kb5 Kb7 16. Kxa5 Kc7 17. f5
                                    Kd7 18. f6 Ke8 19. Kb5 Kf7 20. Kc6 Kg6 21. f7 Kxf7
              time=3.50  mat=1  n=4325348  fh=96%  nps=1.2M
              extensions=100K qchecks=154K reduced=1.2M pruned=1.0M
              predicted=0  evals=321K  50move=0  EGTBprobes=5K  hits=5K

               43->  14.76   8.52   1. Kb1 Kb7 2. Kc1 Kc7 3. Kd1 Kd7 4. Kc2 Kc8 5. Kd2 Kb7 6. Ke2 Kc8 7. Kf2 Kd7 8. Kg3 Ke7 9. Kh4
                                    Kf7 10. Kg5 Kg7 11. Kxf5 Kf7 12. Ke4 Ke7 13. Kd3 Kd7 14. Kc4 Kc7 15. Kb5 Kb7 16. Kxa5 Kc7 17. f5
                                    Kd7 18. f6 Ke8 19. Kb5 Kf7 20. Kc6 Kg6 21. f7 Kxf7
              time=14.76  mat=1  n=4325348  fh=96%  nps=293K
              extensions=100K qchecks=154K reduced=1.2M pruned=1.0M
              predicted=0  evals=321K  50move=0  EGTBprobes=5K  hits=5K

1.5x slower with flash EGTBs, 7x slower with hard disk EGTBS.
jwes
Posts: 778
Joined: Sat Jul 01, 2006 7:11 am

Re: EGTB value

Post by jwes »

I tried a different position and it is a little more favorable to EGTBs.
8/8/2pp3k/8/1P1P3K/8/8/8 w - - bm d5; id "Fine 51 (W to move) white wins";
EGTBs are 32x faster than without. Crafty without EGTBs has to search to ply 15 to see the position is won while with EGTBs it sees mate at ply 4.
First is without EGTBs, second is with.

Code: Select all

              depth   time  score   variation &#40;1&#41;
               14->   0.03   1.16   1. d5 cxd5 2. b5 d4 3. Kg4 Kg6 4. Kf4 d3 5. Ke3 Kf5 6. Kxd3 Ke6 7. b6 Kd7
               15->   0.05   6.74   1. d5 cxd5 2. b5 d4 3. Kg4 d3 4. Kf3 d2 5. Ke2 d1=Q+ 6. Kxd1 Kg5 7. b6 Kf4 8. Ke2
               29->  15.75  13.24   1. d5 cxd5 2. Kg4 Kg6 3. b5 d4 4. Kf3 Kf5 5. b6 d3 6. Ke3 d2 7. Kxd2 Ke4 8. b7 Kd4 9. b8=Q Ke5
                                    10. Kd3 Ke6 11. Qe8+ Kf5 12. Qf7+ Ke5 13. Qe7+ Kf4 14. Qf6+ Kg4 15. Qxd6 Kf5 <HT>
              time=15.75  mat=0  n=37650630  fh=93%  nps=2.4M
              extensions=3.1M qchecks=2.8M reduced=7.7M pruned=15.6M
              predicted=0  evals=4.7M  50move=0  EGTBprobes=0  hits=0

              depth   time  score   variation &#40;1&#41;
                4->   0.02  Mat19   1. d5 cxd5 <EGTB>         
               29->   0.49  Mat19   1. d5 cxd5 <EGTB>         
              time=0.49  mat=0  n=73501  fh=98%  nps=150K
              extensions=1K qchecks=2K reduced=20K pruned=25K
              predicted=0  evals=69  50move=0  EGTBprobes=1K  hits=1K
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: EGTB value

Post by bob »

rbarreira wrote:
bob wrote:
rbarreira wrote:
bob wrote:
rbarreira wrote:
zamar wrote:
rbarreira wrote: I realize that if the tablebases are used during search that would slow down the search, but as someone else said earlier it should be good to at least use them in the root (i.e. if current game position is in the tablebase, play the move suggested there).
The modern chess engines are such monsters with their 20-30 ply searches that if there is a win in 5 pieces position they will find it with >99% probability, so using EGTB might give 1-2 elo at maximum. Linking gaviota probing code in SF made it around 1% slower when compiling with GCC (I really don't know why but likely somehow related to the grown size of executable), this means -1 elo.

So it's very close to +-0 as Bob has already said.
Well if that's true that's all that really needed to be said, I wasn't aware of it.

But is that true for short time controls? In that case would an engine find the win with 5 pieces 99% of the time, even if they're playing against an engine using EGTB?
The issue might be a bit more easily explained, than even what Joona mentioned.

You have two classes of positions: (a) those your search can win by itself; and (b) those it can only win with EGTBs. In my testing, almost all 3-4-5 piece endings fit into A. A few tricky ones (KNNKP perhaps, KQPKQ) may need some help, not because a 40+ ply search can't win them, but instead, because if we encounter one of those positions near the horizon we will mis-evaluate it.

Adding EGTBs hurts case (a) because it slows you down significantly. It helps (b) because you now have perfect knowledge at parts of the tree where you can afford to access it. You help a very small part of the total positions you search, you hurt a huge part of them. Overall, things seem to wash out, regardless of the time control used.

I have not yet tried bitbases, so can't address that issue yet.

The most important part of EGTBs is not "winning" won positions, it is correctly classifying as won/lost/drawn those positions in the search where the normal evaluation produces an incorrect result. SO that you don't stumble into a position you would rather avoid, from a position where you are winning, etc...
But adding EGTB probes at the root node only does not slow you down at all. So case a) positions will work as they do now, and case b) positions will always be won no matter the time control.

Unless the b) cases are really really rare, I don't see how probing EGTBs at the root search would be negligible in terms of strength.
The problem is, "you are already there". You didn't use any judgement to prefer a won KRPKR over a drawn KRPKR position, because at the root, you are already at the point where you are in the position. What good is it to know you are in a drawn position, as opposed to having a chance to avoid it and go into a won position?
That's a tautological argument and I don't really see the point... Yes you "are already there", that's why it's called the root node. With EGTBs you can play the perfect move if your root node is in the EGTB, without them you may or may not play a good move. Isn't it better to have the perfect move than to not have it?

I'm not comparing the benefit of EGTBs at the root with anything else as you seemed to be doing in your last sentence, I'm just wondering what's the value of using EGTBs at the root.
Here's a question that will make it clear.

You have two cases:

(1) you reach a position where every move you can play leads to a loss or draw, according to egtbs.

(2) you probe deeply in the search where you reach positions that are won, lost or drawn, and you get to force the line of play so that it reaches a position that is won.

Which would you prefer?

With (1) you have no practical choice. You are forced to play a move that loses or draws, because you made previous moves without any knowledge that you were heading to this particular drawn/lost position. With (2) you have more options, and have a chance to guide the game to a position that you can win.

That is the point. Yes you can probe at the root. Yes it will, on rare occasions, give a good result. But most of the time, the game is decided before you get the first egtb hit...
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: EGTB value

Post by bob »

rbarreira wrote:
mcostalba wrote:
rbarreira wrote: That's a tautological argument and I don't really see the point... Yes you "are already there", that's why it's called the root node. With EGTBs you can play the perfect move if your root node is in the EGTB, without them you may or may not play a good move. Isn't it better to have the perfect move than to not have it?
At root the possibility to play a wrong move in a winning position is very very low because you have the full search depth to find it.
So how many seconds do you typically need to find a winning move for a 6-piece root node that is a win with perfect play? is it something that you can almost always do at most time controls or not? That's the key question.

I wouldn't doubt that you are correct for long time controls, not so sure about shorter ones.
I once thought that KQ vs KR was a very difficult position to play as a human. About 15 years ago this came up in a discussion with Amir Ban. I decided to try that using crafty with no egtb, vs crafty with 3-4-5 piece egtbs (so that it could play perfectly). Amazingly, even at 0.1 seconds per move, non-egtb Crafty could win the game every last time. These things are not that hard to win with the search depths we saw back then, much less the depths we see today...
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: EGTB value

Post by bob »

jwes wrote:
bob wrote:
michiguel wrote:
bob wrote:
Uri Blass wrote:
bob wrote:
rbarreira wrote:I haven't looked at this in detail, but it looks very weird to me that we have databases of perfect moves and we can't make use of them to improve play.

I realize that if the tablebases are used during search that would slow down the search, but as someone else said earlier it should be good to at least use them in the root (i.e. if current game position is in the tablebase, play the move suggested there).
There are several issues involved.

(1) probing in the search slows things down. 10 years ago, this was not so noticable. Today, with an effective branching factor of way less than 2.0 in endgames, it can be a huge loss.
I do not understand why probing in the search has to slow things down(assuming that you do not probe in every node in the search but only when the remaining depth is big enough so the time of searching the remaining depth is bigger than the time of probing the tablebases).

I think that the first test before playing games should be if you get the same depth faster in endgame analysis.

If you get the same depth faster but still do not earn rating points based on games then it is interesting(and maybe the reason can be that you are slightly slower in opening and middle game positions when you do not probe tablebases because checking that you do not need to probe tablebases after a capture cost time).
Simple math. On my 8-core box, Crafty searches about 20M nodes per second up to 30M in the endgame. On a good disk, you can do a read every 5ms, or about 200 reads per second. Compare the speeds. During the time I can do a single read, I can search 150K nodes. That is huge. For every 200 I/O accesses, I could search another 30M nodes. The cost to check for probes is roughly zero since in the opening and middlegame, that branch gets predicted 100% correctly. But when you get down to the 12-16 pieces total, you begin to see EGTB probes. Each successful probe costs about 5ms if a disk access is required, actually quite a bit more since you read in fairly large compressed blocks, and then have to spend time uncompressing a block before the probe can be completed...

Either you rarely probe, which doesn't help much, or you probe a lot, which starts to cost multiple plies.
Your 5ms figure assumes no cache. But if you have a cache that makes you read from disk only 5% of the time, a fast decompressing scheme that is effectively faster than reading uncompressed data, you will end up with an average figure of 0.3 ms (and we are not even talking about SSD). That means, if you probe in a node in which it is required to search deep enough to cost only 10k nodes, the effect on speed will be negligible. That means you can search "relatively" close to the leaves with no time-to-depth cost (in fact it should lower because of the pruning performed at nodes closer to the root). What is the depth you can reach with 10 k nodes? that is "approximately" the distance to the leaves you can _safely_ afford.

Of course, these numbers may not apply to Nalimov, but they do apply to the Gaviota TBs.

Miguel
The cache is much less significant when you factor in the 6-piece files that many are using. Suddenly the cache becomes almost useless due to the 2gb file sizes, and many files have to be broken into many 2gb chunks to work on 32 bit systems.


My observations are exactly that, observations. Here is one example, using just one CPU to avoid any SMP issues. This is fine #70, not a particularly good EGTB position since it takes a while to reach a position with just 5 pieces left (I am only using 3/4/5 piece files for this test). Both find the correct move, Kb1, at depth 24, same amount of time. But as the search progresses...First, normal Crafty, no egtbs, then same depth using EGTBs:

Code: Select all

               37->   0.16   4.27   1. Kb1 Kb7 2. Kc1 Kc7 3. Kd1 Kd7 4.
                                    Kc2 Kc7 5. Kd3 Kb7 6. Ke3 Kc7 7. Kf3
                                    Kd7 8. Kg3 Ke7 9. Kh4 Kf7 10. Kg5 Kg7
                                    11. Kxf5 Kf7 12. Kg5 Kg7 13. f5 Kf7
                                    14. f6 Kf8 15. Kg4 Kg8 16. Kf4 Kf8
                                    17. Kg5 Ke8 18. Kg4 Kf8 19. Kf5

               37->   3.20   4.27   1. Kb1 Kb7 2. Kc1 Kc7 3. Kd1 Kd7 4.
                                    Kc2 Kc7 5. Kd3 Kb7 6. Ke3 Kc7 7. Kf3
                                    Kd7 8. Kg3 Ke7 9. Kh4 Kf7 10. Kg5 Kg7
                                    11. Kxf5 Kf7 12. Kg5 Kg7 13. f5 Kf7
                                    14. f6 Kf8 15. Kg4 Kg8 16. Kf4 Kf8
                                    17. Kg5 Ke8 18. Kg4 Kf8 19. Kf5
20x _slower_ with EGTBs.

Code: Select all

               46->   2.06   7.11   1. Kb1 Kb7 2. Kc1 Kc7 3. Kd1 Kd7 4.
                                    Kc2 Kc7 5. Kd3 Kb7 6. Ke3 Kc7 7. Kf3
                                    Kd7 8. Kg3 Ke7 9. Kh4 Kf7 10. Kg5 Kg7
                                    11. Kxf5 Kf7 12. Kg5 Kg7 13. f5 Kf7
                                    14. f6 Kf8 15. Kg4 Kg8 16. Kf4 Kf8
                                    17. Kg5 Kf7 18. Kf5 Kf8 19. Ke6 Ke8
                                    20. Kxd6 Kf7 21. Ke5 Kf8 22. Ke6 Kg8
                                    23. d6 Kf8

               46->   1&#58;00  16.73   1. Kb1 Kb7 2. Kc1 Kc7 3. Kd1 Kd7 4.
                                    Kc2 Kc7 5. Kd3 Kb7 6. Ke3 Kc7 7. Kf3
                                    Kd7 8. Kg3 Ke7 9. Kh4 Kf7 10. Kg5 Kg7
                                    11. Kxf5 Kf7 12. Ke4 Kf6 13. f5 Kg5
                                    14. Kd3 Kh5 15. Kc4 Kg5 16. f6 Kg6
                                    17. Kb5 Kf7 18. Kxa5 Ke8 19. f7+ Kf8
                                    20. Kb6 Kg7 21. f8=Q+ Kg6 22. Qxd6+
                                    Kf7 23. Qc7+ Ke8 24. Qc8+ Ke7 25. Qc5+
                                    Kd7 26. Qc7+ Ke8
30x slower there. Current Crafty is probing only up to 1/2 the normal iteration depth. For the 46 ply search, it only probes at plies <= 23. This is quite a ways from egtb probes at the root, and in fact:

predicted=0 evals=1.6M 50move=0 EGTBprobes=53K hits=53K

Is the the search statistics. 53K probes. 30x slower. NPS?

Code: Select all

              time=2.06  mat=1  n=8711502  fh=94%  nps=4.2M
              time=1&#58;00  mat=1  n=21506138  fh=92%  nps=356K
NPS dropped by 10x. That is why this is having a no-better result in cluster testing, whether I used very fast games or very slow games. The overall loss in NPS _really_ affects search depth when the middlegame branching factor is 2.0 or less. Enough so that the loss in depth offsets the gain in perfect knowledge...

Even fast disks don't save the day. And when you add the 6-piece files, boom.

For fun, on the fastest 64gb SSD I have:

Code: Select all

time=1.64  mat=1  n=8711502  fh=94%  nps=5.3M
time=12.99  mat=1  n=21506138  fh=92%  nps=1.7M
6x slower there. If the time limit was exactly 1 second, without, Crafty hits 44 plies, with, 38, before time runs out. 6 plies lost. This is with all 3-4-5 piece files, again on fine 70 for comparison. I can test any position you want, but egtbs really have a negative impact even on a laptop with 4 gigs of RAM for buffering, and a 64 gig SSD for storage.

....
I ran the same experiment you did and got very different results for Fine 70. Crafty 23.3 on an Amd64 3000 32 bit 512m hash. The first result is without egtbs, the second is USB flash EGTBS, the third is hard disk EGTBs.

Code: Select all

               37->   0.30   3.94   1. Kb1 Kb7 2. Kc1 Kc7 3. Kd1 Kd7 4. Kc2 Kc8 5. Kd2 Kb7 6. Ke2 Kc8 7. Kf2 Kd7 8. Kg3 Ke7 9. Kh4
                                    Kf7 10. Kg5 Kg7 11. Kxf5 Kf7 12. Kg5 Kg7 13. f5 Kf7 14. f6 Kf8 15. Kg4 Ke8 16. Kf4 Kd8 17. Kg5
                                    Kd7 18. Kg6 Ke8 19. f7+ Kf8
              time=0.30  mat=1  n=740213  fh=95%  nps=2.5M
              extensions=3K qchecks=5K reduced=231K pruned=85K
              predicted=0  evals=88K  50move=0  EGTBprobes=0  hits=0

               37->   0.64   3.94   1. Kb1 Kb7 2. Kc1 Kc7 3. Kd1 Kd7 4. Kc2 Kc8 5. Kd2 Kb7 6. Ke2 Kc8 7. Kf2 Kd7 8. Kg3 Ke7 9. Kh4
                                    Kf7 10. Kg5 Kg7 11. Kxf5 Kf7 12. Kg5 Kg7 13. f5 Kf7 14. f6 Kf8 15. Kg4 Ke8 16. Kf4 Kd8 17. Kg5
                                    Kd7 18. Kg6 Ke8 19. f7+ Kf8
              time=0.64  mat=1  n=749158  fh=95%  nps=1.2M
              extensions=4K qchecks=10K reduced=233K pruned=88K
              predicted=0  evals=95K  50move=0  EGTBprobes=1K  hits=1K

               37->   3.65   3.94   1. Kb1 Kb7 2. Kc1 Kc7 3. Kd1 Kd7 4. Kc2 Kc8 5. Kd2 Kb7 6. Ke2 Kc8 7. Kf2 Kd7 8. Kg3 Ke7 9. Kh4
                                    Kf7 10. Kg5 Kg7 11. Kxf5 Kf7 12. Kg5 Kg7 13. f5 Kf7 14. f6 Kf8 15. Kg4 Ke8 16. Kf4 Kd8 17. Kg5
                                    Kd7 18. Kg6 Ke8 19. f7+ Kf8
              time=3.65  mat=1  n=749158  fh=95%  nps=205K
              extensions=4K qchecks=10K reduced=233K pruned=88K
              predicted=0  evals=95K  50move=0  EGTBprobes=1K  hits=1K

2x slower with flash EGTBs, 12x slower with hard disk EGTBS. Note that it actually searched more nodes with EGTBs which suggests that it is a very bad case for EGTBs.

Code: Select all

               43->   2.16   6.38   1. Kb1 Kb7 2. Kc1 Kc7 3. Kd1 Kd7 4. Kc2 Kc8 5. Kd2 Kb7 6. Ke2 Kc8 7. Kf2 Kd7 8. Kg3 Ke7 9. Kh4
                                    Kf7 10. Kg5 Kg7 11. Kxf5 Kf7 12. Kg5 Kg7 13. f5 Kf7 14. f6 Kf8 15. Kg4 Ke8 16. Kf4 Kf8 17. Kg5
                                    Kf7 18. Kf5 Kf8 19. Ke6 Ke8 20. Kxd6 Kf7 21. Ke5 Ke8 22. d6
              time=2.16  mat=1  n=5363455  fh=96%  nps=2.5M
              extensions=124K qchecks=202K reduced=1.3M pruned=1.3M
              predicted=0  evals=375K  50move=0  EGTBprobes=0  hits=0

               43->   3.50   8.52   1. Kb1 Kb7 2. Kc1 Kc7 3. Kd1 Kd7 4. Kc2 Kc8 5. Kd2 Kb7 6. Ke2 Kc8 7. Kf2 Kd7 8. Kg3 Ke7 9. Kh4
                                    Kf7 10. Kg5 Kg7 11. Kxf5 Kf7 12. Ke4 Ke7 13. Kd3 Kd7 14. Kc4 Kc7 15. Kb5 Kb7 16. Kxa5 Kc7 17. f5
                                    Kd7 18. f6 Ke8 19. Kb5 Kf7 20. Kc6 Kg6 21. f7 Kxf7
              time=3.50  mat=1  n=4325348  fh=96%  nps=1.2M
              extensions=100K qchecks=154K reduced=1.2M pruned=1.0M
              predicted=0  evals=321K  50move=0  EGTBprobes=5K  hits=5K

               43->  14.76   8.52   1. Kb1 Kb7 2. Kc1 Kc7 3. Kd1 Kd7 4. Kc2 Kc8 5. Kd2 Kb7 6. Ke2 Kc8 7. Kf2 Kd7 8. Kg3 Ke7 9. Kh4
                                    Kf7 10. Kg5 Kg7 11. Kxf5 Kf7 12. Ke4 Ke7 13. Kd3 Kd7 14. Kc4 Kc7 15. Kb5 Kb7 16. Kxa5 Kc7 17. f5
                                    Kd7 18. f6 Ke8 19. Kb5 Kf7 20. Kc6 Kg6 21. f7 Kxf7
              time=14.76  mat=1  n=4325348  fh=96%  nps=293K
              extensions=100K qchecks=154K reduced=1.2M pruned=1.0M
              predicted=0  evals=321K  50move=0  EGTBprobes=5K  hits=5K

1.5x slower with flash EGTBs, 7x slower with hard disk EGTBS.
Not sure what is wrong, but the egtb hits are wrong. Do you have _all_ the 4-5 piece files? If you notice my results, I saw 53K hits, not 1K. That is not going to slow you down as much. No explanation as to why, however. Wait, your search is _much_ shallower. I believe mine were sd=46, not 43. You might try that to see what happens...
rbarreira
Posts: 900
Joined: Tue Apr 27, 2010 3:48 pm

Re: EGTB value

Post by rbarreira »

bob wrote:
rbarreira wrote:
bob wrote:
rbarreira wrote:
bob wrote:
rbarreira wrote:
zamar wrote:
rbarreira wrote: I realize that if the tablebases are used during search that would slow down the search, but as someone else said earlier it should be good to at least use them in the root (i.e. if current game position is in the tablebase, play the move suggested there).
The modern chess engines are such monsters with their 20-30 ply searches that if there is a win in 5 pieces position they will find it with >99% probability, so using EGTB might give 1-2 elo at maximum. Linking gaviota probing code in SF made it around 1% slower when compiling with GCC (I really don't know why but likely somehow related to the grown size of executable), this means -1 elo.

So it's very close to +-0 as Bob has already said.
Well if that's true that's all that really needed to be said, I wasn't aware of it.

But is that true for short time controls? In that case would an engine find the win with 5 pieces 99% of the time, even if they're playing against an engine using EGTB?
The issue might be a bit more easily explained, than even what Joona mentioned.

You have two classes of positions: (a) those your search can win by itself; and (b) those it can only win with EGTBs. In my testing, almost all 3-4-5 piece endings fit into A. A few tricky ones (KNNKP perhaps, KQPKQ) may need some help, not because a 40+ ply search can't win them, but instead, because if we encounter one of those positions near the horizon we will mis-evaluate it.

Adding EGTBs hurts case (a) because it slows you down significantly. It helps (b) because you now have perfect knowledge at parts of the tree where you can afford to access it. You help a very small part of the total positions you search, you hurt a huge part of them. Overall, things seem to wash out, regardless of the time control used.

I have not yet tried bitbases, so can't address that issue yet.

The most important part of EGTBs is not "winning" won positions, it is correctly classifying as won/lost/drawn those positions in the search where the normal evaluation produces an incorrect result. SO that you don't stumble into a position you would rather avoid, from a position where you are winning, etc...
But adding EGTB probes at the root node only does not slow you down at all. So case a) positions will work as they do now, and case b) positions will always be won no matter the time control.

Unless the b) cases are really really rare, I don't see how probing EGTBs at the root search would be negligible in terms of strength.
The problem is, "you are already there". You didn't use any judgement to prefer a won KRPKR over a drawn KRPKR position, because at the root, you are already at the point where you are in the position. What good is it to know you are in a drawn position, as opposed to having a chance to avoid it and go into a won position?
That's a tautological argument and I don't really see the point... Yes you "are already there", that's why it's called the root node. With EGTBs you can play the perfect move if your root node is in the EGTB, without them you may or may not play a good move. Isn't it better to have the perfect move than to not have it?

I'm not comparing the benefit of EGTBs at the root with anything else as you seemed to be doing in your last sentence, I'm just wondering what's the value of using EGTBs at the root.
Here's a question that will make it clear.

You have two cases:

(1) you reach a position where every move you can play leads to a loss or draw, according to egtbs.

(2) you probe deeply in the search where you reach positions that are won, lost or drawn, and you get to force the line of play so that it reaches a position that is won.

Which would you prefer?

With (1) you have no practical choice. You are forced to play a move that loses or draws, because you made previous moves without any knowledge that you were heading to this particular drawn/lost position. With (2) you have more options, and have a chance to guide the game to a position that you can win.

That is the point. Yes you can probe at the root. Yes it will, on rare occasions, give a good result. But most of the time, the game is decided before you get the first egtb hit...
You have already proven that 2) using EGTBs is not a good idea due to search slowdown from probing the EGTBs.

So given that, I would choose 1) of course, with the obvious addition that won positions would be taken advantage of (why did you focus on the lost/drawn ones only?). On lost/drawn positions the EGTB still has a move, right? The one that delays the most, which gives more of a chance for the opponent to screw up and give you a win (which you will find in the EGTB).
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: EGTB value

Post by bob »

jwes wrote:I tried a different position and it is a little more favorable to EGTBs.
8/8/2pp3k/8/1P1P3K/8/8/8 w - - bm d5; id "Fine 51 (W to move) white wins";
EGTBs are 32x faster than without. Crafty without EGTBs has to search to ply 15 to see the position is won while with EGTBs it sees mate at ply 4.
First is without EGTBs, second is with.

Code: Select all

              depth   time  score   variation &#40;1&#41;
               14->   0.03   1.16   1. d5 cxd5 2. b5 d4 3. Kg4 Kg6 4. Kf4 d3 5. Ke3 Kf5 6. Kxd3 Ke6 7. b6 Kd7
               15->   0.05   6.74   1. d5 cxd5 2. b5 d4 3. Kg4 d3 4. Kf3 d2 5. Ke2 d1=Q+ 6. Kxd1 Kg5 7. b6 Kf4 8. Ke2
               29->  15.75  13.24   1. d5 cxd5 2. Kg4 Kg6 3. b5 d4 4. Kf3 Kf5 5. b6 d3 6. Ke3 d2 7. Kxd2 Ke4 8. b7 Kd4 9. b8=Q Ke5
                                    10. Kd3 Ke6 11. Qe8+ Kf5 12. Qf7+ Ke5 13. Qe7+ Kf4 14. Qf6+ Kg4 15. Qxd6 Kf5 <HT>
              time=15.75  mat=0  n=37650630  fh=93%  nps=2.4M
              extensions=3.1M qchecks=2.8M reduced=7.7M pruned=15.6M
              predicted=0  evals=4.7M  50move=0  EGTBprobes=0  hits=0

              depth   time  score   variation &#40;1&#41;
                4->   0.02  Mat19   1. d5 cxd5 <EGTB>         
               29->   0.49  Mat19   1. d5 cxd5 <EGTB>         
              time=0.49  mat=0  n=73501  fh=98%  nps=150K
              extensions=1K qchecks=2K reduced=20K pruned=25K
              predicted=0  evals=69  50move=0  EGTBprobes=1K  hits=1K
That's not the kind of position that is useful. I worry more about the ones where you have to search deeply to get an EGTB hit. And that hit provides good information, but at the cost of a huge number of nodes. And if you can't force that EGTB score back to the root, you have to suffer the loss of depth it causes, and play worse, tactically...
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: EGTB value

Post by bob »

beachknight wrote:
bob wrote:
Jouni wrote:There was another test in Rybka forum showing a small benefit:

Final Report
----------------

I have finished the EGTB test of 10,000 games . Rybka 3 with EGTB's 3-4-5 and 180gb 6man has defeated Rybka 3 without EGTB's in a single CPU fixed depth 8ply match:

Rybka 3 EGTB +2064/=6237/-1699 51.83% 5182.5/10000
Rybka 3 no EGTB +1699/=6237/-2064 48.18% 4817.5/10000

This match favored the EGTB engine by 13 ELO.

Setup
--------
Time control - fixed depth 8 ply
System - Intel i7-920 @2.67ghz , hyperthreading disabled
RAM - 6gb
CPUs - 1 thread per engine
Engine - Rybka 3
Engine hash - 512mb
EGTB hash - 32mb
Engine tablebases - 3-4-5-6 man (180gb 6man)
GUI tablebases - none
Nalimov usage - "Never" for one engine and "Normal" for the other
Opening book - large private book, learning functions disabled, variety at 75%
Engine match options - alternating colors
Game options - Resign : never and Draw : never
OS - Vista x64
GUI - Chessbase Rybka 3 (version May 4 2009)

2 dubious thing: R3 - R3 and fixed depth (isn't just EGTB access making engine slower!)...

Jouni
Fixed depth is simply bogus. The EGTBs will normally cost plies, particularly in endgames. This is yet another worthless result. Yes, if I could use EGTBs and have _no_ performance penalty, they would help. But that is not reality.
So as summary:

What could be your suggestion to us mortal blitz testers?

a. not using egtbs

b. only using 4-pieces egtbs

TIA,

Best,
I suggest using none. If 5's don't help on a machine with enough memory to cache all 7+ gigs of them in memory, then dropping back to 4's only reduces the amount of available info further, although the program will probably play slightly better. And better still with 3. And even better with 2. :) Although the difference going from 5 to 0 is only about 2 Elo based on my testing, whether you use very fast (10s+0.1s), fast blitz (1m+1s) or even 30m+30s (I did not play 30K games at that speed, but the improvement did not grow as the time control was lengthened...)
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: EGTB value

Post by bob »

rbarreira wrote:
bob wrote:
rbarreira wrote:
bob wrote:
rbarreira wrote:
bob wrote:
rbarreira wrote:
zamar wrote:
rbarreira wrote: I realize that if the tablebases are used during search that would slow down the search, but as someone else said earlier it should be good to at least use them in the root (i.e. if current game position is in the tablebase, play the move suggested there).
The modern chess engines are such monsters with their 20-30 ply searches that if there is a win in 5 pieces position they will find it with >99% probability, so using EGTB might give 1-2 elo at maximum. Linking gaviota probing code in SF made it around 1% slower when compiling with GCC (I really don't know why but likely somehow related to the grown size of executable), this means -1 elo.

So it's very close to +-0 as Bob has already said.
Well if that's true that's all that really needed to be said, I wasn't aware of it.

But is that true for short time controls? In that case would an engine find the win with 5 pieces 99% of the time, even if they're playing against an engine using EGTB?
The issue might be a bit more easily explained, than even what Joona mentioned.

You have two classes of positions: (a) those your search can win by itself; and (b) those it can only win with EGTBs. In my testing, almost all 3-4-5 piece endings fit into A. A few tricky ones (KNNKP perhaps, KQPKQ) may need some help, not because a 40+ ply search can't win them, but instead, because if we encounter one of those positions near the horizon we will mis-evaluate it.

Adding EGTBs hurts case (a) because it slows you down significantly. It helps (b) because you now have perfect knowledge at parts of the tree where you can afford to access it. You help a very small part of the total positions you search, you hurt a huge part of them. Overall, things seem to wash out, regardless of the time control used.

I have not yet tried bitbases, so can't address that issue yet.

The most important part of EGTBs is not "winning" won positions, it is correctly classifying as won/lost/drawn those positions in the search where the normal evaluation produces an incorrect result. SO that you don't stumble into a position you would rather avoid, from a position where you are winning, etc...
But adding EGTB probes at the root node only does not slow you down at all. So case a) positions will work as they do now, and case b) positions will always be won no matter the time control.

Unless the b) cases are really really rare, I don't see how probing EGTBs at the root search would be negligible in terms of strength.
The problem is, "you are already there". You didn't use any judgement to prefer a won KRPKR over a drawn KRPKR position, because at the root, you are already at the point where you are in the position. What good is it to know you are in a drawn position, as opposed to having a chance to avoid it and go into a won position?
That's a tautological argument and I don't really see the point... Yes you "are already there", that's why it's called the root node. With EGTBs you can play the perfect move if your root node is in the EGTB, without them you may or may not play a good move. Isn't it better to have the perfect move than to not have it?

I'm not comparing the benefit of EGTBs at the root with anything else as you seemed to be doing in your last sentence, I'm just wondering what's the value of using EGTBs at the root.
Here's a question that will make it clear.

You have two cases:

(1) you reach a position where every move you can play leads to a loss or draw, according to egtbs.

(2) you probe deeply in the search where you reach positions that are won, lost or drawn, and you get to force the line of play so that it reaches a position that is won.

Which would you prefer?

With (1) you have no practical choice. You are forced to play a move that loses or draws, because you made previous moves without any knowledge that you were heading to this particular drawn/lost position. With (2) you have more options, and have a chance to guide the game to a position that you can win.

That is the point. Yes you can probe at the root. Yes it will, on rare occasions, give a good result. But most of the time, the game is decided before you get the first egtb hit...
You have already proven that 2) using EGTBs is not a good idea due to search slowdown from probing the EGTBs.

So given that, I would choose 1) of course, with the obvious addition that won positions would be taken advantage of (why did you focus on the lost/drawn ones only?). On lost/drawn positions the EGTB still has a move, right? The one that delays the most, which gives more of a chance for the opponent to screw up and give you a win (which you will find in the EGTB).
Here is the improvement you are chasing after.

You are going to suddenly find yourself in an EGTB position (at the root). Some are drawn, some are lost. And some are won. The distribution seems to greatly favor draws based on the tbs summary files (way more drawn than won positions unless you go to odd things like KQQQKN and such). So the won positions are going to be a small percent of the total positions you reach. Now, what percent of those can be won _without_ EGTBs? I'd bet 99%. In 1,000 games, how many times do you expect to reach a 4-5-6 piece EGTB ending position on the board? It is _way_ less than 5%. I will have to go thru a lot of data to get an accurate number. So your probe at the root will help in maybe 1% of that 5%, which is 0.05% of the positions. Say 1 game? That is not going to be an Elo changer.