10#ifndef RSMC_ABSTRACTIONS_H
11#define RSMC_ABSTRACTIONS_H
38static inline bool rsmc_board_cell_is_valid(
const RsmcBoardCell cell)
49static_assert(
sizeof(
RsmcClassicBoard) == 64,
"unexpected padding in RsmcBoard");
59static_assert(
sizeof(
RsmcCoords) == 2,
"unexpected padding in RsmcCoords");
66static inline bool rsmc_coords_is_valid(
const RsmcCoords coords)
78static inline int rsmc_coords_to_index(
const RsmcCoords coords)
93static inline RsmcBitMask rsmc_index_to_bitmask(
const uint8_t index)
97 return (uint64_t)1 << index;
102 const RsmcBitMask mask = rsmc_index_to_bitmask(rsmc_coords_to_index(coords));
103 if (board.
black & mask)
105 if (board.
white & mask)
113 const RsmcBitMask mask = rsmc_index_to_bitmask(rsmc_coords_to_index(coords));
114 board.
black &= ~mask;
115 board.
white &= ~mask;
131 classic_board.
cells[y][x] =
132 rsmc_board_get_cell(board, (
RsmcCoords){.x = (int8_t)x, .y = (int8_t)y});
136 return classic_board;
144 const RsmcCoords coords = {.
x = (int8_t)x, .y = (int8_t)y};
146 board.
black |= rsmc_index_to_bitmask(rsmc_coords_to_index(coords));
148 board.
white |= rsmc_index_to_bitmask(rsmc_coords_to_index(coords));
@ RsmcBoardCellBlack
Definition abstractions.h:28
@ RsmcBoardCellCount
Definition abstractions.h:30
@ RsmcBoardCellEmpty
Definition abstractions.h:27
@ RsmcBoardCellWhite
Definition abstractions.h:29
uint8_t RsmcBoardCell
Board cell (empty, black, white)
Definition abstractions.h:25
Types and constants for rsmc.
uint64_t RsmcBitMask
Definition core.h:134
@ RsmcMinCoord
Minimal possible value for index on the 2-dimensional board.
Definition core.h:47
@ RsmcMaxCoord
Maximal possible value for index on the 2-dimensional board.
Definition core.h:51
@ RsmcBoardArea
Count of cells on the board.
Definition core.h:43
@ RsmcBoardSize
Size of one side of the board.
Definition core.h:39
Stores board as two RsmcBitMap for each player pieces.
Definition core.h:139
RsmcBitMap black
Definition core.h:142
RsmcBitMap white
Definition core.h:143
Stores board in 2-dimensional array of all RsmcBoardCell.
Definition abstractions.h:46
RsmcBoardCell cells[RsmcBoardSize][RsmcBoardSize]
Definition abstractions.h:47
Stores coords for the board. Coords might be invalid and negative.
Definition abstractions.h:55
int8_t x
Definition abstractions.h:56
int8_t y
Definition abstractions.h:57