#include "output.h"
#include "mymalloc.h"
#include "eco.h"
+#include "farmhash-c.h"
/* Functions for outputting games in the required format. */
return;
}
- // Find Black and White Elos. Skip games with no Elo.
+ // Find Black and White Elos.
const char *white_elo_tag = current_game.tags[WHITE_ELO_TAG];
const char *black_elo_tag = current_game.tags[BLACK_ELO_TAG];
- if (white_elo_tag == NULL || black_elo_tag == NULL) {
- return;
+ int white_elo = 0, black_elo = 0;
+ if (white_elo_tag) {
+ white_elo = atoi(white_elo_tag);
+ }
+ if (black_elo_tag) {
+ black_elo = atoi(black_elo_tag);
}
-
- int white_elo = atoi(white_elo_tag);
- int black_elo = atoi(black_elo_tag);
int file_num = current_game.file_number;
long start_position = current_game.start_position;
timestamp = 32503680000;
}
+ uint16_t prev_board_hash = 0;
+
for (move = current_game.moves; move != NULL; move = move->next) {
unsigned int opening = move->eco ? move->eco->cumulative_hash_value : 0; // Truncate to 32 bits.
// key
- putc(move->bpfen_len, outputfile);
+ putc(move->bpfen_len + sizeof(prev_board_hash), outputfile);
fwrite(move->bpfen, move->bpfen_len, 1, outputfile);
+ fwrite(&prev_board_hash, sizeof(prev_board_hash), 1, outputfile);
// value
putc(result_int, outputfile);
fwrite(&start_position, sizeof(start_position), 1, outputfile);
putc(strlen((char *)move->move), outputfile);
fwrite(move->move, strlen((char *)move->move), 1, outputfile);
+
+ prev_board_hash = farmhash_32(move->bpfen, move->bpfen_len);
}
}