add board_print, board_print_mask

This commit is contained in:
2024-03-02 07:10:23 +01:00
parent dc6ceb3407
commit a499893f32
9 changed files with 185 additions and 73 deletions

View File

@@ -11,12 +11,14 @@
*
*/
#ifndef BOARD_H
#define BOARD_H
#ifndef _BOARD_H
#define _BOARD_H
#include "brlib.h"
#include "chessdefs.h"
#include "piece.h"
#include "bitboard.h"
/* a square is defined as
* rrrfff
@@ -24,43 +26,6 @@
#define SQ_FILEMASK (007) /* warning, octal */
#define SQ_RANKMASK (070)
typedef enum {
_SSQUARE_ = -1, /* force signed enum */
A1 = 0, B1, C1, D1, E1, F1, G1, H1,
A2, B2, C2, D2, E2, F2, G2, H2,
A3, B3, C3, D3, E3, F3, G3, H3,
A4, B4, C4, D4, E4, F4, G4, H4,
A5, B5, C5, D5, E5, F5, G5, H5,
A6, B6, C6, D6, E6, F6, G6, H6,
A7, B7, C7, D7, E7, F7, G7, H7,
A8, B8, C8, D8, E8, F8, G8, H8,
SQUARE_MAX = 64,
SQUARE_NONE = 64
} square_t;
typedef enum {
_SFILE_ = -1, /* force signed enum */
FILE_A = 0, FILE_B, FILE_C, FILE_D, FILE_E, FILE_F, FILE_G, FILE_H,
FILE_MAX,
} file_t;
typedef enum {
_SRANK_ = -1, /* force signed enum */
RANK_1 = 0, RANK_2, RANK_3, RANK_4, RANK_5, RANK_6, RANK_7, RANK_8,
RANK_MAX,
} rank_t;
typedef enum {
NORTH = 8,
EAST = 1,
SOUTH = -NORTH,
WEST = -EAST,
NORTH_EAST = (NORTH + EAST),
SOUTH_EAST = (SOUTH + EAST),
SOUTH_WEST = (SOUTH + WEST),
NORTH_WEST = (NORTH + WEST),
} dir_t;
/* flip a 0-63 square:
* Vertical: G8 (62) becomes G1 (6)
@@ -100,4 +65,7 @@ static __always_inline rank_t sq_rank(square_t square)
extern const char *sq_to_string(const square_t sq);
extern square_t sq_from_string(const char *sq_string);
#endif /* BOARD_H */
extern void board_print(piece_t *board);
extern void board_print_mask(piece_t *board, bitboard_t mask);
#endif /* _BOARD_H */