Page 1 of 1

How to make a scalable clock implementation

Posted: Wed Sep 19, 2012 6:38 am
by kevinfat
How do chess servers keep track of time for all the games being played. There could potentially be many games where the clock runs down to 0 for one side and the server needs to check for that. A direct approach such as trying to check for that condition for all the games as fast as possible seems like it wouldn't scale to handling many many games. I was wondering if there was a standard implementation for this and what do real chess servers do in practice?

Re: How to make a scalable clock implementation

Posted: Wed Sep 19, 2012 2:50 pm
by hyatt
kevinfat wrote:How do chess servers keep track of time for all the games being played. There could potentially be many games where the clock runs down to 0 for one side and the server needs to check for that. A direct approach such as trying to check for that condition for all the games as fast as possible seems like it wouldn't scale to handling many many games. I was wondering if there was a standard implementation for this and what do real chess servers do in practice?
You run an application on each computer that is participating. that application measures the amount of time that passes from the point where the opponent's move arrives locally until your move is sent. It reports that time to the server which eliminates the network lag (delays) one sees regularly. it is actually more complex than that, but that's the basic idea...

As far as actually detecting this, chess servers don't really call "game over". That's up to the end user. Or the end-user's gui (autoflag in xboard, for example). They do verify the claim that the flag has fallen, of course.

Re: How to make a scalable clock implementation

Posted: Thu Sep 20, 2012 1:45 am
by kevinfat
hyatt wrote:
kevinfat wrote:How do chess servers keep track of time for all the games being played. There could potentially be many games where the clock runs down to 0 for one side and the server needs to check for that. A direct approach such as trying to check for that condition for all the games as fast as possible seems like it wouldn't scale to handling many many games. I was wondering if there was a standard implementation for this and what do real chess servers do in practice?
You run an application on each computer that is participating. that application measures the amount of time that passes from the point where the opponent's move arrives locally until your move is sent. It reports that time to the server which eliminates the network lag (delays) one sees regularly. it is actually more complex than that, but that's the basic idea...

As far as actually detecting this, chess servers don't really call "game over". That's up to the end user. Or the end-user's gui (autoflag in xboard, for example). They do verify the claim that the flag has fallen, of course.
What happens if the user who is about to win on time loses their internet connection. Then they aren't there to claim the flag has fallen. What happens on the chess server then?

Re: How to make a scalable clock implementation

Posted: Thu Sep 20, 2012 10:54 pm
by hyatt
kevinfat wrote:
hyatt wrote:
kevinfat wrote:How do chess servers keep track of time for all the games being played. There could potentially be many games where the clock runs down to 0 for one side and the server needs to check for that. A direct approach such as trying to check for that condition for all the games as fast as possible seems like it wouldn't scale to handling many many games. I was wondering if there was a standard implementation for this and what do real chess servers do in practice?
You run an application on each computer that is participating. that application measures the amount of time that passes from the point where the opponent's move arrives locally until your move is sent. It reports that time to the server which eliminates the network lag (delays) one sees regularly. it is actually more complex than that, but that's the basic idea...

As far as actually detecting this, chess servers don't really call "game over". That's up to the end user. Or the end-user's gui (autoflag in xboard, for example). They do verify the claim that the flag has fallen, of course.
What happens if the user who is about to win on time loses their internet connection. Then they aren't there to claim the flag has fallen. What happens on the chess server then?

Depends. Normally, when one side disconnects, the game is stopped and saved. It can be resumed when they both are online. If you use the "set noescape=1" option on ICC, if you disconnect, you instantly lose the game...