First of all, as you can see I quit from quitting ...
As a preliminary summary, I enjoy noticing that the discussion continues and that there are also new ideas.
Possible efficient/elegant/robust/short/powerful/bug-free implementations of the engine code that's necessary to handle "level"/"mlevel" are now being discussed intensively, and this is one important aspect of the whole issue. Here I fully agree with Pradu who said that
A lot of effort will be replicated by many people when implementing the protocol. Also taking into account that engines far exceed the number of GUIs, the protocol must be made to make engine programming the simplest.
Here I would like to add another statement that is partially similar to the one above:
The implementation should follow the requirements, not vice versa.
Here, requirements come from engine programmers mostly.
One of my main points was, and still is, that defining a new WB command for a new feature would allow engine programmers who want to upgrade their existing engine with the new feature to do the following, at least as a first step before possibly rewriting their "level" [or "mlevel"] handling code:
- Keep their whole code that recognizes the "level" command 100% untouched, and therefore still working reliably.
- Only add new code that recognizes the new command keyword (e.g. "mlevel") and handles it appropriately.
This would be an intermediate strategy since the required data structures to store N time control "sessions" are different from the flat "moves/seconds/increment" triple that is sufficient currently. But it is kind of defensive since any possible bugs in the new code would not affect the operation of the engine in traditional time control mode.
Once the new code would work, the engine programmer could do internal refactoring by choosing one common data structure that is filled and cleared with something like addLevel() and resetLevel() in the way Pradu suggested.
For me, this possibility of separating the working code that implements the existing protocol definition of "level" from new code that implements something new is really an important issue on behalf of the engine programmers.
Also I like Pradu's proposal of sending "level" once as before but followed optionally by one or more "mlevel" commands when multiple TC sessions are requested. The two points that are convincing me most compared to the original idea of sending (in case multi TC is requested) "mlevel" once with 3*N arguments are
- logfile readability and
- robustness with respect to possible buffer overflows.
While the former is kind of a nice service (and I would hate it to read a command with 9, 12, 15 parameters in a logfile) but not essential, the latter is an absolute "must have". To allow for an arbitrary number of parameters in an input string (I mean a really arbitrary number since we obviously don't want to define any artificial limit for the max. allowed number of TC sessions) strongly requires a self-growing string with dynamic memory allocation. It is not really difficult to do this but in the real world we cannot expect that many programmers would like to do this in their engine. But without self-growing, programmers would stick with the "char inputBuffer[256]" style, possibly just increasing the size, but still horribly unsafe.
Note that this issue is not about the exact way of parsing the input string but about a more general design question of a program.
This leads me to one more thought that I would like to point out. While code fragments showing how this or that could be done in detail are clearly a nice thing to discuss about, we should not forget that the "higher level" aspects of some possible alternative decisions should get more weight in the current situation. Concrete implementation details can be left for later.
This completes my list of thoughts I wanted to add to the discussion. I hope we can keep an eye on all, or most, of these somehow and do not dissipate our energies by diving too deep into only one of them.
The next steps should perhaps be
- to really clarify the requirements for "multi-session time control" and possibly other new ways of defining time control for WB engine play, and
- to discuss pros and cons of different ways to realize *these* requirements on the WB protocol level (but not yet too much on the level of the C/C++ bits).
Sven