list of material combinations requiring specialized eval ?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

MahmoudUthman
Posts: 234
Joined: Sat Jan 17, 2015 11:54 pm

list of material combinations requiring specialized eval ?

Post by MahmoudUthman »

Could you provide me with a list of all material combinations that require specialized evaluation functions , and the general idea/method to correctly evaluate them ?

by the way I'm a weak player 1320 blitz on chess.com , so I almost know nothing about that.
User avatar
hgm
Posts: 27790
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: list of material combinations requiring specialized eval

Post by hgm »

This heavily depends on how smart your normal evaluation is. You benefit from dedicated evaluation in all situations where your normal evaluation is off.

It also depends on what you count as 'specialized eval'. E.g. would you consider scaling normal evaluation scores towards a draw in the absence of mating potential, or when the latter is in jeopardy, a form of specialized eval?

It also depends on what exactly you consider 'different material'. E.g. does the material key distinguish light Bishops from dark Bishops? (If so, this would allow you to apply a scaling for unlike Bishops, but not for like Bishops, purely based on material composition. If not, you would need a specialized eval routine to figure this out from the board position.) Does it distinguish Rook Pawns from other Pawns? And if it does, a-Pawns from h-Pawns?

Normal evaluation usually fails for positions where the 'naively stronger' side has no Pawns, (e.g. KRNKR) or a single Pawn that the opponent can afford to sacrifice a piece for (e.g. KRNPKRB). There should not be too many pieces, though; KQRRBNKQRRB would probably be won despite the fact that you are only a minor ahead, because there is enough opportunity to gain a stronger piece for the Knight: every piece becomes a liability when you are behind in piece material.

Well-known cases where it depends on the exact position are KBPK* and KNPK* with rook Pawns, KRKP and KQKP with advanced Pawns, and KPK. Pawn endings in general could use specialized eval, as for instance the concept of an 'unstoppable passer' becomes of dominant importance there.
PK
Posts: 893
Joined: Mon Jan 15, 2007 11:23 am
Location: Warsza

Re: list of material combinations requiring specialized eval

Post by PK »

Absolute basics are:

- bare kings are draw
- single minor piece (without pawns) cannot win, alone, against pawns or against another minor piece (there are mating positions, but they require cooperation, and can be avoided by search; the same applies to well-known checkmate executed by lone knight against edge pawn)
- two knights against bare king cannot win
- rook against a minor piece is difficult to win, return something like score / 2 or score /4
- rook and a minor piece against rook is hard to win, return something like score / 2 or score / 4

My engine uses a few more rules, see https://github.com/nescitus/Rodent_III/ ... l_draw.cpp

But for a really advanced stuff see https://github.com/B4dT0bi/texel/blob/m ... meEval.cpp
MahmoudUthman
Posts: 234
Joined: Sat Jan 17, 2015 11:54 pm

Re: list of material combinations requiring specialized eval

Post by MahmoudUthman »

hgm wrote: It also depends on what you count as 'specialized eval'. E.g. would you consider scaling normal evaluation scores towards a draw in the absence of mating potential, or when the latter is in jeopardy, a form of specialized eval?
yes, to a certain degree.
hgm wrote: does the material key distinguish light Bishops from dark Bishops? (If so, this would allow you to apply a scaling for unlike Bishops, but not for like Bishops, purely based on material composition. If not, you would need a specialized eval routine to figure this out from the board position.)
wouldn't using 2 material keys be faster the using the board ?
As far as I understand two unlike bishops is drawish so It needs to be scaled down , but what about like bishops wouldn't the normal evaluation be sufficient , I couldn't find anything about them ?
hgm wrote: Does it distinguish Rook Pawns from other Pawns? And if it does, a-Pawns from h-Pawns?
Is this related to bishop endgames too ? or does it extend to other material combinations
User avatar
hgm
Posts: 27790
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: list of material combinations requiring specialized eval

Post by hgm »

Like Bishops are not especially drawish. The cases KBPKB or KBPKBP fall under the rule that the mating potential is in jeopardy, because it depends on a single Pawn and the opponent has material he can sac for it.

End-games that need scaling when white seems ahead:

KBxKBy (unlike Bishops, x and y any number of Pawns with x - y <= 2), divide by 2

* No mating potential (B, N, NN): dead draw. (Possible exception requiring detailed analysis or EGT: KNNKP.)
* Any of the above with 1 Pawn extra for white, and a minor or Rook extra for black (e.g. KNNPKR*, KBPKN*). Divide by 4.
* No Pawns, minor or less ahead in piece material, (i.e. extra minor, exchange ahead, two minors vs Rook ahead, equal), weak side not more than 3 minors, 2 Rooks or 1 Queen. E.g. KQBKQ*, KQBKRR*, KRRNKRR*, KRRKRN*, KRKN*, KBBKR*, KBBNKBN* (* = 0 or more Pawns). Divide by 8. (Possible exception: KBBKN*, divide by 2 or 4.)
* Any of the above with 1 Pawn extra for white, and a minor extra for black (e.g. KRPKBN). Divide by 2.
* More piece material or larger advantage without Pawns, against non-bare King (e.g. KRRKBB*): divide by 2.

And of course everything with reversed colors should betreated similarly.
User avatar
hgm
Posts: 27790
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: list of material combinations requiring specialized eval

Post by hgm »

As for material compositions that need a detailed evaluation, KPK is a good example. A lot of Chess knowledge has to go in this. The minimum required for it to work well is to evaluate the following positions as draw (e.g. divide the score by 8):

E.g. for non-Rook Pawns
* defending King one step in front of the Pawn, and not on last rank.
* defending King two steps in front of the Pawn, and not on move on the last rank if the attacking King stands next to the Pawn.
* defending King opposite to a King standing next to the Pawn, but not on last rank if he has the move.
* attacking King on one of the three squares in front of the Pawn, and the defending King standing two steps in front of the King (attacker to move) or able to step there (defender to move), and not on last rank.
* attacking King on same rank as Pawn, and defending King 4 ranks in front of it, in the path of the Pawn or next to it on the same side as the attacking King.

There are more drawn positions, but they all quickly convert to one of these, or lose the Pawn. The mentioned positions can keep the Pawn advantage for a long time before being forced into a repetition, stalemate or Pawn loss, so the search would not easily see the draw. The important thing is that once you enter a position recognized as draw, the defending side can never be forced out of a recognized drawn position. If he could, the strong side would stall untill he could force the weak side to a non-recognized draw at the horizon, and the search would never be able to see the draw.

Similar arguments hold for KQKP. This is a draw when a Rook or Bishop Pawn is on the 7th rank, supported by its King that also covers the promotion square, while the attacking King is 'sufficiently far' away. This is a pretty important one, because the strong side can fool himself into thinking he is ahead for a very long time before he is forced to repeat, by checking the King from many different locations. And it often occurs from a Pawn ending, when that ends in a promotion race, where one Pawn promotes a turn before the other. You would easily bungle such many Pawn endings if you misevaluate the drawn KQKP positions as winning.
S.Taylor
Posts: 8514
Joined: Thu Mar 09, 2006 3:25 am
Location: Jerusalem Israel

Re: list of material combinations requiring specialized eval

Post by S.Taylor »

MahmoudUthman wrote:Could you provide me with a list of all material combinations that require specialized evaluation functions , and the general idea/method to correctly evaluate them ?

by the way I'm a weak player 1320 blitz on chess.com , so I almost know nothing about that.
I would have thought (in the olden days) that your very question of the thread was highly unlikely from a 1320 player. I would have thought it would take a 2300+ player to be thinking of that question.
AlvaroBegue
Posts: 931
Joined: Tue Mar 09, 2010 3:46 pm
Location: New York
Full name: Álvaro Begué (RuyDos)

Re: list of material combinations requiring specialized eval

Post by AlvaroBegue »

S.Taylor wrote:
MahmoudUthman wrote:Could you provide me with a list of all material combinations that require specialized evaluation functions , and the general idea/method to correctly evaluate them ?

by the way I'm a weak player 1320 blitz on chess.com , so I almost know nothing about that.
I would have thought (in the olden days) that your very question of the thread was highly unlikely from a 1320 player. I would have thought it would take a 2300+ player to be thinking of that question.
Why would you think that? I am rated 1525 and I can probably not only ask, but answer the question. Of course, although I almost never play chess myself, I've been writing computer programs since the 90s.
S.Taylor
Posts: 8514
Joined: Thu Mar 09, 2006 3:25 am
Location: Jerusalem Israel

Re: list of material combinations requiring specialized eval

Post by S.Taylor »

AlvaroBegue wrote:
S.Taylor wrote:
MahmoudUthman wrote:Could you provide me with a list of all material combinations that require specialized evaluation functions , and the general idea/method to correctly evaluate them ?

by the way I'm a weak player 1320 blitz on chess.com , so I almost know nothing about that.
I would have thought (in the olden days) that your very question of the thread was highly unlikely from a 1320 player. I would have thought it would take a 2300+ player to be thinking of that question.
Why would you think that? I am rated 1525 and I can probably not only ask, but answer the question. Of course, although I almost never play chess myself, I've been writing computer programs since the 90s.
Because 1350 players cannot even imagine what computers CAN see and calculate, so how can they claim to be so worried about what computers can still not do tactically?
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: list of material combinations requiring specialized eval

Post by lucasart »

MahmoudUthman wrote:Could you provide me with a list of all material combinations that require specialized evaluation functions , and the general idea/method to correctly evaluate them ?

by the way I'm a weak player 1320 blitz on chess.com , so I almost know nothing about that.
Special eval is a waste of time. Either implement the full solution (syzygy tb), or don't care about this at all.

All I have in Demolito is a couple of scaling rules (general purpose):
* if the winning side has no pawn, and the material difference is less than a rook, half the eval.
* if the winning side has one pawn, and the material difference is less than a rook, reduce eval by a quarter.

I know, these rules are not complete, nor even accurate. But they help enough on average, and each of them was tested and showed a measurable (small) elo gain. On the other hand, none of these special case eval have any mesurable elo gain to show for the additional complexity they bring. There has been countless tests in SF that showed it.

My advice is: don't waste your time with endgame madness as done in SF or Texel. These will make your code much more complicated, with an exponential growth of eval transition problems… For no mesurable gain. Purely cosmetic (ie. only useful if you care about the troll comments on how "your engine is retarded because it doesn't show 0.00 in this in this obvious draw").

Maybe I'll add syzygy to Demolito one day. But it's a lot pf woro, for little reward. SF implementation is unusable, because heavily intertwined with SF, and heavy on C++. Fathom is a mess, and I dont want to add illegible and messy code to my engine, because I will have to maintain this mess… So I'm not in a hurry to look at TB.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.