Check out Modern Chess, our featured variant for January, 2025.


[ Help | Earliest Comments | Latest Comments ]
[ List All Subjects of Discussion | Create New Subject of Discussion ]
[ List Earliest Comments Only For Pages | Games | Rated Pages | Rated Games | Subjects of Discussion ]

Single Comment

Game Courier Tournament #1. A multi-variant tournament played on Game Courier.[All Comments] [Add Comment or Rating]
🕸📝Fergus Duniho wrote on Sun, Feb 22, 2004 08:04 PM UTC:
<P>Time controls are now described in the User's Guide. Here is what the code for checking time presently looks like:</p> <PRE> // Check time // The parameters used for time controls are $sparetime, $gracetime, $extratime, $bonustime, and $bonusperiod. // A record of the times when the game begins and when each player moves are stored in $timeline. // $timestamps is an array of the values in $timeline. // $timeleft is an array of how much time is left for each player. // The values for both these arrays are calculated fresh each time and are not stored in the log. // $yourtime is the amount of time left for the player who is moving. if (!empty($timeline)) { if ($submit == 'Send') { $now = time(); $timeline .= ' {$now}'; // $timeline was previously initialized } $timestamps = explode(' ', $timeline); // 1 = odd number, used for first player // 0 = even number, used for second player $timeleft[0] = $timeleft[1] = $sparetime; $stamps = count($timestamps); for ($i = 1; $i < $stamps; $i++) { $timeused = ($timestamps[$i] - $timestamps[$i-1]); $timeused = max(0, $timeused - $gracetime); $timeleft[$i & 1] -= $timeused; if (($timeleft[$i & 1] < 0) && ($submit == 'Send')) { // First player has run out of time && it is first player's turn := opponent wins // First player has run out of time && it is second player's turn := player wins // Second player has run out of time && it is first player's turn := player wins // Second player has run out of time && it is second player's turn := opponent wins $status = sprintf ('%s has won.', (($i & 1) ^ ($side != $first)) ? $opponent : $player); break; } // The $extratime and $bonustime you get for a move are awarded after your move. // So they do not figure into determining whether you have run out of time. $timeleft[$i & 1] += $extratime; if ($timeused < $bonusperiod) $timeleft[$i & 1] += $bonustime; } $yourtime = ($submit == 'Send') ? $timeleft[($stamps - 1) & 1] : $timeleft[$stamps & 1]; } </pre>