Stockfish - material balance/imbalance evaluation

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: Stockfish - material balance/imbalance evaluation

Post by Sven »

mcostalba wrote:
Ralph Stoesser wrote:it would not make any difference whether I include x-ray attacks for queens or not, evaluate_threats() still would not "see" it. That's what I meant.
No, x-ray attacks for queens are used to evaluate mobility not threats.
Ralph Stoesser wrote:Besides evaluate_threats(), queen attacks are especially important in king safety eval.
I would first double check whether it would hurt in king safety to have included x-ray attacks for the queen attacks. Especially the "safe queen contact checks" part seems to be very critical.
I'm not sure if I understood everything correctly, and if there is any misunderstanding involved between both of you. So I try to help by describing how I see it.

1) The ThreatBonus[][] array initialization code has a bug causing each user of the array, beneath other unwanted effects, to get a no-op effect when using ThreatBonus[QUEEN][...] (set to "unused" by accident).

2) Currently ThreatBonus is only used within evaluate_threats(), so evaluate_threats() effectively ignores threats by queens.

3) evaluate_threats() is also using the attackedBy[] array of an EvalInfo object as input parameter. This attackedBy[] array is successively built within the do_evaluate() function and some other functions being called there prior to evaluate_threats(). One of these other functions is evaluate_pieces_of_color() which in turn calls evaluate_pieces().

4) evaluate_pieces() has a special behaviour which may or may not be a bug: it does not consider x-ray attacks by queens while building an internal bitboard 'b' which is used for several purposes, including:
a) for updating the attackedBy[] array,
b) for updating the kingAdjacentZoneAttacksCount[] array,
c) for evaluating mobility.

5) Due to 4) in conjunction with 3) the attackedBy[] array currently has no information about x-ray attacks by queens when being passed as part of EvalInfo to evaluate_threats(). Therefore fixing 2) would help for all pieces types, but for queens the x-ray attacks would not be part of the bonus assigned by evaluate_threats() until also 4) is corrected. On the other hand, fixing only 4) but not 2) would already affect the king safety and mobility evaluation, by adding queen x-ray.

If I analyzed this correctly then from my point of view doing both corrections would be pretty obvious. At least for 2) I see no good reason not to fix it since it is clearly a bug. However, if also applying the fix for 4) hurts ELO strength then it may be an option to leave this one out.

Sven
Ralph Stoesser
Posts: 408
Joined: Sat Mar 06, 2010 9:28 am

Re: Stockfish - material balance/imbalance evaluation

Post by Ralph Stoesser »

Sven Schüle wrote:At least for 2) I see no good reason not to fix it since it is clearly a bug.
Sven
Before I had reported the bug (item 2 in your scheme), I already had evaluated the fix in terms of very fast self play games. It turned out that the fixed version played slightly weaker than the bug version. I would assume this is because the eval parameters are automatically tuned for the bug version, but not yet for the correct one.

Besides, in general, I agree with your analysis. Thanks.

More later.
User avatar
Eelco de Groot
Posts: 4576
Joined: Sun Mar 12, 2006 2:40 am
Full name:   

Re: Stockfish - material balance/imbalance evaluation

Post by Eelco de Groot »

Ralph Stoesser wrote:
Sven Schüle wrote:At least for 2) I see no good reason not to fix it since it is clearly a bug.
Sven
Before I had reported the bug (item 2 in your scheme), I already had evaluated the fix in terms of very fast self play games. It turned out that the fixed version played slightly weaker than the bug version. I would assume this is because the eval parameters are automatically tuned for the bug version, but not yet for the correct one.

Besides, in general, I agree with your analysis. Thanks.

More later.
I think that the parameters of the present ThreatBonus [][] version are tuned, so they can't be very far from what is working. That means that probably the PAWN attacks has to stay or there has to be a correction elsewhere in the code where pawn attacks are a penalty for the piece evaluation. Mainly there has to be added QUEEN attacks but possibly not with the intended parameters, because these were actually tuned for ROOK attacks. In other words most of the parameters possibly should stay in place, unless adding QUEEN attacks and maybe KING attacks changes things. I have not yet done that but something in between for the moment. Rainbow Serpent has some changes in adding the final threat bonuses anyway and did have KING attacks == QUEEN attacks but the rest of the parameters were still in use as in Stockfish.

The new version of the attackedBy[] changes things a little bit but it is not sure yet if it is better or worse. In the single test I did it is only marginally different in the early iterations, the change is just one less node traversed, but later on in the testposition there were more changes, I can't now say if these were good or bad. For instance the PV seemed better with the new version, it is possible though that the code looks deeper and that very far into the search many transposition table entries were missing, so resolving the final plies took longer.

Testposition from Anand - Topalov, game 9. Old code, my new version of ThreatBonus [][] parameters and no changes to attackedBy[]:

[D]6k1/p6p/1p1qp1p1/4n1N1/8/P4P2/6PP/2R1R2K w - -

Engine: Rainbow Serpent 1.7.1s(dc) Build 047 (Athlon 2009 MHz, 256 MB)
by Tord Romstad, Marco Costalba, Joona Kiiski

1.00 0:00 +1.05 33.Rc8+ (580) 2

2.00 0:00 +1.05 33.Rc8+ Kg7 34.Rc7+ Kh6 (683) 2

3.00 0:00 -0.12 33.Rc8+ Kg7 34.Rc7+ Kh6 35.Nf7+ Nxf7
36.Rxf7 (3.261) 10

3.00 0:00 +0.16 33.a4 Nd3 34.Rc8+ Kg7 35.Rxe6 Qd7
36.Ree8 Qxa4 37.Rc7+ (47.139) 125

4.00 0:00 +0.16 33.a4 Nd3 34.Rc8+ Kg7 35.Rxe6 Qd7
36.Ree8 Qxa4 37.Rc7+ (49.718) 127

5.00 0:00 +0.16 33.a4 Kg7 34.Rcd1 Nd3 35.Nxe6+ Kf6 (74.178) 169

6.00 0:00 +0.24++ 33.a4 Kg7 34.h4 Kh6 35.f4 (98.140) 202

6.00 0:00 +0.32++ 33.a4 Kg7 34.g3 Kh6 35.Rxe5 Qxe5
36.Nf7+ (108.905) 217

6.00 0:00 +0.24 33.a4 Kg7 34.Rcd1 Nd3 35.Nxe6+ Kf6
36.Kg1 Kf5 (110.371) 213

7.00 0:00 +0.24 33.a4 Kg7 34.Rcd1 Nd3 35.Nxe6+ Kf6
36.Kg1 Kf5 (131.204) 239

8.00 0:00 +0.32++ 33.a4 Nd3 34.Rc8+ Kg7 35.Rxe6 Qd7
36.Rec6 Nc5 37.R8c7 (200.517) 291

8.00 0:00 +0.40++ 33.a4 Kg7 34.Rcd1 Nd3 35.Nxe6+ Kf6
36.Kg1 Kf5 37.Re3 (206.820) 301

8.00 0:00 +0.24-- 33.a4 h5 34.Rc8+ Kg7 35.Rc7+ Kh6
36.Nf7+ Nxf7 37.Rxf7 Qd2 (254.029) 325

9.01 0:01 +0.32++ 33.a4 h5 34.Rc8+ Kg7 35.h4 Nd3
36.Rxe6 Qd7 37.Rce8 Qxa4 38.R8e7+ Kh6
39.Nf7+ (419.778) 383

9.01 0:01 +0.40++ 33.a4 h5 34.Rc8+ Kg7 35.h4 Nd3
36.Rxe6 Qd7 37.Rce8 Qxa4 38.R8e7+ Kh6
39.Rh7+ (427.905) 385

9.01 0:01 +0.56++ 33.a4 h5 34.Rc8+ Kg7 35.h4 Nd3
36.Rxe6 Qd7 37.Rce8 Qxa4 38.R8e7+ Kh6
39.Rh7+ (437.480) 388

9.01 0:01 +0.79 33.a4 h5 34.Rc8+ Kg7 35.h4 a6
36.Rc7+ Nd7 37.Rec1 Qd5 38.R1c6 Kh6
39.Nxe6 Qd1+ 40.Kh2 Qxa4 (477.616) 402

10.01 0:01 +0.72 33.a4 a5 34.h3 h6 35.Red1 Nd3 36.Ne4 Qd4
37.Rc7 Kf8 (865.452) 450

11.01 0:02 +0.60 33.a4 a5 34.h3 h6 35.Red1 Nd3 36.Ne4 Qd4
37.Rc7 Qe3 38.Rd7 Nc5 39.Ra7 Nd3 (1.114.755) 469

12.01 0:03 +0.60 33.a4 a6 34.Red1 Nd3 35.Ne4 Qd4
36.Rc7 h6 37.Ra7 b5 38.Rd7 Nf2+
39.Nxf2 Qxf2 40.axb5 axb5 (1.683.701) 492

13.01 0:05 +0.48-- 33.a4 a6 34.Rc8+ Kg7 35.Rc7+ Kh6
36.Nf7+ Nxf7 37.Rxf7 Qa3 (2.818.277) 512

13.01 0:08 +0.60 33.a4 a6 34.Red1 Nd3 35.Ne4 Qd4
36.h3 h5 37.Rc6 Qb2 38.Rd6 Nf4
39.R6d2 Qe5 40.Rd8+ Kg7 41.R1d7+ Kh6 (4.249.074) 523

14.01 0:08 +0.52-- 33.a4 a6 34.Red1 Nd3 35.Ne4 Qd4
36.h3 Kg7 37.Rc7+ Kh6 38.g4 g5 (4.479.010) 525

14.08 0:15 +0.68++ 33.Rc8+ Kg7 34.Rec1 Kh6 35.h4 Qd4
36.g3 (7.990.902) 529

14.08 0:15 +0.76++ 33.Rc8+ Kg7 34.Rec1 Kh6 35.h4 Qd4
36.g3 (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d1 Nd3 40.Rd7 Nf4 41.R7d2 Qb5
42.Rd8+ Ke7 (4.653.965.109) 503

27.01 158:14 +2.38++ 33.Rc8+ Kg7 34.Rec1 Qd2 35.R8c7+ Kf8
36.Nxh7+ Ke8 37.Nf6+ Kf8 38.Ne4 Qb2
39.Rd1 Nd3 40.Rd7 Nf4 41.R7d2 (4.793.221.251) 504

27.01 165:24 +2.22-- 33.Rc8+ Kg7 34.Rec1 Qd2 35.R8c7+ Kf8
36.Nxh7+ Ke8 (5.021.549.302) 505

28.01 216:49 +2.30++ 33.Rc8+ Kg7 34.Rec1 Qd2 35.R8c7+ Kf8
36.Nxh7+ Ke8 37.Nf6+ Kf8 38.Ne4 Qe3
39.Rd1 Nd3 40.Rd7 Nc5 41.Nxc5 bxc5
42.Rxa7 (6.645.538.191) 510

28.01 228:12 +2.38++ 33.Rc8+ Kg7 34.Rec1 Qd2 35.R8c7+ Kf8
36.Nxh7+ (6.997.647.052) 511

28.01 249:04 +2.46 33.Rc8+ Kg7 34.Rec1 Qd2 35.R8c7+ Kf8
36.Nxh7+ Kg8 37.Nf6+ Kf8 38.Ne4 Qb2
39.Rd1 Nd3 40.Rd7 Nf4 41.R7d2 Qb5
42.Rd8+ Ke7 43.Rh8 Nd5 44.Rh7+ Kd8
45.Rxa7 Qe2 46.Rg1 (7.668.213.365) 513

29.01 367:44 +2.46 33.Rc8+ Kg7 34.Rec1 Qd2 35.R8c7+ Kf8
36.Nxh7+ Kg8 37.Nf6+ Kf8 38.Ne4 Qb2
39.Rd1 Nd3 40.Rd7 Nf4 41.R7d2 Qb5
42.Rd8+ Ke7 43.Rh8 Nd5 44.Rh7+ Kd8
45.Rxa7 Qe2 46.Rg1 (11.452.048.097) 519


best move: Rc1-c8 time: 485:35.032 min n/s: 511.781 nodes: 14.910.750.143

New code, my new version of ThreatBonus [][] parameters and Ralph's changes to attackedBy[]:

[D]6k1/p6p/1p1qp1p1/4n1N1/8/P4P2/6PP/2R1R2K w - -

Engine: Rainbow Serpent 1.7.1s(dc) Build 048 (Athlon 2009 MHz, 256 MB)
by Tord Romstad, Marco Costalba, Joona Kiiski

1.00 0:00 +1.05 33.Rc8+ (580) 2

2.00 0:00 +1.05 33.Rc8+ Kg7 34.Rc7+ Kh6 (683) 2

3.00 0:00 -0.12 33.Rc8+ Kg7 34.Rc7+ Kh6 35.Nf7+ Nxf7
36.Rxf7 (3.261) 12

3.00 0:00 +0.16 33.a4 Nd3 34.Rc8+ Kg7 35.Rxe6 Qd7
36.Ree8 Qxa4 37.Rc7+ (47.139) 137

4.00 0:00 +0.16 33.a4 Nd3 34.Rc8+ Kg7 35.Rxe6 Qd7
36.Ree8 Qxa4 37.Rc7+ (49.718) 138

5.00 0:00 +0.16 33.a4 Kg7 34.Rcd1 Nd3 35.Nxe6+ Kf6 (74.178) 182

6.00 0:00 +0.24++ 33.a4 Kg7 34.h4 Kh6 35.f4 (98.140) 209

6.00 0:00 +0.32++ 33.a4 Kg7 34.g3 Kh6 35.Rxe5 Qxe5
36.Nf7+ (108.905) 224

6.00 0:00 +0.24 33.a4 Kg7 34.Rcd1 Nd3 35.Nxe6+ Kf6
36.Kg1 Kf5 (110.371) 227

7.00 0:00 +0.24 33.a4 Kg7 34.Rcd1 Nd3 35.Nxe6+ Kf6
36.Kg1 Kf5 (131.204) 246

8.00 0:00 +0.32++ 33.a4 Nd3 34.Rc8+ Kg7 35.Rxe6 Qd7
36.Rec6 Nc5 37.R8c7 (200.517) 305

8.00 0:00 +0.40++ 33.a4 Kg7 34.Rcd1 Nd3 35.Nxe6+ Kf6
36.Kg1 Kf5 37.Re3 (206.820) 307

8.00 0:00 +0.24-- 33.a4 h5 34.Rc8+ Kg7 35.Rc7+ Kh6
36.Nf7+ Nxf7 37.Rxf7 Qd2 (254.029) 338

9.01 0:01 +0.32++ 33.a4 h5 34.Rc8+ Kg7 35.h4 Nd3
36.Rxe6 Qd7 37.Rce8 Qxa4 38.R8e7+ Kh6
39.Nf7+ (419.778) 389

9.01 0:01 +0.40++ 33.a4 h5 34.Rc8+ Kg7 35.h4 Nd3
36.Rxe6 Qd7 37.Rce8 Qxa4 38.R8e7+ Kh6
39.Rh7+ (427.905) 391

9.01 0:01 +0.56++ 33.a4 h5 34.Rc8+ Kg7 35.h4 Nd3
36.Rxe6 Qd7 37.Rce8 Qxa4 38.R8e7+ Kh6
39.Rh7+ (437.480) 394

9.01 0:01 +0.79 33.a4 h5 34.Rc8+ Kg7 35.h4 a6
36.Rc7+ Nd7 37.Rec1 Qd5 38.R1c6 Kh6
39.Nxe6 Qd1+ 40.Kh2 Qxa4 (477.616) 407

10.01 0:01 +0.72 33.a4 a5 34.h3 h6 35.Red1 Nd3 36.Ne4 Qd4
37.Rc7 Kf8 (865.452) 453

11.01 0:02 +0.60 33.a4 a5 34.h3 h6 35.Red1 Nd3 36.Ne4 Qd4
37.Rc7 Qe3 38.Rd7 Nc5 39.Ra7 Nd3 (1.114.755) 472

12.01 0:03 +0.60 33.a4 a6 34.Red1 Nd3 35.Ne4 Qd4
36.Rc7 h6 37.Ra7 b5 38.Rd7 Nf2+
39.Nxf2 Qxf2 40.axb5 axb5 (1.683.701) 494

13.01 0:05 +0.48-- 33.a4 a6 34.Rc8+ Kg7 35.Rc7+ Kh6
36.Nf7+ Nxf7 37.Rxf7 Qa3 (2.818.276) 510

13.01 0:08 +0.60 33.a4 a6 34.Red1 Nd3 35.Ne4 Qd4
36.h3 h5 37.Rc6 Qb2 38.Rd6 Nf4
39.R6d2 Qe5 40.Rd8+ Kg7 41.R1d7+ Kh6 (4.249.073) 522

14.01 0:08 +0.52-- 33.a4 a6 34.Red1 Nd3 35.Ne4 Qd4
36.h3 Kg7 37.Rc7+ Kh6 38.g4 g5 (4.479.009) 523

14.08 0:15 +0.68++ 33.Rc8+ Kg7 34.Rec1 Kh6 35.h4 Qd4
36.g3 (7.990.901) 528

14.08 0:15 +0.76++ 33.Rc8+ Kg7 34.Rec1 Kh6 35.h4 Qd4
36.g3 (8.125.727) 529

14.08 0:15 +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ralph's version} 33.Rc8+ Kg7 34.Rec1 Qd2
35.R8c7+ Kf8 36.Nxh7+ Kg8 37.Nf6+ Kf8
38.Ne4 Qb2 39.Rd1 Nd3 40.Rd7 Nf4 41.R7d2
Qb5 42.Rd8+ Ke7 43.Rh8 Nd5 44.Rh7+ Kd8
45.Rxa7 Qe2 46.Rg1 (851.636.143) 496

25.01 50:28 +2.46 33.Rc8+ Kg7 34.Rec1 Qd2 35.R8c7+ Kf8
36.Nxh7+ Kg8 37.Nf6+ Kf8 38.Ne4 Qb2
39.Rd1 Nd3 40.Rd7 Nf4 41.R7d2 Qb5
42.Rd8+ Ke7 43.Rh8 Nd5 44.Rh7+ Kd8
45.Rxa7 Qe2 46.Rg1 (1.535.150.336) 506

26.01 66:33 +2.38 33.Rc8+ Kg7 34.Rec1 Qd2 35.R8c7+ Kf8
36.Nxh7+ Kg8 37.Nf6+ Kf8 38.Ne4 Qb2
39.Rd1 Nd3 40.Rd7 Nf4 41.R7d2 Qb5
42.Rd8+ Ke7 43.Rh8 Nd5 44.Rh7+ Kd8
45.Rxa7 Qe2 46.Rg1 (2.047.119.894) 512

27.01 198:15 +2.38 33.Rc8+ Kg7 34.Rec1 Qd2 35.R8c7+ Kf8
36.Nxh7+ Kg8 37.Nf6+ Kf8 38.Ne4 Qb2
39.Rd1 Nd3 40.Rd7 Nf4 41.R7d2 Qb5
42.Rd8+ Ke7 43.Rh8 Nd5 44.Rh7+ Kd8
45.Rxa7 Qe2 46.Rg1 (6.011.983.716) 505

28.01 274:31 +2.30-- 33.Rc8+ Kg7 34.Rec1 Kh6 35.h4 Qd4 (8.340.922.977) 506

28.01 471:05 +2.22-- {fail lows not in the other version}33.Rc8+ Kg7 (14.249.041.339) 504

28.01 659:07 +2.46++ 33.Rc8+ Kg7 34.Rec1 Kh6 35.h4 Qd4
36.g3 Nd7 37.R8c7 a5 38.Kg2 Qd5 (19.306.169.115) 488


best move: Rc1-c8 time: 678:45.922 min n/s: 486.400 nodes: 19.809.120.450

Eelco
Debugging is twice as hard as writing the code in the first
place. Therefore, if you write the code as cleverly as possible, you
are, by definition, not smart enough to debug it.
-- Brian W. Kernighan
Ralph Stoesser
Posts: 408
Joined: Sat Mar 06, 2010 9:28 am

Re: Stockfish - material balance/imbalance evaluation

Post by Ralph Stoesser »

Hi Marco,

not so hasty pls. I'm still new to SF. I have already found a major bug. It would not have been possible, if I would not inspect what I try to learn.
mcostalba wrote:
Ralph Stoesser wrote: it would not make any difference whether I include x-ray attacks for queens or not, evaluate_threats() still would not "see" it. That's what I meant.
No, x-ray attacks for queens are used to evaluate mobility not threats.
X-ray attacks would be used for mobility, king safety and threat evaluation. Right?
Ralph Stoesser wrote: Besides evaluate_threats(), queen attacks are especially important in king safety eval.
I would first double check whether it would hurt in king safety to have included x-ray attacks for the queen attacks. Especially the "safe queen contact checks" part seems to be very critical. I will take a look at it tomorrow evening.
I am curious how you "double check" without testing the tweak and verify with real games if it hurts ot not :?:
W.r.t. to king evaluation I see a piece of code that discovers safe queen contact checks and mates. The attackedBy table is used there. I thought it would be worth to look at this issue *thoroughly* before testing something. In case we would collect high bonuses for mate threats where there in fact are none, or more worse, detect queen contact mates, we would face some real mess not worth to test anything. Most likely you already knew it would be not critical, but I prefer to check it myself, anyhow.

To summarize I can spot three parts of the evaluation where x-ray queen attacks would be meaningful.

A) Mobility: Although I think it would probably not hurt, it seems not logical to me to use x-ray attacks for the mobility evaluation. Neither for queens, nor for rooks or bishops. Mobility is the ability to make moves. With my queen on d1 and my rook on d2 I cannot move my queen along the open d-file, because I have my rook in front of my nose.

B) Threats: It would be usefull to see x-ray attacks against week enemy pieces, but the bonuses for x-ray attacks probably should be lesser compared to the bonuses for direct attacks.

C) King eval: Luckily there already is a check for x-ray queen attacks which prevents wrong mate detection. So it seems somebody already had the plan to include x-ray attacks for the queens. Who could that have been?
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: Stockfish - material balance/imbalance evaluation

Post by mcostalba »

Ralph Stoesser wrote:Hi Marco,

not so hasty pls.
:?:

Ralph Stoesser wrote:
A) Mobility: Although I think it would probably not hurt, it seems not logical to me to use x-ray attacks for the mobility evaluation. Neither for queens, nor for rooks or bishops. Mobility is the ability to make moves. With my queen on d1 and my rook on d2 I cannot move my queen along the open d-file, because I have my rook in front of my nose.
I have tested in the past removing x-ray for bishop and rooks and it was weaker. Still untested the queen x-ray attack, test is queued up.

Ralph Stoesser wrote: B) Threats: It would be usefull to see x-ray attacks against week enemy pieces, but the bonuses for x-ray attacks probably should be lesser compared to the bonuses for direct attacks.
Apart from the validity of the idea (impossible to say without testing), I can spot a big performance impact here because mobility evaluation is very heavy and you are suggesting to add a second evaluation that it translates in a second bit counting operation specific for x-ray attack.

Ralph Stoesser wrote: C) King eval: Luckily there already is a check for x-ray queen attacks which prevents wrong mate detection. So it seems somebody already had the plan to include x-ray attacks for the queens. Who could that have been?


I fail to see the code you are referring to.

queen contact checks are currently evaluated with

Code: Select all

      // Analyse safe queen contact checks
      b = undefended & ei.attacked_by(Them, QUEEN) & ~pos.pieces_of_color(Them);
Where the term ei.attacked_by(Them, QUEEN) would be surely influenced by queen x-ray when we will add them.
Ralph Stoesser
Posts: 408
Joined: Sat Mar 06, 2010 9:28 am

Re: Stockfish - material balance/imbalance evaluation

Post by Ralph Stoesser »

mcostalba wrote:
Ralph Stoesser wrote: C) King eval: Luckily there already is a check for x-ray queen attacks which prevents wrong mate detection. So it seems somebody already had the plan to include x-ray attacks for the queens. Who could that have been?


I fail to see the code you are referring to.

queen contact checks are currently evaluated with

Code: Select all

      // Analyse safe queen contact checks
      b = undefended & ei.attacked_by(Them, QUEEN) & ~pos.pieces_of_color(Them);
Where the term ei.attacked_by(Them, QUEEN) would be surely influenced by queen x-ray when we will add them.

There is rather complicated code afterwards. For mate detection we should be safe because of this condition: bit_is_set(pos.attacks_from<QUEEN>(from), to)
Regarding our x-ray matter it translates to "only direct attacks from queens".
line 797.

Code: Select all

// We have a mate, unless the queen is pinned or there
// is an X-ray attack through the queen.
for &#40;int i = 0; i < pos.piece_count&#40;Them, QUEEN&#41;; i++)
&#123;
    from = pos.piece_list&#40;Them, QUEEN, i&#41;;
    if (    bit_is_set&#40;pos.attacks_from<QUEEN>&#40;from&#41;, to&#41;
        && !bit_is_set&#40;pos.pinned_pieces&#40;Them&#41;, from&#41;
        && !&#40;rook_attacks_bb&#40;to, occ & ClearMaskBB&#91;from&#93;) & pos.pieces&#40;ROOK, QUEEN, Us&#41;)
        && !&#40;bishop_attacks_bb&#40;to, occ & ClearMaskBB&#91;from&#93;) & pos.pieces&#40;BISHOP, QUEEN, Us&#41;))

       // Set the mate threat move
       ei.mateThreat&#91;Them&#93; = make_move&#40;from, to&#41;;
&#125;
Ralph Stoesser
Posts: 408
Joined: Sat Mar 06, 2010 9:28 am

Re: Stockfish - material balance/imbalance evaluation

Post by Ralph Stoesser »

mcostalba wrote:
Ralph Stoesser wrote:
A) Mobility: Although I think it would probably not hurt, it seems not logical to me to use x-ray attacks for the mobility evaluation. Neither for queens, nor for rooks or bishops. Mobility is the ability to make moves. With my queen on d1 and my rook on d2 I cannot move my queen along the open d-file, because I have my rook in front of my nose.
I have tested in the past removing x-ray for bishop and rooks and it was weaker. Still untested the queen x-ray attack, test is queued up.
This is interesting. How much weaker was it?

I have a question about testing SF. What are very fast self play games worth w.r.t. eval-only changes? Let's say 1 sec or 5 secs or 10 secs per game. No special hardware involved. 2 years old core duo or something. What are your experiences?
Ralph Stoesser wrote: B) Threats: It would be usefull to see x-ray attacks against week enemy pieces, but the bonuses for x-ray attacks probably should be lesser compared to the bonuses for direct attacks.
Apart from the validity of the idea (impossible to say without testing), I can spot a big performance impact here because mobility evaluation is very heavy and you are suggesting to add a second evaluation that it translates in a second bit counting operation specific for x-ray attack.
No bit counting involved, but yes, extra code for x-rays. I assume therefor you would not like it, unless it would result in a big ELO gain.
Just to clarfiy, generally I totally agree on this attitude.
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: Stockfish - material balance/imbalance evaluation

Post by mcostalba »

Ralph Stoesser wrote: This is interesting. How much weaker was it?
I don't remember...not a lot I would guess.
Ralph Stoesser wrote: I have a question about testing SF. What are very fast self play games worth w.r.t. eval-only changes? Let's say 1 sec or 5 secs or 10 secs per game. No special hardware involved. 2 years old core duo or something. What are your experiences?
Not trustable. At least 1 minute per game.
Ralph Stoesser wrote: No bit counting involved.
Not to be considered hasty ;-) but if you say so it means you have not understood how mobility is evaluated in SF. I would suggest to try to write the patch you are proposing and so verify yourself what I was trying to tell you.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Stockfish - material balance/imbalance evaluation

Post by bob »

mcostalba wrote:
Ralph Stoesser wrote: This is interesting. How much weaker was it?
I don't remember...not a lot I would guess.
Ralph Stoesser wrote: I have a question about testing SF. What are very fast self play games worth w.r.t. eval-only changes? Let's say 1 sec or 5 secs or 10 secs per game. No special hardware involved. 2 years old core duo or something. What are your experiences?
Not trustable. At least 1 minute per game.
I have tens of millions of game that show the exact opposite. For most changes, and for almost all eval changes, very fast games produce similar "spreads" between the old and new version regardless of whether you play 15 sec games or 15 minute game. Some search changes can break this, and whenever you change time allocation code, you have to test different time controls to make sure it doesn't work with one and fail for another. But for eval changes, fast games do work _extremely_ accurately...


Ralph Stoesser wrote: No bit counting involved.
Not to be considered hasty ;-) but if you say so it means you have not understood how mobility is evaluated in SF. I would suggest to try to write the patch you are proposing and so verify yourself what I was trying to tell you.
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: Stockfish - material balance/imbalance evaluation

Post by mcostalba »

bob wrote: I have tens of millions of game that show the exact opposite. For most changes, and for almost all eval changes, very fast games produce similar "spreads" between the old and new version regardless of whether you play 15 sec games or 15 minute game. Some search changes can break this, and whenever you change time allocation code, you have to test different time controls to make sure it doesn't work with one and fail for another. But for eval changes, fast games do work _extremely_ accurately...
Thanks, of course you have much more experience then me and everybody else here !