}
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/) {
}
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;