diff options
| author | Tom Harley | 2019-04-08 19:56:44 +0100 |
|---|---|---|
| committer | Tom Harley | 2019-04-08 19:56:44 +0100 |
| commit | 00de4082c38cc2e9e01dfc4ca6a8308a74c5d779 (patch) | |
| tree | 0f8992f0332187287d9d9dadde578ab62ff7f35e /metasol.cpp | |
| parent | Add time/node limit options (diff) | |
| download | metasol-00de4082c38cc2e9e01dfc4ca6a8308a74c5d779.tar.gz metasol-00de4082c38cc2e9e01dfc4ca6a8308a74c5d779.zip | |
Enable reading deal seeds from a file
Diffstat (limited to 'metasol.cpp')
| -rw-r--r-- | metasol.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/metasol.cpp b/metasol.cpp index fa57ff4..daac9ad 100644 --- a/metasol.cpp +++ b/metasol.cpp @@ -939,6 +939,11 @@ int run_single(ms_rules *r, ms_settings *s, unsigned long seed, return ms_run(&gs, r, s, tp); } +int ms_run_id(int id, unsigned long seed, ms_rules *r, ms_settings *s, + ctpl::thread_pool *tp) { + return run_single(r, s, seed, tp); +} + int ms_run_single(ms_rules *r, ms_settings *s, unsigned long seed) { ctpl::thread_pool tp(s->max_concurrent_threads); return run_single(r, s, seed, &tp); @@ -981,6 +986,38 @@ int ms_run_many(ms_rules *r, ms_settings *s) { return 0; } +int ms_run_from_file(ms_rules *r, ms_settings *s, const char *filename, + ctpl::thread_pool *tp) { + + FILE *fp = fopen(filename, "r"); + char *line = NULL; + size_t len = 0; + ssize_t read; + std::vector<std::future<int>> fs; + + ctpl::thread_pool main_tp(s->max_concurrent_games); + + while ((read = getline(&line, &len, fp)) != EOF) { + unsigned long seed = strtoll(line, NULL, 0); + fs.push_back(main_tp.push(ms_run_id, seed, r, s, tp)); + } + + main_thread_pool = &main_tp; + + /* + * these will run forever, unless stopped by ^C + */ + for (auto &f : fs) { + assert(f.valid()); + f.wait(); + } + + fclose(fp); + free(line); + + return 0; +} + ms_rules fetch_default_rules() { ms_rules dr; |
