From: Steinar H. Gunderson Date: Sun, 4 Feb 2018 21:23:07 +0000 (+0100) Subject: Yet more Chess960 fixes. X-Git-Url: https://git.sesse.net/?p=remoteglot;a=commitdiff_plain;h=10ac7d58489ba6f8fcc340dbe5c90e0bc41e21fb Yet more Chess960 fixes. --- diff --git a/Position.pm b/Position.pm index 93bde53..8cfc4a6 100644 --- a/Position.pm +++ b/Position.pm @@ -76,11 +76,11 @@ sub from_fen { } while ($castling =~ s/([A-H])//g) { my $rook_col = lc($1); - my $king_col = _find_piece_col($board->[7], 'K'); - if ($rook_col < $king_col) { - $pos->{'white_castle_q'} = _col_num_to_letter($rook_col); + my $king_col = _col_num_to_letter(_find_piece_col($board->[7], 'K')); + if ($rook_col lt $king_col) { + $pos->{'white_castle_q'} = $rook_col; } else { - $pos->{'white_castle_k'} = _col_num_to_letter($rook_col); + $pos->{'white_castle_k'} = $rook_col; } } if ($castling =~ /k/) { @@ -91,11 +91,11 @@ sub from_fen { } while ($castling =~ s/([a-h])//g) { my $rook_col = $1; - my $king_col = _find_piece_col($board->[0], 'k'); - if ($rook_col < $king_col) { - $pos->{'black_castle_q'} = _col_num_to_letter($rook_col); + my $king_col = _col_num_to_letter(_find_piece_col($board->[0], 'k')); + if ($rook_col lt $king_col) { + $pos->{'black_castle_q'} = $rook_col; } else { - $pos->{'black_castle_k'} = _col_num_to_letter($rook_col); + $pos->{'black_castle_k'} = $rook_col; } } $pos->{'time_since_100move_rule_reset'} = $halfmove_clock // 0; diff --git a/remoteglot.pl b/remoteglot.pl index 86334a7..049cdab 100755 --- a/remoteglot.pl +++ b/remoteglot.pl @@ -910,6 +910,7 @@ sub output_json { } else { $pos = Position->start_pos('white', 'black'); } + $pos->{'chess960'} = $pos_calculating->{'chess960'}; my $halfmove_num = 0; for my $move (@{$pos_calculating->{'history'}}) { my $id = id_for_pos($pos, $halfmove_num);