From 5fbf19e12b717ae047f81ce904cb218f5e4fe081 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 15 Dec 2014 00:21:48 +0100 Subject: [PATCH] Mark moves that arise only due to transpositions in blue. --- www/css/remoteglot.css | 3 +++ www/js/book.js | 4 ++++ www/opening-stats.pl | 8 +++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/www/css/remoteglot.css b/www/css/remoteglot.css index 110f5c8..a07fb48 100644 --- a/www/css/remoteglot.css +++ b/www/css/remoteglot.css @@ -194,3 +194,6 @@ a.move:hover { .totals { background: rgb(90%,90%,90%); } +.transponly { + background: rgb(90%,90%,100%); +} diff --git a/www/js/book.js b/www/js/book.js index 854d6ad..36a9a26 100644 --- a/www/js/book.js +++ b/www/js/book.js @@ -157,6 +157,7 @@ var show_lines = function(data, game) { } var lines = []; + var transpose_only = []; for (var i = 0; i < moves.length; ++i) { var move = moves[i]; var line = []; @@ -166,6 +167,7 @@ var show_lines = function(data, game) { var black = parseInt(move['black']); line.push(move['move']); // Move. + transpose_only.push(move['transpose_only']); var num = white + draw + black; line.push(num); // N. line.push(num / total_num); // %. @@ -214,6 +216,8 @@ var show_lines = function(data, game) { if (line[0] === undefined) { $(tr).addClass("totals"); + } else if (transpose_only[i]) { + $(tr).addClass("transponly"); } for (var j = 0; j < line.length; ++j) { diff --git a/www/opening-stats.pl b/www/opening-stats.pl index e809088..3fb8946 100755 --- a/www/opening-stats.pl +++ b/www/opening-stats.pl @@ -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; -- 2.39.2