Files
chess/engine/src/test.c
Josh c80826710d
All checks were successful
Python tests (make) / test (push) Successful in 10s
Python tests (make) / test (pull_request) Successful in 9s
Add fen loader and a test script for c
2025-08-16 12:44:04 -04:00

33 lines
728 B
C

/**
A quick test script to debug and visually inspect functions
and operations.
*/
#include <stdio.h>
#include <string.h>
#include "bitboard.h"
#include "fen.h"
static int popcount64(uint64_t x){ int c=0; while(x){ x&=x-1; ++c; } return c; }
static const char NAME[12] = {'P','N','B','R','Q','K','p','n','b','r','q','k'};
int main(void) {
const char *fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
struct Board b;
int rc = load_fen(&b, fen);
for (int i=0;i<12;i++) printf("%c: %d\n", NAME[i], popcount64(b.pieces[i]));
if (rc != 0) {
fprintf(stderr, "load_fen failed (rc=%d) for FEN:\n%s\n", rc, fen);
return 1;
}
print_board(&b);
return 0;
}