summaryrefslogtreecommitdiff
path: root/src/search/moves.c
diff options
context:
space:
mode:
authorAargh Rai <aargh.rai+git@gmail.com>2026-02-24 22:49:43 +0530
committerAargh Rai <aargh.rai+git@gmail.com>2026-02-24 22:49:43 +0530
commit63fa6656749d1cdb6a54a001950048a9660f0d73 (patch)
tree39c7e0586c2ad761d65f56bdfd6c96f6bbfdccb9 /src/search/moves.c
parent9cd36deffadc4f5ab83f08c2999407b31354027e (diff)
pawn forward movement works?
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(