+ # white short/long chess960-style castling (king takes own rook)
+ my $dst_piece = $board->[$to_row][$to_col];
+ if ($dst_piece eq 'R') {
+ return ($to_col > $from_col) ? 'O-O' : 'O-O-O';
+ }
+ } elsif ($piece eq 'k') {
+ # black short/long castling
+ return 'O-O' if ($move eq 'e8g8');
+ return 'O-O-O' if ($move eq 'e8c8');
+
+ # black short/long chess960-style castling (king takes own rook)
+ my $dst_piece = $board->[$to_row][$to_col];
+ if ($dst_piece eq 'r') {
+ return ($to_col > $from_col) ? 'O-O' : 'O-O-O';
+ }