Suggestions for XBoard documentation

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

D Sceviour
Posts: 570
Joined: Mon Jul 20, 2015 5:06 pm

Re: Memory Question

Post by D Sceviour »

H.G. Muller wrote,
This is hard-coded, but I could conceivably have started by reading a simple.ini file, with some data in it that would be used for this startup allocation.
That is not what you have said before:
Initialization files are so 20th-century... It is highly recommended you let your engine support the 'memory' command to set its hash size. Just send

feature memory=1

at startup, and be ready to receive the command

memory N

from the GUI, and (re-)allocate the hash table to N megabytes if it wasn't already that. (For an example, see Simple's source code.)
H.G. Muller wrote,
When it receives the memory N command it calls SetMemorySize(N), which then (if N is not accidentally equal to the already allocated amount) frees the current hash table, and allocates a new one of N megabytes.
Yes, but you have already stated then N = 64 and is uneditable.

H.G. Muller wrote,
As WinBoard would always send the memory command to an engine that specified feature memory=1 the whole exercise of startup allocation is pointless when running under WinBoard.
Therefore, Graham Banks is correct and an engine is better off being Graham compatible with memory=0. Most engine programmers would not be prepared to accept 64M as an uneditable default hash size anymore just to be xboard compatible. You could run a poll to find out.
User avatar
hgm
Posts: 27790
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Memory Question

Post by hgm »

D Sceviour wrote:Yes, but you have already stated then N = 64 and is uneditable.
Not at all. N is the number to which you set the Hash Size in the Common Engine menu dialog, irrespective of what is in the winboard.ini file. It could be any number. When WinBoard saves settings (automatically on exit or on explicit request) the number specified in that dialog would end up in the user-settings file, so that the next time you run WinBoard the setting would still be the same as when you terminated the previous run. It is only 64 when in the current or some previous run you set it to 64.

I don't understand what is so difficult to grasp about this. Do you know any other GUI where you cannot change the engines hash usage by opening a menu dialog and altering the value there?
D Sceviour
Posts: 570
Joined: Mon Jul 20, 2015 5:06 pm

Re: Memory Question

Post by D Sceviour »

OK, that answers the question.
User avatar
hgm
Posts: 27790
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Elaborations

Post by hgm »

sje wrote:Having a unified view of state variable management allows for easy expansion while at the same time avoiding idiosyncrasies. Stuff like posting (two different directives), random (a toggle), pondering (two different directives), sd/st vs level (conflicting directives), and new mode variables required for additional functionality. Without a general unification, the ugly never goes away. Without a general unification, the newcomer coder has to slog through a document loaded with references to a long-gone chess engine.
Except of course that by now some 1000 other XBoard engines also work this way. The random, st, sd, easy, hard, post and nopost commands are not deprecated, and belong to the core set of command an engine must have to be of any practical use.

And, like I said, much of what you propose is only a 'formal' advantage, which makes no practical difference. Who cares whether you have post/nopost (2 commands) or "post true"/"post false" (imagining those are the same command, just because they contain a space)? Note that 'sd' is not a conflicting directive, but an additional limitation to the search, orthogonal to the timing requirements. Only 'st' and 'level' are actually conflicting, and my intention is to allow level 0 0 -N as a synonym for st N in engines that support an extended level command (that can also handle multiple sessions). So specifying feature xlevel=1 would get rid of the st command. That random is a toggle, (and consequently has to rely on new for being put in a defined state) and the others not might be ugly, but considering that hardly any engine supports randomization anyway, hardly a burden on the programmer...
A go/search action can be bundled on a usermove directive just by adding another field; there will already be field definitions for a draw offer and a draw claim, so adding a third field requesting a reply does not affect the general unification. With this, the total count of directives sent will be less than that of the current scheme.
Like it would really matter to many whether you have to send

usermove e2e4 search

or

usermove e2e4
search


...

I think this kind of bundling is intrinsically bad, as you might not want neither usermoves nor searches to always accompany each other, so there would still be need for unbundled search and usermove commands, so that many of the same can go in a row (for forcing in a game or having the engine play itself). Having them as separate commands is much more flexible. Only for combinations of actions that need to be atomic bundling makes sense. And even then I would probably prefer providing general atomicity through individual 'semaphore' commands to protect the critical section. Like

hold
move a6b6
1/2-1/2 {repetition draw}
release


to tell the GUI it should not stop parsing commands for the current engine until it has seen the release (and thus the draw claim) before processing any input events from the opponent.