Root score sign flipping

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: Root score sign flipping

Post by Sven »

I think your problem is a different one. At the end of eval() you correctly negate "value" if black is the moving side. So the main part of eval() must assign positive numbers to "value" for something that is good for white and negative numbers for things that are good for black. But you don't do that, what you do is:

Code: Select all

if (tmp & b->sidemask[b->side]) {
    ...
    value += ...
} else {
    ...
    value -= ...
}
which means: if you find a piece of the moving side then you do += else -=. This together with negating if black is to move always leads to an evaluation from white viewpoint which explains your flipping of signs.

So instead it needs to be:

Code: Select all

if (tmp & b->sidemask[WHITE]) {
    ...
    value += ...
} else {
    ...
    value -= ...
}
How to correctly flip "sq" to access your PST I can leave up to you.
ZirconiumX
Posts: 1334
Joined: Sun Jul 17, 2011 11:14 am

Re: Root score sign flipping

Post by ZirconiumX »

Sven Schüle wrote:I think your problem is a different one. At the end of eval() you correctly negate "value" if black is the moving side. So the main part of eval() must assign positive numbers to "value" for something that is good for white and negative numbers for things that are good for black. But you don't do that, what you do is:

Code: Select all

if (tmp & b->sidemask[b->side]) {
    ...
    value += ...
} else {
    ...
    value -= ...
}
which means: if you find a piece of the moving side then you do += else -=. This together with negating if black is to move always leads to an evaluation from white viewpoint which explains your flipping of signs.

So instead it needs to be:

Code: Select all

if (tmp & b->sidemask[WHITE]) {
    ...
    value += ...
} else {
    ...
    value -= ...
}
How to correctly flip "sq" to access your PST I can leave up to you.
If anyone can fix something, I swear it's you. You have magic powers or something...

Sure enough:

Code: Select all

1 90 0 2 b1a3
1 140 0 6 g1f3
1 140 0 42 g1f3
2 30 1 130 b1a3 e7e5
2 35 1 316 b2b4 d7d5
2 40 1 457 d2d3 d7d5
2 50 1 553 d2d4 d7d5
2 50 1 660 d2d4 d7d5
3 100 1 1125 b1a3 e7e5 g1f3
3 120 1 1797 d2d4 d7d5 g1f3
3 120 1 1845 d2d4 d7d5 g1f3
4 15 3 4040 b1a3 e7e5 a3c4 d7d5
4 40 3 5497 a2a4 d7d5 b1c3 e7e5
4 50 3 7639 d2d3 d7d5 b1c3 e7e5
4 50 3 10481 d2d3 d7d5 b1c3 e7e5
5 100 4 15109 b1a3 g8f6 g1f3 d7d6 e2e4
5 130 6 30669 d2d3 g8f6 b1c3 e7e5 g1f3
5 130 6 35732 d2d3 g8f6 b1c3 e7e5 g1f3
6 5 9 54932 b1a3 d7d5 e2e3 c8f5 g1f3 f5c2
6 25 12 82786 c2c3 b8c6 g1f3 g8f6 d2d3 c6d4
6 35 17 115578 d2d3 e7e6 b1c3 f8c5 g1f3 c5f2
6 65 20 141189 d2d4 d7d5 g1f3 c8f5 b1c3 f5c2
6 65 20 164867 d2d4 d7d5 g1f3 c8f5 b1c3 f5c2
7 95 31 234421 b1a3 b8c6 g1f3 g8f6 a3c4 d7d5 d2d4
7 125 48 383038 d2d3 g8f6 b1c3 d7d6 c1e3 c8e6 g1f3
7 140 70 598526 d2d4 g8f6 b1c3 d7d6 g1f3 c8e6 e2e4
7 140 70 626382 d2d4 g8f6 b1c3 d7d6 g1f3 c8e6 e2e4
8 15 128 1097585 b1a3 b8c6 a1b1 g8f6 g1f3 f6e4 a3c4 e4d2
8 25 212 1872857 c2c4 b8c6 b1c3 c6e5 g1f3 e5c4 d2d4 e7e5
8 65 279 2510916 d2d3 b8c6 b1c3 d7d5 g1f3 e7e5 c1e3 f8c5
8 65 279 5181528 d2d3 b8c6 b1c3 d7d5 g1f3 e7e5 c1e3 f8c5
# Iteration limit reached
move d2d3
Man I feel dumb for not realising that.

Matthew:out
Some believe in the almighty dollar.

I believe in the almighty printf statement.
Matthias Hartwich
Posts: 38
Joined: Tue Jul 01, 2008 9:36 pm

Re: Root score sign flipping

Post by Matthias Hartwich »

You still search b1-a3 as first move at every iteration. ;)
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Root score sign flipping

Post by Sven »

In the beginning of your qsearch function you write:

Code: Select all

   if (value > beta)
      return beta;
but for stand-pat it needs to be

Code: Select all

   if (value >= beta)
      return beta;
Furthermore the same bug that I described in my previous post applies to your mobility eval code as well, I hope you already fixed it (...->side to be replaced by WHITE).