20 BOOL capture_only = 0;
26 for (int32_t source_col = (source_row - 1) & 1; source_col <
CHECKERS_BOARD_SIDE; source_col += 2)
28 uint8_t source_piece = board_state->
playable_by_col[source_col][source_row >> 1];
40 move_cursor = move_list->
records;
49 int32_t column_step = source_col < 4 ? -2 : 2;
50 int32_t row_step = source_row < 4 ? -2 : 2;
51 int32_t first_col = source_col - column_step / 2;
52 int32_t first_row = source_row - row_step / 2;
54 for (int32_t column_choice = 0; column_choice < 2; ++column_choice)
56 int32_t to_col = first_col + column_choice * column_step;
58 for (int32_t row_choice = 0; row_choice < 2; ++row_choice)
60 int32_t to_row = first_row + row_choice * row_step;
66 .fromRow = source_row,
67 .packedToCols = to_col,
68 .packedToRows = to_row};
84 for (int32_t to_col = from_col - 2; to_col <= from_col + 2; to_col += 4)
86 for (int32_t to_row = from_row - 2; to_row <= from_row + 2; to_row += 4)
91 (*move_cursor_in_out)->fromCol = from_col;
92 (*move_cursor_in_out)->fromRow = from_row;
93 (*move_cursor_in_out)->packedToCols = to_col;
94 (*move_cursor_in_out)->packedToRows = to_row;
98 memcpy(&candidate_board, board, 0x20);
103 ++*move_cursor_in_out;
120 *move_cursor_in_out = &(*move_cursor_in_out)[1];
124 int32_t from_col = current_sequence->
fromCol;
125 int32_t from_row = current_sequence->
fromRow;
126 uint32_t packed_to_cols = current_sequence->
packedToCols;
127 uint32_t packed_to_rows = current_sequence->
packedToRows;
128 uint32_t jump_source_col = packed_to_cols >> ((uint8_t)pack_shift & 0x1f);
129 uint32_t jump_source_row = packed_to_rows >> ((uint8_t)pack_shift & 0x1f);
130 uint32_t next_pack_shift = pack_shift + 3;
132 for (int32_t column_delta = -2; column_delta <= 2; column_delta += 4)
134 int32_t to_col = column_delta + jump_source_col;
135 int32_t to_row = jump_source_row - 2;
137 for (int32_t row_choice = 0; row_choice < 2; ++row_choice, to_row += 4)
147 memcpy(&candidate_board, board, 0x20);
150 jump_source_col, jump_source_row, to_col, to_row);
152 (*move_cursor_in_out)->packedToCols =
153 (to_col << (next_pack_shift & 0x1f)) + packed_to_cols;
154 (*move_cursor_in_out)->packedToRows =
155 (to_row << (next_pack_shift & 0x1f)) + packed_to_rows;
161 ++*move_cursor_in_out;
162 (*move_cursor_in_out)->
fromCol = from_col;
163 (*move_cursor_in_out)->fromRow = from_row;
215 int32_t best_score = maximizing ? -0x3fffffff : 0x3fffffff;
217 for (int32_t i = --moves->
count; i >= 0; i = --moves->
count)
225 if (maximizing && score >= best_score)
236 else if (!maximizing && score <= best_score)
249 *out_best_move = moves->
records[*selected_index];
#define CHECKERS_COORDINATE_MASK
#define CHECKERS_BOARD_SIDE
#define CHECKERS_NORMAL_SCORE_JITTER
@ CHECKERS_DIFFICULTY_HARD
@ CHECKERS_DIFFICULTY_EASY
@ CHECKERS_DIFFICULTY_NORMAL
#define CHECKERS_PLAYER_MASK
#define CHECKERS_EASY_SCORE_JITTER
#define CHECKERS_HARD_SCORE_JITTER
#define CHECKERS_MAN_VALUE
#define CHECKERS_RENDER_NODE_MASK
#define CHECKERS_EDGE_PENALTY
#define CHECKERS_KING_VALUE
#define CHECKERS_LAST_COORDINATE
@ CHECKERS_PIECE_PLAYER1_MAN
@ CHECKERS_PIECE_PLAYER1_KING
@ CHECKERS_PIECE_PLAYER2_MAN
Checkers_MoveExecutionResult
@ CHECKERS_EXEC_CAPTURE_CAN_CONTINUE
@ CHECKERS_STATE_AI_RENDER_TICK
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)
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)
int32_t Checkers_SearchBestMove(struct Checkers_Board *board, int32_t depth, struct Checkers_MoveSequence *out_best_move, enum Checkers_Player player, int32_t alpha, int32_t beta)
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)
BOOL Checkers_ProcessInputAndRender(void)
#define g_checkersAINodeCounter
#define g_checkersAIThinkTimeout
#define g_checkersJumpBuffer
#define g_checkersAIMove_fromRow
#define g_checkersAIMove_toRow
#define g_checkersAIMove_fromCol
#define g_checkersMinigameState
#define g_checkersAIMove_toCol
uint32_t Math_GenerateRandom(uint32_t range)
void _longjmp(struct CRT_JumpBuffer3 *jump_buffer, int32_t value)
void Checkers_ExpandCaptureSequences(struct Checkers_Board *board, struct Checkers_MoveSequence **move_cursor_in_out, uint32_t pack_shift)
void Checkers_AppendCaptureMoveSequences(struct Checkers_Board *board, int32_t from_col, int32_t from_row, struct Checkers_MoveSequence **move_cursor_in_out)
BOOL Checkers_BuildMoveList(struct Checkers_Board *board_state, enum Checkers_Player player, struct Checkers_MoveList *move_list)
int32_t Checkers_EvaluateBoardScore(struct Checkers_Board *board)
int32_t Checkers_SearchWithMoveList(struct Checkers_Board *board, int32_t depth, struct Checkers_MoveSequence *out_best_move, enum Checkers_Player player, int32_t alpha, int32_t beta, struct Checkers_MoveList *moves, int32_t *selected_index)
enum Checkers_Piece playable_by_col[0x8][0x4]
struct Checkers_MoveSequence records[0x3c]
#define g_worldBonusStateArray