2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 int att_side
, def_side
;
35 from
= GET_FROM(move
);
37 type
= GET_TYPE(move
);
39 att_side
= (BIT(from
) & side_boards
[WHITE
]) ? WHITE
: BLACK
;
40 def_side
= 1 ^ att_side
;
43 atts
= ATTACK_TO(to
, att_side
, occ
);
44 defs
= ATTACK_TO(to
, def_side
, occ
);
50 if (type
& TYPE_PROMOTE
) {
51 swap_list
[0] = piece_value
[GET_PROMOTE(move
)] - piece_value
[PAWN
];
52 last_val
= -piece_value
[GET_PROMOTE(move
)];
54 swap_list
[0] += (GET_TYPE(move
) & TYPE_ENPASSANT
) ? piece_value
[PAWN
] : piece_value
[square64
[to
]];
55 last_val
+= -piece_value
[square64
[from
]];
59 for (piece
= PAWN
; piece
<= KING
; piece
++) {
60 bb
= defs
& piece_boards
[def_side
][piece
];
62 square
= bit_scan(bb
);
65 swap_list
[count
] = swap_list
[count
- 1] + last_val
;
66 last_val
= piece_value
[piece
];
75 for (piece
= PAWN
; piece
<= KING
; piece
++) {
76 bb
= atts
& piece_boards
[att_side
][piece
];
78 square
= bit_scan(bb
);
81 swap_list
[count
] = swap_list
[count
- 1] + last_val
;
82 last_val
= -piece_value
[piece
];
95 if (swap_list
[count
] <= swap_list
[count
- 1])
96 swap_list
[count
- 1] = swap_list
[count
];
98 if (swap_list
[count
] >= swap_list
[count
- 1])
99 swap_list
[count
- 1] = swap_list
[count
];