Implementing Contempt For The Draw

Discussion of chess software programming and technical issues.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Post Reply
ChessRenewal
Posts: 5
Joined: Thu Jul 25, 2019 5:13 pm
Full name: Jay Warendorff

Implementing Contempt For The Draw

Post by ChessRenewal » Sun Jul 26, 2020 10:41 pm

I am writing a C language chess engine using FirstChess as a base. Please provide some insight on how to implement Contempt For The Draw in the code.

odomobo
Posts: 78
Joined: Thu Jul 05, 2018 11:09 pm
Location: Chicago, IL
Full name: Josh Odom

Re: Implementing Contempt For The Draw

Post by odomobo » Mon Jul 27, 2020 6:51 am

It doesn't look like FirstChess will evaluate a draw for repetition or 50 move rule, so it will actually blindly stumble into those without realizing they terminate the game. The only draw FirstChess can see is stalemate, which I see on line 623.

For contempt, there are 2 things to take into account.
  1. The draw value changes sign depending on which color the engine is playing as.
  2. Since Search() is negamax, draw value also changes sign depending on which color is currently being evaluated.
So let's say you have contempt of 20 centipawns. This mean the engine views a draw the same as if it was down by 20 centipawns. In absolute terms, if the engine was white, it would give the position an evaluation of -20 centipawns.

However, within a negamax search, score is always given from the perspective of the side being evaluated (so if it's black's turn, a positive value means black's winning). So, if the engine is playing as white, and black gets stalemated, then it needs to be evaluated as +20 centipawns.

Post Reply