Why is Checkmate +318 or -318 in analysis

Sort:
MrMythicalYT
Why is it like this? I analyze my games and it says +318/-318 when I am on checkmate
notmtwain
MrMythicalYT wrote:
Why is it like this? I analyze my games and it says +318/-318 when I am on checkmate

https://www.reddit.com/r/chess/comments/ioldx9/why_do_chess_engines_evaluate_checkmate_at_3180/g4gtntk

jonnin

That link is not very accurate.   Its been a long long time since integer was default 16 bits.  You can use a 16 bit int, but you have to force the issue unless its using an antique platform.   Its a mess due to various reasons... back in the day sizeof(int) was the size of the cpu registers, but they have not been moved up to 64 bit because it is often a waste of {space and time} to shove the extra 4 bytes over the bus or store it in memory when you were not using large values.  

you can however specify the size, so you *can* use 16 bit, uint16_t or 'short' or similar names.  But 'int' or 'integers' are 32 bit on anything newer than a pentium (and even the 386 had 32 bit registers, but the OS and tools were still 16 bit). 

 

However,  its a good explanation if they did actually use 16 bit, which may have some performance merits. 

notmtwain

I will post it here for future reference:

An engine only evaluates in numbers, "mate in 4" doesn't mean anything to an engine, so in order to represent mate you need to pick a number.

So why 318?

First we need to understand a few basics:

  1. Decimals is not nice in any programming environment (rounding errors are very dangerous, and with billions of lines they add up) so we will store evaluation in integer numbers

  2. Since we don't want decimals the value of e.g. a pawn can't be 1 (then we couldn't represent 0.5 pawns), so to get parts of a value of a pawn the most common representation is centipawn, meaning a full pawn is 100 and half pawn is 50 and so on. This gives enough granularity.

  3. This means that reasonable evaluations would range from say -10000 to +10000, maybe more if one side has a few extra queens etc.

  4. Now we have to store the evaluation in a data type that can fit the centipawn evaluation with some margin, but not too much margin (no point wasting memory). In C a signed integer goes from - 32,768 to +32,767 so that should do nicely.

  5. Since mate needs to be higher than any crazy combined evaluation, we pick a number close to the highest range we have. In this case around 32000.

  6. The engine evaluation is for readability given in full pawns (so the number divided by 100). Meaning a mate would be something like 320.0

Now we're very close to 318, and for some engines it's actually 320 that's the number given (and for others it's the integer max, but it's more common that it's rounded to a nicer number).

To get to 318 we can continue on a bit:

  1. We need some room to allow for faster mates being worth more. So we start at 32000 which would be mate in one, 31999 mate in two and so on.

  2. So what is a mate and what is a just a really high evaluation. It's semantics (they should never be mixed in reality) but it's the mate in one score (32000) minus the max search depth (this is usually defined to stop the engine if there's a bug that goes on forever). The max depth could be defined as 200 (a high number that should never be reached).

  3. If 200 is the max search depth it turns out 31800 is the lowest number that is still a mate (and not just a high evaluation). So if we just want to say, this is a mate of some kind and we don't want to promise how quick, 31800 is probably the best representation.

  4. And in full pawn representation we arrive at 318.0

Hope that helps. :)

TandAC

Sometimes you evaluate mate as +318.0 and sometimes as +0.0.      What is the. Distinction?

BigParsley

The maximum I had in evaluations was once, +99.

And after a while it changed to mate in 12 or something like that.

Where do you see the+318?

 

TandAC

Big parsley,

on the iPhone, once you mate your computer opponent  the numbers   +318.0  or +0.0 appear on the far right side of the scree  underneath the white horizontal  stripe that says “Checkmate “.   +318.0  appears far more frequently