#include "../search.h" #include moves_t init_moves() { return init_moves_wcapacity(16); } moves_t init_moves_wcapacity(u32 capacity) { move_t* moves = malloc(capacity * sizeof(*moves)); return (moves_t) { .moves = moves, .capacity = capacity, .length = 0, }; } moves_t empty_moves() { return (moves_t) { .moves = 0, .capacity = 0, .length = 0, }; } int min(int a, int b) { if (a > b) return b; return a; } void add_move(moves_t* moves, square_t from, square_t to) { if (moves->moves == 0) return; if (moves->length + 1 >= moves->capacity) { moves->capacity += min(32, moves->capacity); moves->moves = realloc( moves->moves, moves->capacity * sizeof(*moves->moves) ); } moves->moves[moves->length] = (move_t){ .from = from, .to = to }; moves->length++; }