Tapered Eval

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Tapered Eval

Post by bob »

I was just looking at my code while thinking about this. You would also have to maintain two pairs of scores, one for black and one for white if you are going to scale each according to the material for the other side.
Robert Pope
Posts: 558
Joined: Sat Mar 25, 2006 8:27 pm

Re: Tapered Eval

Post by Robert Pope »

bob wrote:I was just looking at my code while thinking about this. You would also have to maintain two pairs of scores, one for black and one for white if you are going to scale each according to the material for the other side.
You aleady do that in Crafty, don't you?

Code: Select all

       +---+---+---+---+---+---+---+---+
    8  |<R>| . |   | . |<K>|<B>|   |<R>|
       +---+---+---+---+---+---+---+---+
    7  | . |<P>|<P>|   | . |   |<P>|   |
       +---+---+---+---+---+---+---+---+
    6  |<P>| . |   | . |<B>|<P>|   |<P>|
       +---+---+---+---+---+---+---+---+
    5  | . |   | . |   | . |<Q>| . |   |
       +---+---+---+---+---+---+---+---+
    4  |   | . |   |-Q-|-N-| . |   | . |
       +---+---+---+---+---+---+---+---+
    3  | . |-P-| . |   | . |   | . |   |
       +---+---+---+---+---+---+---+---+
    2  |-P-|-B-|-P-| . |   | . |-P-| . |
       +---+---+---+---+---+---+---+---+
    1  | . |   | . |-R-|-R-|   |-K-|   |
       +---+---+---+---+---+---+---+---+
         a   b   c   d   e   f   g   h

White&#40;1&#41;&#58; score
note&#58; scores are for the white side
                        +-----------white----------+-----------black----------+
material.......  -1.95  |    comp     mg      eg   |    comp     mg      eg   |
pawns..........  -0.34  |   -0.12   -0.11   -0.17  |   -0.22   -0.19   -0.37  |
passed pawns...   0.00  |    0.00    0.00    0.00  |    0.00    0.00    0.00  |
knights........   0.28  |    0.28    0.28    0.28  |    0.00    0.00    0.00  |
bishops........  -0.43  |    0.27    0.24    0.42  |   -0.70   -0.64   -1.00  |
rooks..........   0.92  |    0.71    0.81    0.34  |    0.21    0.24    0.12  |
queens.........   0.02  |    0.11    0.11    0.11  |   -0.09   -0.09   -0.09  |
kings..........   0.31  |   -0.88   -1.00   -0.40  |    1.19    1.38    0.40  |
development....   0.48  |    0.00    0.00    0.00  |    0.48    0.60    0.00  |
pawn races.....   0.00  +--------------------------+--------------------------+
total..........  -0.69
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Tapered Eval

Post by bob »

Robert Pope wrote:
bob wrote:I was just looking at my code while thinking about this. You would also have to maintain two pairs of scores, one for black and one for white if you are going to scale each according to the material for the other side.
You aleady do that in Crafty, don't you?

Code: Select all

       +---+---+---+---+---+---+---+---+
    8  |<R>| . |   | . |<K>|<B>|   |<R>|
       +---+---+---+---+---+---+---+---+
    7  | . |<P>|<P>|   | . |   |<P>|   |
       +---+---+---+---+---+---+---+---+
    6  |<P>| . |   | . |<B>|<P>|   |<P>|
       +---+---+---+---+---+---+---+---+
    5  | . |   | . |   | . |<Q>| . |   |
       +---+---+---+---+---+---+---+---+
    4  |   | . |   |-Q-|-N-| . |   | . |
       +---+---+---+---+---+---+---+---+
    3  | . |-P-| . |   | . |   | . |   |
       +---+---+---+---+---+---+---+---+
    2  |-P-|-B-|-P-| . |   | . |-P-| . |
       +---+---+---+---+---+---+---+---+
    1  | . |   | . |-R-|-R-|   |-K-|   |
       +---+---+---+---+---+---+---+---+
         a   b   c   d   e   f   g   h

White&#40;1&#41;&#58; score
note&#58; scores are for the white side
                        +-----------white----------+-----------black----------+
material.......  -1.95  |    comp     mg      eg   |    comp     mg      eg   |
pawns..........  -0.34  |   -0.12   -0.11   -0.17  |   -0.22   -0.19   -0.37  |
passed pawns...   0.00  |    0.00    0.00    0.00  |    0.00    0.00    0.00  |
knights........   0.28  |    0.28    0.28    0.28  |    0.00    0.00    0.00  |
bishops........  -0.43  |    0.27    0.24    0.42  |   -0.70   -0.64   -1.00  |
rooks..........   0.92  |    0.71    0.81    0.34  |    0.21    0.24    0.12  |
queens.........   0.02  |    0.11    0.11    0.11  |   -0.09   -0.09   -0.09  |
kings..........   0.31  |   -0.88   -1.00   -0.40  |    1.19    1.38    0.40  |
development....   0.48  |    0.00    0.00    0.00  |    0.48    0.60    0.00  |
pawn races.....   0.00  +--------------------------+--------------------------+
total..........  -0.69
No. I can separate them in the score command, but in the actual evaluation, everything is combined into score_mg and score_eg.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Tapered Eval

Post by bob »

matthewlai wrote:
bob wrote:
matthewlai wrote:
Robert Pope wrote:My current code for game phase is really bulky, so I was looking at what some other programs do. I was reading a description of (I think) Rookie's evaluation, and I noticed that it was basing the game phase on the remaining pieces of the opponent, rather than all pieces. Is this common practice, or is it just as common to use all pieces?

While I was wondering about that, I wandered over to the chess programming wiki, and it appears that Fruit uses all pieces, but pawns have zero impact on the game phase. Did I read that right?
It doesn't really matter in practice.

If there is a significant imbalance in material, the game is probably already won/lost anyways.
It does make the resolution twice as coarse, which has a negative effect.
The steps are also twice as big though, with every exchange.
Good point...

So it really is a "moot point" as to whether you use both sides or just one side.
pijl
Posts: 115
Joined: Mon Sep 17, 2012 8:59 pm

Re: Tapered Eval

Post by pijl »

Not entirely. The things that are probably affected most by the phase scoring are things related to king safety/centralization (there are more but let us just restrict ourselves to these). Whether or not you're centralizing your king or not, or care for attacks on the king are determined more by the opponent material then your own.
When you're clearly up some material that difference is probably not important, but when you do have compensation for the material in a number of pawns (possibly even passers) then it is not that clear anymore.
Another thing is related to autotuning, where you try to define evaluation terms as clean as possible to avoid noise.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Tapered Eval

Post by bob »

pijl wrote:Not entirely. The things that are probably affected most by the phase scoring are things related to king safety/centralization (there are more but let us just restrict ourselves to these). Whether or not you're centralizing your king or not, or care for attacks on the king are determined more by the opponent material then your own.
When you're clearly up some material that difference is probably not important, but when you do have compensation for the material in a number of pawns (possibly even passers) then it is not that clear anymore.
Another thing is related to autotuning, where you try to define evaluation terms as clean as possible to avoid noise.
So you suggest keeping the black and white scores separate, and then scaling them according to the opposite side's material??

BTW, while I scale everything, king safety self-scales as pieces are removed because each piece removed reduces the threats on the king.
pijl
Posts: 115
Joined: Mon Sep 17, 2012 8:59 pm

Re: Tapered Eval

Post by pijl »

bob wrote: So you suggest keeping the black and white scores separate, and then scaling them according to the opposite side's material??
Yes, that is what I do.
mvk
Posts: 589
Joined: Tue Jun 04, 2013 10:15 pm

Re: Tapered Eval

Post by mvk »

bob wrote:Surely you don't mean a different "phase" for each side
A "phase" for each material-dependent term. Not every term responds in the same manner to material changes. The relative piece values are generally not even the same. It would be a miracle if they did.
[Account deleted]
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Tapered Eval

Post by bob »

mvk wrote:
bob wrote:Surely you don't mean a different "phase" for each side
A "phase" for each material-dependent term. Not every term responds in the same manner to material changes. The relative piece values are generally not even the same. It would be a miracle if they did.
I am not convinced that the evaluation is that sensitive to anything, much less the scaling whether it be uniform for all or unique for each positional term.
Ferdy
Posts: 4840
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Tapered Eval

Post by Ferdy »

Robert Pope wrote:
Ferdy wrote:What do you mean by bulky?
In fruit, stage is a simple function of pieces captured. In Abbess, the stage is a lookup of the 1071 possible permutations of pieces on the board: Index=Pawns*63 + Minors*7 + Majors
so that every possible piece combination can have its own stage.
Mine only consider non-pawn material. I use 2 kinds of phase, general game phase, and passer game phase. The general game phase uses all non-pawn, and the passer game phase is specific for passer, it comprises of 2 phases one for white and one for black still non-pawn material. So to increase my passer worth I seek, to reduce my opp pieces, it can be by exchange say my knight vs opp bishop. It reduces my material too actually but I have to be sure that I reduce the opp material, if I use the total material, it could happen that I reduce my material without reducing the opp material and the engine called it progress for passer even though my opp pieces were not reduced. Pawn game phase is also possible and can be applied for 2-bishops for example, as pawn decreases, the 2 bishops bonus increases. Or as pawn phase decreases the knight bonus decreases. Still another is about minor pieces game phase, as minors decreases power of rook increases, say the rook in 7th rank increases as minor decreases. Another example is as bishop decreases the bonus of connected passer increases, because connected passer is not effective against bishops but it is effective against rooks. I think it is not enough to rely on general game phase.