Ippolit and contempt.

Code, algorithms, languages, construction...
carotino
Posts: 8
Joined: Mon Feb 20, 2012 11:30 am
Real Name: Roberto Munter

Ippolit and contempt.

Post by carotino » Sun Dec 22, 2013 10:07 pm

This is a feature absent on the "Ippolits".
There exists a couple of variables in Evaluation.c: wDrawWeight and bDrawWeight, but they are (I think) unused.

In Fire, the author has added a simple multiplier:

Value -= (PAWN_INFO->wDrawWeight * MIN (Value, 100)) / 64 * DrawWeight / 100;

This, however, seems to me a very small thing....
No one has ever thought to implement a function of "contempt" in the Ippolits? Are there any plans or proposals?

Thx in advance,
Roberto.

carotino
Posts: 8
Joined: Mon Feb 20, 2012 11:30 am
Real Name: Roberto Munter

Re: Ippolit and contempt.

Post by carotino » Mon Dec 23, 2013 10:01 am

This is the result of Deep Saros in the first round of a tournament (Don Daley Tribute, by Graham Banks):

7. DEEPSAROS 4.1.4 64-BIT 8CPU 15 7.5 = 0 1 0 1 0 * = = = = = = 1 = =

He fought well against the best (tied with Houdini, lost against Stockfish and Critter, won against Rybka and Komodo), but against the weaker engines have picked up only a series of draws... How many points wasted!

Here, however, the results of Rybka in the same tournament.

3. RYBKA 4.1 64-BIT 8CPU 15 10.0 = = * = 1 = 0 1 = = = 1 1 = 1 1

His results against stronger engines, are worse than those of Saros, but he has won almost all the games against the weaker engines.
The result is that Rybka is now in 3rd place, while Saros is 7th place.
A proper function of contempt, makes the difference!

velmarin
Posts: 39
Joined: Thu Mar 17, 2011 11:31 am
Real Name: Jose Mº Velasco

Re: Ippolit and contempt.

Post by velmarin » Mon Dec 23, 2013 2:46 pm

My engine also has serious problems with too many draws.

I'm researching at the end of evaluation, when we send the Score to the search, very simply like this:
if (Position->white_to_move && Value == 0) // 7 may be an option UCI
{
Value += 7;// if Score PV is +0.04, now is +0.11
}
if (!Position->white_to_move && Value == 0)
{
Value -= 7; // if Score PV is -0.04, now is -0.11
}
or, beginning to complicate:
if (Position->white_to_move && Value == 0)
{
Value += 7;// if Score PV is +0.04, now is +0.11
}
if (Position->white_to_move && Value >= 12)
{
Value += 7; // if Score PV is +0.12, now is +0.19
}
ect, ect.
This makes something, but you can add parameters.
Also would be interesting to work three repetitions, not to fall too much.

Greetings, Jose.

carotino
Posts: 8
Joined: Mon Feb 20, 2012 11:30 am
Real Name: Roberto Munter

Re: Ippolit and contempt.

Post by carotino » Mon Dec 23, 2013 7:20 pm

Thx Josè,
is an interesting idea. Someone also suggested to run an 'asymmetric contempt' on the King_safety. This would make the engine very aggressive ... Although the risk is high.

lucasart
Posts: 201
Joined: Mon Dec 17, 2012 1:09 pm
Contact:

Re: Ippolit and contempt.

Post by lucasart » Tue Dec 24, 2013 5:49 am

carotino wrote:This is a feature absent on the "Ippolits".
There exists a couple of variables in Evaluation.c: wDrawWeight and bDrawWeight, but they are (I think) unused.

In Fire, the author has added a simple multiplier:

Value -= (PAWN_INFO->wDrawWeight * MIN (Value, 100)) / 64 * DrawWeight / 100;

This, however, seems to me a very small thing....
No one has ever thought to implement a function of "contempt" in the Ippolits? Are there any plans or proposals?

Thx in advance,
Roberto.
I never really looked at Ippolit's code (because it's illegible). But contempt=draw score is not a feature of the eval. It's normally done by the search. It is the search that detects draws by chess rules (3-rep, 50 move, stalemate, insufficient material). So it's in the search that you score them -Contempt for the root color (ie. the engine) and +Contempt for the non root color (ie. the opponent).

I made some experiments with contempt a while ago. What comes out of it is that it does not hurt to have a default contempt (provided it's not too big). It mostly prevents repetition draws when the otherwise eval is close enough to zero. That way engines play until death rather than accept a draw without fighting. I much prefer it that way (I hate unsought repetition draws)
viewtopic.php?f=5&t=2321

An extreme variation would be to score draws as mates. Which is equivalent to Contempt = +infinity. There is probably not much elo loss in doing it, but you would have the most stubborn engine, ever, like that.
"Talk is cheap. Show me the code." -- Linus Torvalds.

carotino
Posts: 8
Joined: Mon Feb 20, 2012 11:30 am
Real Name: Roberto Munter

Re: Ippolit and contempt.

Post by carotino » Tue Dec 24, 2013 7:20 am

I fully agree: the code of Ippolit is a damned tangle! :)

I like your idea of 'extreme contempt' (same value as the mate)...

hyatt
Posts: 1242
Joined: Thu Jun 10, 2010 2:13 am
Real Name: Bob Hyatt (Robert M. Hyatt)
Location: University of Alabama at Birmingham
Contact:

Re: Ippolit and contempt.

Post by hyatt » Tue Dec 24, 2013 8:45 pm

carotino wrote:I fully agree: the code of Ippolit is a damned tangle! :)

I like your idea of 'extreme contempt' (same value as the mate)...

You should test it. :) You will NOT get what you expect to get. You will get almost 100% draws, except for the losses. Mostly due to repetition when you COULD force mate, but since repeat = mate, that happens easier.

carotino
Posts: 8
Joined: Mon Feb 20, 2012 11:30 am
Real Name: Roberto Munter

Re: Ippolit and contempt.

Post by carotino » Tue Dec 24, 2013 11:58 pm

Oh, this is also true... Well, never mind.
I will try the idea of ​​José, by the method of Houdini: high contempt in the opening, and lighter in middle-game, but not now.
Now I wish you all a happy Christmas and a peaceful New Year.
Ad majora!

BB+
Posts: 1484
Joined: Thu Jun 10, 2010 4:26 am

Re: Ippolit and contempt.

Post by BB+ » Sat Jan 04, 2014 5:44 am

There exists a couple of variables in Evaluation.c: wDrawWeight and bDrawWeight, but they are (I think) unused.
These come from the pawn structure, and are folded into the eval:

Code: Select all

if (Value > 0) Value -= (PAWN_INFO->wDrawWeight * MIN (Value, 100)) / 64;
  else Value += (PAWN_INFO->bDrawWeight * MIN (-Value, 100)) / 64;

Code: Select all

static uint8 OpposingPawnsMult[9] = { 6, 5, 4, 3, 2, 1, 0, 0, 0 };
static uint8 PawnCountMult[9] = { 6, 5, 4, 3, 2, 1, 0, 0, 0 };

Code: Select all

  RESULT->wPfile_count = POPCNT (T); // number of file with a white pawn
  RESULT->bPfile_count = POPCNT (U); // number of files with a black pawn
  RESULT->OpenFileCount = 8 - POPCNT (T | U); // this *does* seems to be unused though
  RESULT->wDrawWeight = OpposingPawnsMult[POPCNT (T & ~U)] * PawnCountMult[RESULT->wPfile_count];
  RESULT->bDrawWeight = OpposingPawnsMult[POPCNT (U & ~T)] * PawnCountMult[RESULT->bPfile_count];
However, this has nothing to do with contempt per se, it seems to have more to do with drawishness of pawn structure vis-a-vis symmetry (the Rybka 3 method is not exactly comparable).

mdannib
Posts: 7
Joined: Thu Aug 19, 2010 12:20 pm
Real Name: Matteo

Re: Ippolit and contempt.

Post by mdannib » Wed Jan 08, 2014 9:31 pm

velmarin wrote:My engine also has serious problems with too many draws.

I'm researching at the end of evaluation, when we send the Score to the search, very simply like this:
if (Position->white_to_move && Value == 0) // 7 may be an option UCI
{
Value += 7;// if Score PV is +0.04, now is +0.11
}
if (!Position->white_to_move && Value == 0)
{
Value -= 7; // if Score PV is -0.04, now is -0.11
}
or, beginning to complicate:
if (Position->white_to_move && Value == 0)
{
Value += 7;// if Score PV is +0.04, now is +0.11
}
if (Position->white_to_move && Value >= 12)
{
Value += 7; // if Score PV is +0.12, now is +0.19
}
ect, ect.
This makes something, but you can add parameters.
Also would be interesting to work three repetitions, not to fall too much.

Greetings, Jose.
Carotino i use a similar approach inside BlackMamba but with an array like this

Code: Select all

static const int ContemptValue[32] = 
	{20,20,19,19,18,18,17,17,17,16,16,15,15,14,14,13,13,13,12,12,11,11,10,10,10,9,9,8,8,7,7,6}
and use the code

Code: Select all

if (Position->white_to_move && Value == 0)
	{
		Value += ContemptValue[phase];
	}
	if (!Position->white_to_move && Value == 0)
	{
		Value -= ContemptValue[phase];
	} 
;)

/Matteo

Post Reply