Does the chess.com engine check for checkmate at every move?

Sort:
dileepkottilil

I wonder how the algorithm of chess.com works. Logically, at every move, the chess.com algorithm should check for a checkmate during the game. But then that takes a fraction of time. Is there any chance that the other person wins on time within this checkmate-checking-time (especially in a 1 min game)? 

NichtGut

Why should it check for checkmate everytime, specially if the piece moved does not attack the king? 

dileepkottilil

Then the algorithm should check whether the piece is attacking the king or not, and if it attacks it should check for a checkmate. It seems it takes longer now

happy.png 

NichtGut

Leave "algorithms" to the professionals (not me) kid. 

 

How do you think a computer looks for checkmate, it just doesnt look at the board and say "Oh, checkmate!". You want the "algorithm" to check if the king has any legal moves and if it is under attack whenever a move is made.

My method suggests only checking if the king has any legal moves or ways to capture the attacking piece when its under attack. 

 

Whose method takes longer now?

Do you want the computer to look for checkmate when 1.e4 is played?

Shock_Me
NichtGut wrote:

Why should it check for checkmate everytime, specially if the piece moved does not attack the king? 

Because the piece that just moved might not be the one giving check, i.e. discovered check. Certainly, the engine performs a test of checkmate every move (perhaps not if still in opening book, but that seems needlessly complicated) which would logically begin with a test of whether or not the king is in check and if not, return 'false'. 
It's a peculiar thing to be concerned about whether one might lose in the (several microseconds?) that a checkmate test would take as this is only one of many housekeeping tasks that need to be accomplished each move. The engine might well pause your timer while this happens, but again the actual time involved is insignificant. 

NichtGut
Shock_Me hat geschrieben:
NichtGut wrote:

Why should it check for checkmate everytime, specially if the piece moved does not attack the king? 

Because the piece that just moved might not be the one giving check, i.e. discovered check. Certainly, the engine performs a test of checkmate every move (perhaps not if still in opening book, but that seems needlessly complicated) which would logically begin with a test of whether or not the king is in check and if not, return 'false'. 
It's a peculiar thing to be concerned about whether one might lose in the (several microseconds?) that a checkmate test would take as this is only one of many housekeeping tasks that need to be accomplished each move. The engine might well pause your timer while this happens, but again the actual time involved is insignificant. 

That is right, instead of the piece attacking it should check whether the king is attacked or not. Checking whether the king is attacked or not is not the same as checking for checkmate every move. I also thought the engine could pause the timer but as you said is insignificant when you consider premoves on bullet take one tenth of a second.

forked_again

I don't think checking for check mate is different than the normal function of looking for the best move.  Of course your Kings safety and the computer Kings safety has to be known to know the best move.

dileepkottilil
Shock_Me wrote:
NichtGut wrote:

Why should it check for checkmate everytime, specially if the piece moved does not attack the king? 

Because the piece that just moved might not be the one giving check, i.e. discovered check. Certainly, the engine performs a test of checkmate every move (perhaps not if still in opening book, but that seems needlessly complicated) which would logically begin with a test of whether or not the king is in check and if not, return 'false'. 
It's a peculiar thing to be concerned about whether one might lose in the (several microseconds?) that a checkmate test would take as this is only one of many housekeeping tasks that need to be accomplished each move. The engine might well pause your timer while this happens, but again the actual time involved is insignificant. 

Yes! That's what I meant! A checkmate test at every move (Maybe it is just that I used a bit different way to explain the same) is needed. I was pretty sure about this checkmate test when I asked about it. But I was not sure about the winning chance of the other person during this time. But as you said, the engine should pause the clock for this fraction of time. Thanks!

dileepkottilil
NichtGut wrote:

My method suggests only checking if the king has any legal moves or ways to capture the attacking piece when its under attack. 

 

Making an engine to check whether your king has any legal moves or not, will take several lines (?) of code to run (It's like running a certain piece of code when a condition satisfies. But then that test should be executed at every move). That's what I said. Anyway, I liked it when you called me a kid! It is good to be a kid. Right? tongue.png 

Shock_Me

I could have been more clear, an implicit checkmate test is necessary for every move. The computer must generate a list of legal moves from which to evaluate and select the best.  None of the potential moves that place or leave the king in check are legal. So the computer needs to determine 1) are there any legal moves and 2) is the king in check. If the answer to #1 is yes, then the best move is selected. If the answer to #1 is no, then the game is lost if #2 is true, and stalemated/drawn if false. The order in which the questions are asked could go either way, depending on the implementation. Regardless, the computer should be thinking on its own time, no matter how short that is.

Preggo_Basashi
dileepkottilil wrote:

I wonder how the algorithm of chess.com works. Logically, at every move, the chess.com algorithm should check for a checkmate during the game. But then that takes a fraction of time. Is there any chance that the other person wins on time within this checkmate-checking-time (especially in a 1 min game)? 

If it checks for checkmate before it checks for zero time, then it wouldn't matter.

And if moves are time stamped, then that would also be a work around.

In any case, seems like something any programmer would be sure to guard against i.e. losing on time after checkmating someone.

Preggo_Basashi
Shock_Me wrote:

I could have been more clear, an implicit checkmate test is necessary for every move. The computer must generate a list of legal moves from which to evaluate and select the best.  None of the potential moves that place or leave the king in check are legal. So the computer needs to determine 1) are there any legal moves and 2) is the king in check. If the answer to #1 is yes, then the best move is selected. If the answer to #1 is no, then the game is lost if #2 is true, and stalemated/drawn if false. The order in which the questions are asked could go either way, depending on the implementation. Regardless, the computer should be thinking on its own time, no matter how short that is.

He's not talking about engines, he asking about chess.com.

For example when you run out of time, chess.com ends the game in a loss for you.

If you give checkmate, then the chess.com ends the game as a win for you.

He's asking about when you preform mate with very little time left.

NichtGut

Its called an if condition and I think it would make more sense to check first whether the king is in check or not. Sometimes kings do not have any legal moves but are not in check either.

Preggo_Basashi

Yeah, that was my first thought. If the king isn't in check it doesn't have to go into the lines of code that verify checkmate. You pointed this out a few days ago.

NichtGut

But people ignored it and thought of me as some random dude that cant tell C from Java, WHICH HURT MY EGO A LOT sad.png

Preggo_Basashi

They've probably never heard of Java and have no idea what you're talking about, so don't take it badly grin.png

Shock_Me
Preggo_Basashi wrote:
Shock_Me wrote:

I could have been more clear, an implicit checkmate test is necessary for every move. The computer must generate a list of legal moves from which to evaluate and select the best.  None of the potential moves that place or leave the king in check are legal. So the computer needs to determine 1) are there any legal moves and 2) is the king in check. If the answer to #1 is yes, then the best move is selected. If the answer to #1 is no, then the game is lost if #2 is true, and stalemated/drawn if false. The order in which the questions are asked could go either way, depending on the implementation. Regardless, the computer should be thinking on its own time, no matter how short that is.

He's not talking about engines, he asking about chess.com.

For example when you run out of time, chess.com ends the game in a loss for you.

If you give checkmate, then the chess.com ends the game as a win for you.

He's asking about when you preform mate with very little time left.

you are correct. my brain was wandering. 

NichtGut
Preggo_Basashi hat geschrieben:

They've probably never heard of Java and have no idea what you're talking about, so don't take it badly

Thanks, that was the EGO boost I needed.

cellomaster8
I know Java 😀
dileepkottilil
NichtGut wrote:
Preggo_Basashi hat geschrieben:

They've probably never heard of Java and have no idea what you're talking about, so don't take it badly

Thanks, that was the EGO boost I needed.

You know, you made this discussion thread worth reading!! Thanks dude..

Guest7628664637
Please Sign Up to comment.

If you need help, please contact our Help and Support team.