mirror of
https://github.com/sockspls/badfish
synced 2025-07-11 19:49:14 +00:00
バグ修正(learn convert_bin_from_pgn-extract)
This commit is contained in:
parent
fda3945c07
commit
486f72af54
1 changed files with 30 additions and 25 deletions
|
@ -2614,6 +2614,7 @@ void convert_bin_from_pgn_extract(const vector<string>& filenames, const string&
|
||||||
|
|
||||||
else {
|
else {
|
||||||
int gamePly = 0;
|
int gamePly = 0;
|
||||||
|
bool first = true;
|
||||||
|
|
||||||
PackedSfenValue psv;
|
PackedSfenValue psv;
|
||||||
memset((char*)&psv, 0, sizeof(PackedSfenValue));
|
memset((char*)&psv, 0, sizeof(PackedSfenValue));
|
||||||
|
@ -2682,6 +2683,35 @@ void convert_bin_from_pgn_extract(const vector<string>& filenames, const string&
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (first) {
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
psv.gamePly = gamePly;
|
||||||
|
psv.game_result = game_result;
|
||||||
|
|
||||||
|
if (pos.side_to_move() == BLACK) {
|
||||||
|
if (!pgn_eval_side_to_move) {
|
||||||
|
psv.score *= -1;
|
||||||
|
}
|
||||||
|
psv.game_result *= -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
std::cout << "write: "
|
||||||
|
<< "score=" << psv.score
|
||||||
|
<< ", move=" << psv.move
|
||||||
|
<< ", gamePly=" << psv.gamePly
|
||||||
|
<< ", game_result=" << (int)psv.game_result
|
||||||
|
<< std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ofs.write((char*)&psv, sizeof(PackedSfenValue));
|
||||||
|
memset((char*)&psv, 0, sizeof(PackedSfenValue));
|
||||||
|
|
||||||
|
fen_count++;
|
||||||
|
}
|
||||||
|
|
||||||
// example: { rnbqkbnr/pppppppp/8/8/3P4/8/PPP1PPPP/RNBQKBNR b KQkq d3 0 1 }
|
// example: { rnbqkbnr/pppppppp/8/8/3P4/8/PPP1PPPP/RNBQKBNR b KQkq d3 0 1 }
|
||||||
if (!std::regex_search(itr, line.cend(), match, pattern_bracket)) {
|
if (!std::regex_search(itr, line.cend(), match, pattern_bracket)) {
|
||||||
break;
|
break;
|
||||||
|
@ -2706,31 +2736,6 @@ void convert_bin_from_pgn_extract(const vector<string>& filenames, const string&
|
||||||
trim(str_move);
|
trim(str_move);
|
||||||
//std::cout << "str_move=" << str_move << std::endl;
|
//std::cout << "str_move=" << str_move << std::endl;
|
||||||
psv.move = UCI::to_move(pos, str_move);
|
psv.move = UCI::to_move(pos, str_move);
|
||||||
|
|
||||||
//
|
|
||||||
psv.gamePly = gamePly;
|
|
||||||
psv.game_result = game_result;
|
|
||||||
|
|
||||||
if (pos.side_to_move() == BLACK) {
|
|
||||||
if (!pgn_eval_side_to_move) {
|
|
||||||
psv.score *= -1;
|
|
||||||
}
|
|
||||||
psv.game_result *= -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
std::cout << "write: "
|
|
||||||
<< "score=" << psv.score
|
|
||||||
<< ", move=" << psv.move
|
|
||||||
<< ", gamePly=" << psv.gamePly
|
|
||||||
<< ", game_result=" << (int)psv.game_result
|
|
||||||
<< std::endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ofs.write((char*)&psv, sizeof(PackedSfenValue));
|
|
||||||
memset((char*)&psv, 0, sizeof(PackedSfenValue));
|
|
||||||
|
|
||||||
fen_count++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
game_result = 0;
|
game_result = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue