5static bool on_board(int32_t col, int32_t row)
10static bool allows_row_delta(uint32_t piece, int32_t delta, int32_t distance,
bool unknown_piece_result)
15 return delta == distance;
17 return delta == -distance;
20 return delta == distance || delta == -distance;
22 return unknown_piece_result;
32 int32_t col_delta = to_col - from_col;
33 if (col_delta != 1 && col_delta != -1)
40static bool can_jump(
const struct Checkers_Board *board, int32_t col, int32_t row, int32_t dx, int32_t dy, uint32_t opponent)
42 int32_t to_col = col + 2 * dx;
43 int32_t to_row = row + 2 * dy;
49 return can_jump(board, col, row, 1, dy, opponent) ||
can_jump(board, col, row, -1, dy, opponent);
97 int32_t col_delta = to_col - from_col;
98 int32_t row_delta = to_row - from_row;
100 if (col_delta == 1 || col_delta == -1)
108 if ((col_delta != 2 && col_delta != -2) || !
allows_row_delta(piece, row_delta, 2,
true))
111 uint32_t jumped = board->
playable_by_col[(from_col + to_col) >> 1][(from_row + to_row) >> 2];
152 int32_t from_col = move_sequence->
fromCol;
153 int32_t from_row = move_sequence->
fromRow;
168 }
while (packed_to_rows | packed_to_cols);
static bool on_board(int32_t col, int32_t row)
enum Checkers_MoveValidation Checkers_ValidateSimpleMove(struct Checkers_Board *board, int32_t from_col, int32_t from_row, int32_t to_col, int32_t to_row)
static bool can_jump(const struct Checkers_Board *board, int32_t col, int32_t row, int32_t dx, int32_t dy, uint32_t opponent)
BOOL Checkers_CheckCapturePossible(struct Checkers_Board *board, uint32_t piece, int32_t col, int32_t row)
enum Checkers_MoveExecutionResult Checkers_ExecuteMoveSequence(struct Checkers_Board *board, struct Checkers_MoveSequence const *move_sequence)
enum Checkers_MoveValidation Checkers_ValidateMove(struct Checkers_Board *board, int32_t from_col, int32_t from_row, int32_t to_col, int32_t to_row)
static bool allows_row_delta(uint32_t piece, int32_t delta, int32_t distance, bool unknown_piece_result)
enum Checkers_MoveExecutionResult Checkers_ExecuteMove(struct Checkers_Board *board, int32_t from_col, int32_t from_row, int32_t to_col, int32_t to_row)
static bool side_has_capture(struct Checkers_Board *board, uint32_t player)
void Checkers_InitializeBoard(struct Checkers_Board *board)
static bool can_jump_in_row_direction(const struct Checkers_Board *board, int32_t col, int32_t row, int32_t dy, uint32_t opponent)
#define CHECKERS_COORDINATE_MASK
#define CHECKERS_COORDINATE_BITS
#define CHECKERS_BOARD_SIDE
#define CHECKERS_PLAYER2_BIT
#define CHECKERS_PLAYER_MASK
#define CHECKERS_PLAYER1_BIT
#define CHECKERS_LAST_COORDINATE
@ CHECKERS_PIECE_PLAYER1_MAN
@ CHECKERS_PIECE_PLAYER2_KING
@ CHECKERS_PIECE_PLAYER1_KING
@ CHECKERS_PIECE_PLAYER2_MAN
Checkers_MoveExecutionResult
@ CHECKERS_EXEC_TURN_COMPLETE_PROMOTED
@ CHECKERS_EXEC_TURN_COMPLETE
@ CHECKERS_EXEC_CAPTURE_CAN_CONTINUE
enum Checkers_Piece playable_by_col[0x8][0x4]
#define g_worldBonusStateArray