This makes sure lines no longer stop in dead ends. It's not perfect,
since we don't get the elos or computer percentages, but it's much
better than nothing.
- var move_a = document.createElement("a");
- move_a.href = "javascript:make_move('" + line[j] + "')";
- td.appendChild(move_a);
- $(move_a).text(line[j]);
+ if (line[j] === '1-0' || line[j] === '1/2-1/2' || line[j] === '0-1') {
+ $(td).text($(td).text() + line[j]);
+ } else {
+ var move_a = document.createElement("a");
+ move_a.href = "javascript:make_move('" + line[j] + "')";
+ td.appendChild(move_a);
+ $(move_a).text(line[j]);
+ }
} else if (headings[j][1] == TYPE_INTEGER) {
add_td(tr, line[j] || 0);
} else if (headings[j][1] == TYPE_FLOAT) {
} else if (headings[j][1] == TYPE_INTEGER) {
add_td(tr, line[j] || 0);
} else if (headings[j][1] == TYPE_FLOAT) {
};
# Explore one move out.
};
# Explore one move out.
+my $white_left = $json_root_pos->{'white'};
+my $draw_left = $json_root_pos->{'draw'};
+my $black_left = $json_root_pos->{'black'};
for my $move (@{$root_aux_data->{'moves'}}) {
my ($np, $uci_move) = $pos->make_pretty_move($move);
my $json_pos;
for my $move (@{$root_aux_data->{'moves'}}) {
my ($np, $uci_move) = $pos->make_pretty_move($move);
my $json_pos;
+
+ my ($json_pos_only_this_root, undef) = get_json_move($np, $root_aux_data->{'pos_hash'}, $chld_in, $chld_out);
+ $white_left -= $json_pos_only_this_root->{'white'};
+ $draw_left -= $json_pos_only_this_root->{'draw'};
+ $black_left -= $json_pos_only_this_root->{'black'};
+
if ($includetransp) {
($json_pos, undef) = get_json_move($np, undef, $chld_in, $chld_out);
# See if this move exists only due to transpositions.
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)) {
+ if (!defined($json_pos_only_this_root)) {
$json_pos->{'transpose_only'} = 1;
}
} else {
$json_pos->{'transpose_only'} = 1;
}
} else {
- ($json_pos, undef) = get_json_move($np, $root_aux_data->{'pos_hash'}, $chld_in, $chld_out);
+ $json_pos = $json_pos_only_this_root;
}
$json_pos->{'move'} = $move;
push @json_moves, $json_pos;
}
}
$json_pos->{'move'} = $move;
push @json_moves, $json_pos;
}
+# If there are any positions that are not accounted for by any moves,
+# these have to be games that end here. Add them as pseudo-moves so as
+# not to confuse the user.
+for my $result (['1-0', 'white', $white_left], ['1/2-1/2', 'draw', $draw_left], ['0-1', 'black', $black_left]) {
+ next if ($result->[2] == 0);
+ my $move = {
+ move => $result->[0],
+ white => 0,
+ draw => 0,
+ black => 0
+ };
+ $move->{$result->[1]} = $result->[2];
+ push @json_moves, $move;
+}
+
# Get stats for the root position, for the human index.
my $start_pos = Position->start_pos("white", "black");
my ($json_start_pos, undef) = get_json_move($start_pos, 0, $chld_in, $chld_out);
# Get stats for the root position, for the human index.
my $start_pos = Position->start_pos("white", "black");
my ($json_start_pos, undef) = get_json_move($start_pos, 0, $chld_in, $chld_out);