]> git.sesse.net Git - remoteglot-book/blobdiff - binmerger.cpp
Key the table by position, not position+move. Makes for more complex exploration...
[remoteglot-book] / binmerger.cpp
index 6c162404e416e1c347ee449d83ee82153297ebfb..9bd969ead0d3795ed0a495047ad5e2ae77232a0c 100644 (file)
@@ -2,6 +2,7 @@
 #include <mtbl.h>
 #include <memory>
 #include <string>
+#include <unordered_set>
 #include <string.h>
 #include <assert.h>
 #include "count.pb.h"
@@ -38,6 +39,18 @@ void merge_count(void* userdata,
                }
        }
 
+       // Merge the moves, with deduplication.
+       unordered_set<string> moves;
+       for (int i = 0; i < c0.move_size(); ++i) {
+               moves.insert(c0.move(i));
+               c.add_move(c0.move(i));
+       }
+       for (int i = 0; i < c1.move_size(); ++i) {
+               if (!moves.count(c1.move(i))) {
+                       c.add_move(c1.move(i));
+               }
+       }
+
        static string buf;  // Keep allocated.
        c.SerializeToString(&buf);