| 1 | #! /bin/false | ||
| 2 | |||
| 3 | # Copyright (C) 2021-2026 Guido Flohr <guido.flohr@cantanea.com>, | ||
| 4 | # all rights reserved. | ||
| 5 | |||
| 6 | # This program is free software. It comes without any warranty, to | ||
| 7 | # the extent permitted by applicable law. You can redistribute it | ||
| 8 | # and/or modify it under the terms of the Do What the Fuck You Want | ||
| 9 | # to Public License, Version 2, as published by Sam Hocevar. See | ||
| 10 | # http://www.wtfpl.net/ for more details. | ||
| 11 | |||
| 12 | # This is a macro that is not intended to run standalone. | ||
| 13 | |||
| 14 | ## no critic (TestingAndDebugging::RequireUseStrict) | ||
| 15 | |||
| 16 | (do { | ||
| 17 | # FIXME! Pass the colour in to the macro! | ||
| 18 | my $my_colour = cp_pos_to_move($p); | ||
| 19 | my $her_pieces = $p->[CP_POS_WHITE_PIECES + !$my_colour]; | ||
| 20 | my $occupancy = ($p->[CP_POS_WHITE_PIECES + $my_colour] | $her_pieces) & ~(1 << $from); | ||
| 21 | my $queens = cp_pos_queens($p); | ||
| 22 | $her_pieces | ||
| 23 | & (($pawn_masks[$my_colour]->[2]->[$to] & cp_pos_pawns($p)) | ||
| 24 | | ($knight_attack_masks[$to] & cp_pos_knights($p)) | ||
| 25 | | ($king_attack_masks[$to] & cp_pos_kings($p)) | ||
| 26 | | (cp_mm_bmagic($to, $occupancy) & ($queens | cp_pos_bishops($p))) | ||
| 27 | | (cp_mm_rmagic($to, $occupancy) & ($queens | cp_pos_rooks($p)))); | ||
| 28 | }) |