aboutsummaryrefslogtreecommitdiff
path: root/metasol.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'metasol.cpp')
-rw-r--r--metasol.cpp37
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;