sq_attackers() + others (see dedails). Ready for move do/undo ?

- add many "const" in func parameters
- attack.c: sq_attackers()
- move print_board_raw from position.c to to board.c
- move some fen_check() tests to pos_check()
- add REL_RANK() macro. TODO: add one more for bitboards
- fen.c: more tests for FEN validity
- position.c: add pos_checkers() and pos_check()
- tests: add common-test.h (for shared FEN positions access)
This commit is contained in:
2024-03-04 21:34:29 +01:00
parent a499893f32
commit b351d198b8
18 changed files with 584 additions and 482 deletions

View File

@@ -1,12 +1,22 @@
//#include "debug.h"
//#include "pool.h"
/* bitboard-test.c - basic bitboard/hyperbola tests.
*
* Copyright (C) 2024 Bruno Raoult ("br")
* Licensed under the GNU General Public License v3.0 or later.
* Some rights reserved. See COPYING.
*
* You should have received a copy of the GNU General Public License along with this
* program. If not, see <https://www.gnu.org/licenses/gpl-3.0-standalone.html>.
*
* SPDX-License-Identifier: GPL-3.0-or-later <https://spdx.org/licenses/GPL-3.0-or-later.html>
*
*/
#include <stdio.h>
#include <string.h>
#include "bug.h"
#include "position.h"
#include "piece.h"
#include "chessdefs.h"
#include "bitboard.h"
#include "hyperbola-quintessence.h"
@@ -27,26 +37,25 @@ int main(int __unused ac, __unused char**av)
bb_file[i], bb_rank[i],
bb_knight[i], bb_king[i]);
}
bitboard_print_multi("a1-a8 a1-h8 a1-h1 a2-a7 a2-g7 a2-g2", 6,
sprintf(str, "between: %-22s%-22s%-22s%-22s%-22s%-22s",
"a1-a8", "a1-h8", "a1-h1", "a2-a7", "a2-g7", "a2-g2");
bitboard_print_multi(str, 6,
bb_between[A1][A8], bb_between[A1][H8],
bb_between[A1][H1], bb_between[A2][A7],
bb_between[A2][G7], bb_between[A2][G2]);
bitboard_print_multi("c3-c6 c3-f6 c3-f3 c3-e1 c3-c1 c3-a1 c3-a3 c3-a5", 8,
sprintf(str, "between: %-22s%-22s%-22s%-22s%-22s%-22s%-22s%-22s",
"c3-c6", "c3-f6", "c3-f3", "c3-e1", "c3-c1", "c3-a1", "c3-a3", "c3-a5");
bitboard_print_multi(str, 8,
bb_between[C3][C6], bb_between[C3][F6],
bb_between[C3][F3], bb_between[C3][E1],
bb_between[C3][C1], bb_between[C3][A1],
bb_between[C3][A3], bb_between[C3][A5]);
bitboard_print_multi("c4-c6 c4-f6 c4-f3 c4-e1 c4-c1 c4-a1 c4-a3 c4-a5", 8,
sprintf(str, "between: %-22s%-22s%-22s%-22s%-22s%-22s%-22s%-22s",
"c4-c6", "c4-f6", "c4-f3", "c4-e1", "c4-c1", "c4-a1", "c4-a3", "c4-a5");
bitboard_print_multi(str, 8,
bb_between[C4][C6], bb_between[C4][F6],
bb_between[C4][F3], bb_between[C4][E1],
bb_between[C4][C1], bb_between[C4][A1],
bb_between[C4][A3], bb_between[C4][A5]);
for (square_t sq = 0; sq < 64; ++sq) {
sprintf(str, "%2d %#lx %#lx knight", sq, bb_sq[sq], bb_knight[sq]);
bitboard_print(str, bb_knight[sq]);
//sprintf(str, "%2d %#lx %#lx knight", sq, bb_sq[sq], bb_king[sq]);
//bitboard_print(str, bb_king[sq]);
}
return 0;
}