Discussion of chess software programming and technical issues.
Moderators: hgm, Harvey Williamson, bob
Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
-
Robert Pope
- Posts: 392
- Joined: Sat Mar 25, 2006 7:27 pm
Post
by Robert Pope » Thu Aug 06, 2015 12:13 pm
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.
That is obviously bad, because I don't have adequate data to tune every combination. But at the same time, I disagree with a simple subtraction of pieces -- how much a Knight loss changes the phase should be different if you have only 5 pieces left than if it is in the first 5 moves. Also, you should be in 100% endgame well before you are down to K vs. K. So, I want to switch to something formula driven, but more tunable than just the parameters in Fruit.
-
bob
- Posts: 20342
- Joined: Mon Feb 27, 2006 6:30 pm
- Location: Birmingham, AL
Post
by bob » Thu Aug 06, 2015 12:39 pm
mvk 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 is a bug to use the sum of pieces instead of opponent pieces. Think of king safety and passers. But it is a bug of the same order of magnitude as, say, worrying about opposite square colors for the bishop pair bonus: one of zero practical impact, if you consider winning or losing games. Many programs now copy the Fruit design with score tuples, and for that you need one scalar game phase. You don't need to follow.
Wether or not to ignore pawns is also rather arbitrary. The tuner will resolve any differences.
Surely you don't mean a different "phase" for each side, since evaluation has to cover both sides? I don't see how this would be a "bug" at all. And doing it twice would have some computational cost.
If the piece counts are different for the two sides, I doubt the phase scaling matters much anyway, the game is already out of hand most of the time.
-
bob
- Posts: 20342
- Joined: Mon Feb 27, 2006 6:30 pm
- Location: Birmingham, AL
Post
by bob » Thu Aug 06, 2015 1:52 pm
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: 392
- Joined: Sat Mar 25, 2006 7:27 pm
Post
by Robert Pope » Thu Aug 06, 2015 2:07 pm
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(1): score
note: 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: 20342
- Joined: Mon Feb 27, 2006 6:30 pm
- Location: Birmingham, AL
Post
by bob » Thu Aug 06, 2015 2:38 pm
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(1): score
note: 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: 20342
- Joined: Mon Feb 27, 2006 6:30 pm
- Location: Birmingham, AL
Post
by bob » Thu Aug 06, 2015 2:39 pm
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: 72
- Joined: Mon Sep 17, 2012 6:59 pm
Post
by pijl » Thu Aug 06, 2015 8:15 pm
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: 20342
- Joined: Mon Feb 27, 2006 6:30 pm
- Location: Birmingham, AL
Post
by bob » Thu Aug 06, 2015 9:13 pm
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: 72
- Joined: Mon Sep 17, 2012 6:59 pm
Post
by pijl » Thu Aug 06, 2015 9:41 pm
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 8:15 pm
Post
by mvk » Thu Aug 06, 2015 9:41 pm
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]