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:
26
src/board.c
26
src/board.c
@@ -1,4 +1,4 @@
|
||||
/* board.c - 8x8 board.
|
||||
/* board.c - 8x8 functions.
|
||||
*
|
||||
* Copyright (C) 2024 Bruno Raoult ("br")
|
||||
* Licensed under the GNU General Public License v3.0 or later.
|
||||
@@ -57,7 +57,7 @@ square_t sq_from_string(const char *sqstr)
|
||||
* board_print() - Print a board
|
||||
* @board: &board_t to print
|
||||
*/
|
||||
void board_print(piece_t *board)
|
||||
void board_print(const piece_t *board)
|
||||
{
|
||||
printf(" +---+---+---+---+---+---+---+---+\n");
|
||||
for (int rank = 7; rank >= 0; --rank) {
|
||||
@@ -82,7 +82,7 @@ void board_print(piece_t *board)
|
||||
*
|
||||
* Squares corresponding to @mask will be displayed in reverse colors.
|
||||
*/
|
||||
void board_print_mask(piece_t *board, bitboard_t mask)
|
||||
void board_print_mask(const piece_t *board, const bitboard_t mask)
|
||||
{
|
||||
// 6: blink
|
||||
# define REVERSE "\e[7m▌"
|
||||
@@ -106,3 +106,23 @@ void board_print_mask(piece_t *board, bitboard_t mask)
|
||||
}
|
||||
printf(" A B C D E F G H\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* board_print_raw - print raw (octal or FEN symbol) board
|
||||
* @bb: the bitboard
|
||||
* @type: int, 0 for octal, 1 for fen symbol
|
||||
*/
|
||||
void board_print_raw(const piece_t *board, const int type)
|
||||
{
|
||||
for (rank_t r = RANK_8; r >= RANK_1; --r) {
|
||||
for (file_t f = FILE_A; f <= FILE_H; ++f) {
|
||||
piece_t p = board[sq_make(f, r)];
|
||||
if (type) {
|
||||
printf("%s ", p == EMPTY? ".": piece_to_char_color(p));
|
||||
} else {
|
||||
printf("%02o ", p);
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user