How to make a scalable clock implementation

Code, algorithms, languages, construction...
Post Reply
kevinfat
Posts: 13
Joined: Tue Aug 09, 2011 3:42 am

How to make a scalable clock implementation

Post by kevinfat » Wed Sep 19, 2012 6:38 am

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?

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: How to make a scalable clock implementation

Post by hyatt » Wed Sep 19, 2012 2:50 pm

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.

kevinfat
Posts: 13
Joined: Tue Aug 09, 2011 3:42 am

Re: How to make a scalable clock implementation

Post by kevinfat » Thu Sep 20, 2012 1:45 am

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?

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: How to make a scalable clock implementation

Post by hyatt » Thu Sep 20, 2012 10:54 pm

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...

Post Reply