Skip to content

Commit

Permalink
feats: add hash suffix for data files. 🎉
Browse files Browse the repository at this point in the history
  • Loading branch information
Joker2770 committed Dec 31, 2023
1 parent 06bb24f commit f1db08c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/play.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ SOFTWARE.

#include <iostream>
#include <fstream>
#include <sstream>

using namespace std;

Expand Down Expand Up @@ -122,8 +123,11 @@ void SelfPlay::play(unsigned int saved_id)
}
cout << "Self play: total step num = " << step << " winner = " << game_state.second << endl;

size_t hash_value = std::hash<std::shared_ptr<Gomoku>>{}(g);
std::ostringstream oss;
oss << hash_value;
ofstream bestand;
bestand.open("./data/data_" + to_string(saved_id), ios::out | ios::binary);
bestand.open("./data/data_" + to_string(saved_id) + "_" + oss.str(), ios::out | ios::binary);
bestand.write(reinterpret_cast<char *>(&step), sizeof(int));

for (int i = 0; i < step; i++)
Expand Down

0 comments on commit f1db08c

Please sign in to comment.