2021-11-14 00:02:03 +08:00
|
|
|
// This file is part of Sanmill.
|
|
|
|
// Copyright (C) 2019-2021 The Sanmill developers (see AUTHORS file)
|
|
|
|
//
|
|
|
|
// Sanmill is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Sanmill is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2019-09-17 01:58:27 +08:00
|
|
|
#include "endgame.h"
|
2021-11-18 01:12:08 +08:00
|
|
|
#include <string>
|
2019-09-17 01:58:27 +08:00
|
|
|
|
2021-11-14 00:02:03 +08:00
|
|
|
using std::string;
|
|
|
|
|
2019-09-17 01:58:27 +08:00
|
|
|
#ifdef ENDGAME_LEARNING
|
2021-11-06 08:31:33 +08:00
|
|
|
static constexpr int endgameHashSize = 0x1000000; // 16M
|
2021-05-01 19:12:07 +08:00
|
|
|
HashMap<Key, Endgame> endgameHashMap(endgameHashSize);
|
2019-12-22 01:01:51 +08:00
|
|
|
|
2021-11-18 01:12:08 +08:00
|
|
|
void mergeEndgameFile(
|
|
|
|
const string& file1, const string& file2, const string& mergedFile)
|
2019-12-22 01:01:51 +08:00
|
|
|
{
|
2021-05-01 19:12:07 +08:00
|
|
|
HashMap<Key, Endgame> map1(endgameHashSize);
|
|
|
|
HashMap<Key, Endgame> map2(endgameHashSize);
|
2019-12-22 01:01:51 +08:00
|
|
|
|
|
|
|
map1.load(file1);
|
|
|
|
map2.load(file2);
|
|
|
|
|
|
|
|
map1.merge(map2);
|
|
|
|
|
|
|
|
map1.dump(mergedFile);
|
|
|
|
|
2021-11-28 23:03:22 +08:00
|
|
|
debugPrintf("[endgame] Merge %s to %s and save to %s\n", file2.c_str(),
|
2021-11-18 01:12:08 +08:00
|
|
|
file1.c_str(), mergedFile.c_str());
|
2019-12-22 01:01:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int mergeEndgameFile_main()
|
|
|
|
{
|
2020-12-31 10:57:47 +08:00
|
|
|
string filename;
|
2019-12-22 01:01:51 +08:00
|
|
|
|
2020-12-31 10:57:47 +08:00
|
|
|
for (char ch = '0'; ch <= '9'; ch++) {
|
|
|
|
filename = ch + "/endgame.txt";
|
2019-12-22 01:01:51 +08:00
|
|
|
mergeEndgameFile("endgame.txt", filename, "endgame.txt");
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
system("pause");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-09-17 01:58:27 +08:00
|
|
|
#endif // ENDGAME_LEARNING
|