Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Strange programming problem

Author: Dann Corbit

Date: 17:02:00 05/30/02

Go up one level in this thread


On May 30, 2002 at 19:25:26, William H Rogers wrote:

>In the last CCC4 tournement, the time controls were set to one minute per move.
>Currently my program only searches to fixed ply depths, so I tried to put in
>time controls. In the place where the program looks to see if the ply-max has
>been reached, I put in a time limit. The limit works and the program stops
>searching and makes a move at the right time. The problem is this, it never
>seems to make the same move that it would have if it had used the ply-max cutoff
>instead. Quite often the moves are different, and I can not say at this time if
>they are better or worse. Is this a normal situation or do I need to do
>something different?

Here is Beowulf's approach to time control:

/* Get the initial suggested base time limit per move in an
 * xboard game with fixed time controls. */
void            GetTimeLimit(void)
{
    int             left;
    int             oleft,
                    tpts = Current_Board.WPts + Current_Board.BPts;
    float           mvleft;

    /* Get how much time we have to play with, and how much our opponent has */
    left = Params.Time;
    oleft = Params.OTime;

    /* If we know the number of moves per time control, then work out how
     * many we have left to play.  Otherwise, estimate the average game is
     * about GAME_LENGTH moves long. Assume also that we're probably going to
     * have to play about another MIN_LEFT moves minimum from any position,
     * unless we're playing a certain number of moves per time control.  We
     * should also take into account that we might need to spend a bit longer
     * occasionally because of blunder avoidance */
    if (Params.Mps != 0) {
        mvleft = (float) (Params.Mps + 1 - ((mvno / 2) % Params.Mps));
        /* If we have several moves left then allocate a slight buffer of
         * time in case we have to extend a search later because of blunder
         * avoidance. */
        if (mvleft > 1)
            mvleft *= 1.1;
    } else {
        mvleft = (float) ((GAME_LENGTH * 2) - mvno) / 2.0;
        if (mvleft < (float) MIN_LEFT)
            mvleft = (float) MIN_LEFT;
    }

    /* If we're down on time compared to our opponent then reduce time per
     * move */
    if (oleft > left && mvleft > 10.0)
        mvleft++;

    /* If we're in the opening still then spend more time per move */
    if (tpts > 70 && mvleft > 10.0)
        mvleft--;

    /* Set the suggested thinking time */
    Params.MoveTime = (float) left / (mvleft * 100.0);
    /* If we have 8 seconds left or less then move as fast as possible,
     * provided we're not playing in a time-per-session game */
    if (left < 800 && Params.Mps == 0) {
        Params.MoveTime = 0.0;
        bRushed = TRUE;
    }
    /* If we're playing with a time increment per move then factor in the
     * extra time we have  If this is more than the available time then it'll
     * get trapped in the time control code. Hopefully :) */
    if (Params.Inc > 0)
        Params.MoveTime += (float) Params.Inc;
    /* Check if we have enough space in the hash table to store quiescence
     * positions during this search. */
    QStore = QStoreAll = FALSE;
    if (Params.HashSize > 8 && (float) (1 << (Params.HashSize - 9)) >
Params.MoveTime)
        QStore = TRUE;
    if (Params.HashSize > 11 && (float) (1 << (Params.HashSize - 12)) >
Params.MoveTime)
        QStoreAll = TRUE;
}

Here is Pepito:
//------------------------------------------------------------------------------
entero32        AllocTime(int mv_ctrl, int numjug, entero32 time_left, int inc)
{
    entero32        allocated;
/*  Old way falls off of a cliff...
    if (inc) {
        if (time_left > (inc + inc))
            return inc + time_left / 35;
        else
            return time_left / 35;
*/
    if (inc) {
        return (entero32) (inc * (time_left / ((float) time_left + inc)) +
time_left / 35.0f + 0.5f);
    } else if (mv_ctrl) {
        allocated = (time_left / (mv_ctrl - ((numjug / 2) % mv_ctrl)) * 80 /
100);
        if (time_left < 1000)
            allocated = allocated * 80 / 100;
    } else
        allocated = time_left / 40;

    CONTROL_INC = allocated > 300 ? 50000 : 20000;

    Log("mv_ctrl: %d, time_left: %d, allocated: %d\n", mv_ctrl, time_left,
allocated);

    return allocated;

}

There are more sophisticated methods, but this sort of idea will probably do for
starters.  Later, you could look at what Crafty does.



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.