From c5f6be3c3c618f9a01ff1d00bf778eef5d7af251 Mon Sep 17 00:00:00 2001 From: Ole Morud Date: Wed, 22 Jun 2022 20:58:04 +0200 Subject: [PATCH] Add comments for is_valid function --- chess.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/chess.c b/chess.c index 7ffed89..c8eb24a 100644 --- a/chess.c +++ b/chess.c @@ -210,13 +210,16 @@ int get_piece(char *str){ } - +/* + * Returns 1 if a move is valid, 0 otherwise + */ int is_valid(int* board, const int from, const int to, const int player){ int movedelta = (from - to) * player; printf("attempting to move %lc to %lc\t%i", 0x2659 + board[from], 0x2659 + board[to], movedelta); switch(board[from]){ + // PAWNS case P: case -P: switch(movedelta){ default: @@ -238,6 +241,8 @@ int is_valid(int* board, const int from, const int to, const int player){ return 1; break; } + + // the remaining pieces are left as an exercise for the reader default: return 0; }