summaryrefslogtreecommitdiff
path: root/src/search/moves.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/search/moves.c')
-rw-r--r--src/search/moves.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/search/moves.c b/src/search/moves.c
index 57797e7..7089886 100644
--- a/src/search/moves.c
+++ b/src/search/moves.c
@@ -1,11 +1,12 @@
#include "../search.h"
+#include <assert.h>
#include <stdlib.h>
-moves_t init_moves() {
- return init_moves_wcapacity(16);
+moves_t moves_init() {
+ return moves_init_wcapacity(16);
}
-moves_t init_moves_wcapacity(u32 capacity) {
+moves_t moves_init_wcapacity(u32 capacity) {
move_t* moves = malloc(capacity * sizeof(*moves));
return (moves_t) {
.moves = moves,
@@ -14,7 +15,7 @@ moves_t init_moves_wcapacity(u32 capacity) {
};
}
-moves_t empty_moves() {
+moves_t moves_empty() {
return (moves_t) {
.moves = 0,
.capacity = 0,
@@ -28,7 +29,9 @@ int min(int a, int b) {
}
void add_move(moves_t* moves, square_t from, square_t to) {
- if (moves->moves == 0) return;
+ assert(moves->moves != 0);
+ assert(from != to);
+
if (moves->length + 1 >= moves->capacity) {
moves->capacity += min(32, moves->capacity);
moves->moves = realloc(