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,39 +1,43 @@
//#include <stdio.h>
/* fen-test.c - basic fen 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 "bug.h"
#include <stdio.h>
#include "chessdefs.h"
#include "bitboard.h"
#include "position.h"
#include "fen.h"
int main(int ac, char**av)
#include "common-test.h"
int main(__unused int ac, __unused char**av)
{
pos_t *pos;
bitboard_t mask = A1bb | C3bb | A8bb | G7bb | H8bb | H1bb;
const char *fen;
char revfen[128];
int comp;
//debug_init(5, stderr, true);
//pos_pool_init();
bitboard_init();
pos = pos_new();
if (ac == 1) {
fen = startfen;
startpos(pos);
} else {
fen = av[1];
fen2pos(pos, fen);
}
pos_print(pos);
pos_print_mask(pos, mask);
printf("ULL=#%lx %#lx %#lx %#lx #%lx\n", A5bb, H5bb, H6bb, H7bb, H8bb);
printf("ULL=%llx %llx %llx\n", mask(A5), mask(H7), mask(H8));
pos2fen(pos, revfen);
//printf("reverse fen=[%s]\n", pos2fen(pos, NULL));
comp = strcmp(fen, revfen);
printf("compare=%d - %s\n", comp, comp? "NOK": "OK");
pos_print_board_raw(pos, 0);
pos_print_board_raw(pos, 1);
bitboard_init();
while ((fen = next_fen(FEN))) {
if (!(pos = fen2pos(NULL, fen))) {
printf("fen = [%s] **INVALID\n", fen);
} else {
pos_print_raw(pos, 1);
pos2fen(pos, revfen);
printf("fen = [%s]\nrev = [%s]", fen, revfen);
if (strcmp(fen, revfen))
printf(" **FIXED\n");
pos_del(pos);
}
}
}