From: Steinar H. Gunderson Date: Fri, 19 Dec 2014 23:17:42 +0000 (+0100) Subject: Accept and store the computer/human flag. X-Git-Url: https://git.sesse.net/?p=remoteglot-book;a=commitdiff_plain;h=9875a6ae1879342d97c1664dfbefa32deb5a8879 Accept and store the computer/human flag. --- diff --git a/binloader.cpp b/binloader.cpp index 7825116..6467cf8 100644 --- a/binloader.cpp +++ b/binloader.cpp @@ -49,6 +49,7 @@ struct Element { int file_num; time_t timestamp; long start_position; + int computer; bool operator< (const Element& other) const { int s = memcmp_different_len(bpfen, bpfen_len, other.bpfen, other.bpfen_len); @@ -85,6 +86,7 @@ void write_subshard(const char *basename, ShardData* shard, int bucket) } else if (e.result == BLACK) { c.set_black(c.black() + 1); } + c.set_computer(c.computer() + e.computer); if (e.white_elo >= 100 && e.black_elo >= 100) { c.set_sum_white_elo(c.sum_white_elo() + e.white_elo); c.set_sum_black_elo(c.sum_black_elo() + e.black_elo); @@ -197,6 +199,11 @@ int main(int argc, char **argv) exit(1); } + int computer = getc(fp); + if (computer == -1) { + perror("getc(computer)"); + exit(1); + } char move[8]; int l = getc(fp); @@ -222,6 +229,7 @@ int main(int argc, char **argv) e.bpfen_len = bpfen_len; strcpy(e.move, move); e.result = Result(r); + e.computer = computer; e.opening_num = opening_num; e.white_elo = white_elo; e.black_elo = black_elo; diff --git a/build-book.sh b/build-book.sh index d9c2876..94f3a29 100755 --- a/build-book.sh +++ b/build-book.sh @@ -19,9 +19,14 @@ for X in $( seq 0 $(( MAPPERS - 1 )) ); do ( PGNNUM=0 for FILE in "$@"; do + COMP=0 + if echo "$FILE" | grep -q ^comp:; then + COMP=1 + FILE=$( echo "$FILE" | sed s/comp:// ) + fi START=$( ./find-pgn-split-point.sh "$FILE" $X $MAPPERS ) END=$( ./find-pgn-split-point.sh "$FILE" $(( X + 1 )) $MAPPERS ) - ~/nmu/pgn-extract/pgn-extract --startpos $START --endpos $END --startfilenum $PGNNUM -e -Wsessebin "$FILE" 2>/dev/null + ~/nmu/pgn-extract/pgn-extract --computerflag $COMP --startpos $START --endpos $END --startfilenum $PGNNUM -e -Wsessebin "$FILE" 2>/dev/null PGNNUM=$(( PGNNUM + 1 )) done ) | ./binloader - tmp.mtbl.mapper$X $SHARDS 500000 diff --git a/count.proto b/count.proto index 39da3e0..80e026d 100644 --- a/count.proto +++ b/count.proto @@ -4,6 +4,9 @@ message Count { optional int32 draw = 2; optional int32 black = 3; + // Number of games played by computers. + optional int32 computer = 12; + // Opening number (32-bit hash value). optional fixed32 opening_num = 4; diff --git a/merge_count.cpp b/merge_count.cpp index dbf028d..c23e439 100644 --- a/merge_count.cpp +++ b/merge_count.cpp @@ -11,6 +11,7 @@ Count merge_count(const Count& c0, const Count& c1) c.set_white(c0.white() + c1.white()); c.set_draw(c0.draw() + c1.draw()); c.set_black(c0.black() + c1.black()); + c.set_computer(c0.computer() + c1.computer()); c.set_sum_white_elo(c0.sum_white_elo() + c1.sum_white_elo()); c.set_sum_black_elo(c0.sum_black_elo() + c1.sum_black_elo()); c.set_num_elo(c0.num_elo() + c1.num_elo());