]> git.sesse.net Git - remoteglot-book/blobdiff - www/opening-stats.pl
Mark moves that arise only due to transpositions in blue.
[remoteglot-book] / www / opening-stats.pl
index e809088cbaf3af9f4e594c24f49560f9155f658a..3fb8946f3122fcf10fab9f73519bd801ee8ca10f 100755 (executable)
@@ -55,6 +55,12 @@ for my $move (@{$root_aux_data->{'moves'}}) {
        my $json_pos;
        if ($includetransp) {
                ($json_pos, undef) = get_json_move($np, undef, $chld_in, $chld_out);
+
+               # See if this move exists only due to transpositions.
+               my ($alt_json_pos, undef) = get_json_move($np, $root_aux_data->{'pos_hash'}, $chld_in, $chld_out);
+               if (!defined($alt_json_pos)) {
+                       $json_pos->{'transpose_only'} = 1;
+               }
        } else {
                ($json_pos, undef) = get_json_move($np, $root_aux_data->{'pos_hash'}, $chld_in, $chld_out);
        }
@@ -124,7 +130,7 @@ sub get_json_move {
        chomp (my $line = <$chld_out>);
        if ($line eq '-') {
                warn "Missing pos '" . $pos->fen . "' " . $filter_prev_pos_hash;
-               return ({}, {});
+               return (undef, undef);
        }
 
        my ($white, $draw, $black, $opening_num, $white_sum_elo, $black_sum_elo, $num_elo, $timestamp, $pgn_file_number, $pgn_start_position, @moves) = split / /, $line;