Explanation of the Cute Chess message 'connection stalls'

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
Roland Chastain
Posts: 640
Joined: Sat Jun 08, 2013 10:07 am
Location: France
Full name: Roland Chastain

Re: Explanation of the Cute Chess message 'connection stalls'

Post by Roland Chastain »

elcabesa wrote: Sun Jun 16, 2019 7:58 am if your engine search at fixed depth and doesn't answer until it has finished you can try a combination of those options with cutechess:
depth=plies
Set the search depth limit.

st=n Set the time limit for each move to n seconds. This option
cannot be used in combination with the tc option.
Thank you for the tip.

In the meantime, I found the explanation. It's because the engine didn't answer to 'stop' command. I used to believe that the 'go' command was only used after a 'go infinite'. Now I understand that it can also be used when the engine is slow to answer.
Qui trop embrasse mal étreint.
User avatar
Roland Chastain
Posts: 640
Joined: Sat Jun 08, 2013 10:07 am
Location: France
Full name: Roland Chastain

Re: Explanation of the Cute Chess message 'connection stalls'

Post by Roland Chastain »

Ras wrote: Sun Jun 16, 2019 10:47 am When I look at alouette.pas, the parser for the "go" command is not really implementing the UCI spec. The order of arguments is not specified, but you rely on it in utils.pas. Also, the case where wtime, btime, winc, binc AND movestogo is given seems to be missing.

I'd suggest that you do a WordPresent or so on every possible argument, and if it's present, get its position dynamically, and the following argument then must be the integer parameter. At the end, figure out which configuration it is.
Thank you for looking into Alouette code. Well seen. Indeed these functions would need to be rewritten. Thank you for the idea.
Ras wrote: Sun Jun 16, 2019 10:47 amAlso, the UCI parser doesn't contain the 'stop' command so that the engine can't possibly react to it. Yes, 'stop' needs to be evaluated while the engine is calculating its move. 'isready' the same. I'm not good enough at Pascal to see whether you're running the UCI parser and engine calculator in different threads so that the move calculation won't block the evaluation of UCI input.
Yes, that was the origin of the problem. I don't know why I imagined that the 'stop' command was only used in association with 'go infinite'.

I made a quick modification, to remember that I have to solve the problem:

Code: Select all

                  if LCmd = 'stop' then
                  begin
                    Ecrire('bestmove 1234');
                  end else
Cute Chess no longer sends 'connection stalls' message, but 'illegal move 1234'. :)

Yes, I have a separated thread for best move computation. So technically the engine is always able to answer to user commands, but in the current state of the program there is no provisional best move, to be returned when the 'stop' command is received. I have to think how I will make that.
Qui trop embrasse mal étreint.
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Explanation of the Cute Chess message 'connection stalls'

Post by Sven »

Roland Chastain wrote: Sun Jun 16, 2019 1:45 pm but in the current state of the program there is no provisional best move, to be returned when the 'stop' command is received. I have to think how I will make that.
The typical solution for this problem in classical chess engines is iterative deepening: the engine performs a search to depth 1, 2, 3, ... until the allocated time is exhausted, and if the timeout occurs during iteration N+1 then the best move of the previous iteration N is available and can be played. Also iteration N+1 will always search the best move from N as its first move (or more generally, when using a hash table, at any node throughout the tree you will always search the best move first that was stored in the hash table during a previous visit of the position) which is especially helpful for alpha-beta searchers.
Sven Schüle (engine author: Jumbo, KnockOut, Surprise)
User avatar
Roland Chastain
Posts: 640
Joined: Sat Jun 08, 2013 10:07 am
Location: France
Full name: Roland Chastain

Re: Explanation of the Cute Chess message 'connection stalls'

Post by Roland Chastain »

Sven wrote: Sun Jun 16, 2019 2:47 pm
Roland Chastain wrote: Sun Jun 16, 2019 1:45 pm but in the current state of the program there is no provisional best move, to be returned when the 'stop' command is received. I have to think how I will make that.
The typical solution for this problem in classical chess engines is iterative deepening: the engine performs a search to depth 1, 2, 3, ... until the allocated time is exhausted, and if the timeout occurs during iteration N+1 then the best move of the previous iteration N is available and can be played. Also iteration N+1 will always search the best move from N as its first move (or more generally, when using a hash table, at any node throughout the tree you will always search the best move first that was stored in the hash table during a previous visit of the position) which is especially helpful for alpha-beta searchers.
Thank you for your message. For iterative deepening, I understand what it is but I have to figure how to do it. For now, I use a recursive function. For the hash, it is upon my current programming knowledge. :)

Thank you all for your help.
Qui trop embrasse mal étreint.
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Explanation of the Cute Chess message 'connection stalls'

Post by Sven »

Roland Chastain wrote: Sun Jun 16, 2019 5:11 pm For iterative deepening, I understand what it is but I have to figure how to do it. For now, I use a recursive function.
Iterative deepening is a concept one level above the tree search itself. The latter can be implemented recursively or iteratively.

Code: Select all

int search(Board b, int d, int alpha, int beta, OUT Move bestMove)
{
    if (checkTimeout()) {
        stopSearch := true;
        return IGNORE;
    }
    if (d == 0) {
        return b.evaluateLeaf();
    }
    // move loop ...
    {
        b.makeMove(move);
        score := -search(b, d - 1, -beta, -alpha, localBestMove);
        b.unmakeMove(move);
        if (stopSearch) {
            return IGNORE;
        }
        if (score >= beta) {
            return beta;
        }
        if (score > alpha) {
            alpha := score;
            bestMove := move;
        }
    }
    return alpha;
}

Move idLoop(Board b)
{
    d := 1;
    bestMove := null;
    stopSearch := false;
    while (!stopSearch) {
        score = search(b, d, -INF, +INF, localBestMove);
        if (!stopSearch) {
            bestMove := localBestMove;
    	    d := d + 1;
    	}
    }
    return bestMove;
}
Sven Schüle (engine author: Jumbo, KnockOut, Surprise)
User avatar
Roland Chastain
Posts: 640
Joined: Sat Jun 08, 2013 10:07 am
Location: France
Full name: Roland Chastain

Re: Explanation of the Cute Chess message 'connection stalls'

Post by Roland Chastain »

Sven wrote: Sun Jun 16, 2019 6:24 pmIterative deepening is a concept one level above the tree search itself. The latter can be implemented recursively or iteratively.
Thank you for your code. I will study it.
Qui trop embrasse mal étreint.