mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 01:03:09 +00:00
enable convert_plain
learn convert_plain output_file_name xxx.txt xxx.bin
This commit is contained in:
parent
df9b2a87db
commit
a06234c639
1 changed files with 44 additions and 41 deletions
|
@ -2759,39 +2759,43 @@ void convert_bin_from_pgn_extract(const vector<string>& filenames, const string&
|
||||||
ofs.close();
|
ofs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
//void convert_plain(const vector<string>& filenames , const string& output_file_name)
|
void convert_plain(const vector<string>& filenames, const string& output_file_name)
|
||||||
//{
|
{
|
||||||
// Position tpos;
|
Position tpos;
|
||||||
// std::ofstream ofs;
|
std::ofstream ofs;
|
||||||
// ofs.open(output_file_name, ios::app);
|
ofs.open(output_file_name, ios::app);
|
||||||
// for (auto filename : filenames) {
|
auto th = Threads.main();
|
||||||
// std::cout << "convert " << filename << " ... ";
|
for (auto filename : filenames) {
|
||||||
//
|
std::cout << "convert " << filename << " ... ";
|
||||||
// // Just convert packedsfenvalue to text
|
|
||||||
// std::fstream fs;
|
// Just convert packedsfenvalue to text
|
||||||
// fs.open(filename, ios::in | ios::binary);
|
std::fstream fs;
|
||||||
// PackedSfenValue p;
|
fs.open(filename, ios::in | ios::binary);
|
||||||
// while (true)
|
PackedSfenValue p;
|
||||||
// {
|
while (true)
|
||||||
// if (fs.read((char*)&p, sizeof(PackedSfenValue))) {
|
{
|
||||||
// // write as plain text
|
if (fs.read((char*)&p, sizeof(PackedSfenValue))) {
|
||||||
// ofs << "sfen " << tpos.sfen_unpack(p.sfen) << std::endl;
|
StateInfo si;
|
||||||
// ofs << "move " << to_usi_string(Move(p.move)) << std::endl;
|
tpos.set_from_packed_sfen(p.sfen, &si, th, false);
|
||||||
// ofs << "score " << p.score << std::endl;
|
|
||||||
// ofs << "ply " << int(p.gamePly) << std::endl;
|
// write as plain text
|
||||||
// ofs << "result " << int(p.game_result) << std::endl;
|
ofs << "fen " << tpos.fen() << std::endl;
|
||||||
// ofs << "e" << std::endl;
|
ofs << "move " << UCI::move(Move(p.move), false) << std::endl;
|
||||||
// }
|
ofs << "score " << p.score << std::endl;
|
||||||
// else {
|
ofs << "ply " << int(p.gamePly) << std::endl;
|
||||||
// break;
|
ofs << "result " << int(p.game_result) << std::endl;
|
||||||
// }
|
ofs << "e" << std::endl;
|
||||||
// }
|
}
|
||||||
// fs.close();
|
else {
|
||||||
// std::cout << "done" << std::endl;
|
break;
|
||||||
// }
|
}
|
||||||
// ofs.close();
|
}
|
||||||
// std::cout << "all done" << std::endl;
|
fs.close();
|
||||||
//}
|
std::cout << "done" << std::endl;
|
||||||
|
}
|
||||||
|
ofs.close();
|
||||||
|
std::cout << "all done" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
// Learning from the generated game record
|
// Learning from the generated game record
|
||||||
void learn(Position&, istringstream& is)
|
void learn(Position&, istringstream& is)
|
||||||
|
@ -3082,14 +3086,13 @@ void learn(Position&, istringstream& is)
|
||||||
shuffle_files_on_memory(filenames,output_file_name);
|
shuffle_files_on_memory(filenames,output_file_name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//if (use_convert_plain)
|
if (use_convert_plain)
|
||||||
//{
|
{
|
||||||
// is_ready(true);
|
init_nnue(true);
|
||||||
// cout << "convert_plain.." << endl;
|
cout << "convert_plain.." << endl;
|
||||||
// convert_plain(filenames,output_file_name);
|
convert_plain(filenames, output_file_name);
|
||||||
// return;
|
return;
|
||||||
//
|
}
|
||||||
//}
|
|
||||||
if (use_convert_bin)
|
if (use_convert_bin)
|
||||||
{
|
{
|
||||||
init_nnue(true);
|
init_nnue(true);
|
||||||
|
|
Loading…
Add table
Reference in a new issue