-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Validation support for specifying GTP commands for each binary #1459
Conversation
@marcocalignano please review |
Marco didn't reply? I don't see anything wrong with this, but I have one concern: this seems to be a special case of the more generic problem of wanting to specify some GTP commands to be run at startup. Would you be willing to rework this to just take some arbitrary startup command(s)? "time_settings blah" would then be one of them? |
I was actually thinking about trying that anyway so that handicap games could be tested too. |
It is not a easy review because Game.cpp is used also by autogtp. And I was busy last week I see what I can do this week. |
Multiple strings I think. Asking the user to include "\n" in the command is messy. Better to allow the same command line option multiple times. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
autogtp seems to work with this patch
Thanks guys. |
What do you mean by:
|
As in two different sets of initial gtp commands, one for each binary, as per above:
|
The problem that I see is that the Game object is shared with autogtp so you have to be careful to port the changes even in autogtp. I would a different member function that accept a string list of GTP commands. Also I would concentrate on that (Game object changes) first before you add the list in main. And yes then you should do one list for each player. |
Got it, I appreciate the guidance. |
Since you use
|
That sounds simple but @gcp said it is messy above. Another way that does follow his preference would be to also specify the side the commands are for e.g. |
It would become
That is, the commands refer to the last specified engine. No need to specify which one then. To get some idea of how this can work, take a look at cutechess-cli. |
@gcp Don't you like the suggestion with the ';' separator between commands? It would be easier to implement with the QT CommandLineParser. |
The problem I see is that if a GTP command would contain a ";" this solution would break. |
@gcp we can start with the separator character (a bit like |
How about --gtp-command-file commands.txt? And put all your gtp commands in a text file. |
No
Yes |
What's wrong with the command line? The situation I described literally already exists in cutechess-cli, which is also written in Qt IIRC. I'm not asking for rocket science here, I'm asking to replicate an existing solution that works really well :( |
Thanks for the clarity. I'll make a start tonight. |
I've had a look at cutechess-cli's code and instructions on running and following that will result in e.g.: |
6032cb2
to
6c4e1cc
Compare
For this evening I have managed to change Game and Validation to be able to cope with multiple GTP commands but have left the Validations options as they were. Might get a bit more time tomorrow or sat morning. |
@Hersmunch What I suggest you should define the name of the binary ( |
I am trying to use validation for handicap games with a fixed binary playing black; after the existing commits I can append Also, for not switching binaries between games, does commenting out the following two places suffice? Thank you in advance for reviewing. |
Follow-up: I modified https://github.com/Hersmunch/leela-zero/blob/6c4e1cc9802ede637cee392cd1dddafa42e0b5b6/autogtp/Game.cpp#L32 also and everything seems to work. |
@alreadydone I'll leave the support for handicap games that you mention for a separate PR. |
@Hersmunch no that is not what I meant! |
Haha, whoops! Sorry about that. OK, I'll have one more go at it :) |
can we learn the gogui twogtp command format, |
0152274
to
7d3f8b2
Compare
@marcocalignano, I gave up trying to find a way for general options to be specified after a binary is specified. Hopefully this is more what you were thinking?
Example: |
@l1t1 I had a look at https://www.mankier.com/1/gogui-twogtp but it doesn't appear to support specifying GTP commands to each side or allowing for handicap to be specified (except for maybe in an .sgf?). |
@Hersmunch I found following from your link, but i haven't used them
|
@Hersmunch Yes that what I was thinking, I would also specify the command line a bit better: |
@marcocalignano I had a search around but haven't found out how to change the usage information. I agree it would be better as you describe.
I'm not sure what you are asking. You can see the content of my commits, right? |
@@ -23,11 +23,12 @@ | |||
#include <QFileInfo> | |||
#include "Game.h" | |||
|
|||
Game::Game(const QString& weights, const QString& opt, const QString& binary) : | |||
Game::Game(const QString& weights, const QString& opt, const QString& binary, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Game is used from autogtp too. So I guess this change breaks autogtp.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll double check but the new parameter is defaulted in the constructor in the Game.h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, still works for me.
autogtp/Game.cpp
Outdated
for (auto command : m_commands) { | ||
sendGtpCommand(command); | ||
} | ||
QTextStream(stdout) << "Thinking time set." << endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have to wait for and parse the answer of each command before you send the next.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, doesn't sendGtpCommand()
already do this?
I'll add catching of a it returning false (command failing) and exit though.
validation/Validation.h
Outdated
QString network; | ||
QStringList commands; | ||
} engine_t; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would make a proper Object with copy constructor, maybe even a move constructor and call it Engine. And maybe adding a member to handle the list of command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have a preference between using a struct or a class?
What do you mean by "handle the list of command"? I'm not understanding what I could add that would be helpful.
@@ -116,16 +118,35 @@ int main(int argc, char *argv[]) { | |||
return EXIT_FAILURE; | |||
} | |||
} | |||
|
|||
QStringList commandList = {"time_settings 0 1 0"}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You do not want to add this for default, what if someone wants to change the time settings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gtp-command
s given by the user are added to the end of the list so any other time_settings commands that follow will be done after this one, overwriting what this first one does. Seems to work from when I've used it.
I thought this would be easier than parsing commandList
after all the user's commands had been added and looking to see if a time_settings one had been provided. It would seem cleaner to not always send this initial command though so I'd be happy to change it if anyone has ideas on a better approach.
validation/main.cpp
Outdated
pos_args = parser.positionalArguments(); | ||
engine_idx++; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this while loop works like we want?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my limited usage of the changes it appears to work how I expect. Have you got any particular concerns? I might have misunderstood something :)
I was surprised at first that I didn't have to remove/pop the binary from pos_args
but QCommandLineParser::process()
expects the string list of arguments to be from the command line and therefore ignores the first item as "Usually arguments().at(0) is the program name..." http://doc.qt.io/qt-5/qcoreapplication.html#arguments. I have only got Windows to test on though.
I could add some comment(s) if that helps?
@Hersmunch I presume you're still working on this when you find some spare time? |
Also gitignore some local files and outputs
… up but left the Validations options untouched.
…. Replaced time settings option with ability to specify any GTP commands.
…xisting option parser. Also changed default binary options from -p 1600 to -v 3200.
Yes, I intend to but just haven't had a lot of time lately. |
7d3f8b2
to
15580cb
Compare
15580cb
to
60a61e0
Compare
@marcocalignano OK to merge? |
@gcp I didn't have time to test it but it looks fine and he tested it so go for it! |
I had to back this out :-(
It looks like this was changed in Qt 5.6. We require Qt 5.3 only. The default Qt in Ubuntu 16.04 is 5.5.1. At the very least, we'll need to bump our Qt dependency to 5.6, or avoid this. Ubuntu 18.04.1 is due in about 10 days at which point 16.04 upgrades will be possible. That sounds like a reasonable time to require a newer baseline, but we'd still screw some people over with this, though. |
:( sorry about that. Having a look at the Qt 5.2 documentation it looks like it might be possible to work around this by requiring a |
Fixes #1455.
Also gitignore some local files and outputs.