From c57fdac8fb91a29205bda4a8d8a6f91f4c1ec172 Mon Sep 17 00:00:00 2001 From: Kai Stevenson Date: Wed, 7 Dec 2022 15:20:01 -0800 Subject: fixed check detection. changed all board[8][8] arguments to int** --- chesshelpers.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'chesshelpers.c') diff --git a/chesshelpers.c b/chesshelpers.c index a0caadd..7a8178b 100644 --- a/chesshelpers.c +++ b/chesshelpers.c @@ -1,15 +1,16 @@ #include #include +#include #include "vector.h" #include "chesshelpers.h" int in_board(vector_t position) { return position.mx < 8 && position.mx >= 0 && position.my < 8 && position.my >= 0; } -int is_empty(int board[8][8], vector_t position) { +int is_empty(int** board, vector_t position) { return board[position.mx][position.my] == 0; } -int is_color(int board[8][8], vector_t position, int color) { +int is_color(int** board, vector_t position, int color) { if(color == 0) { return board[position.mx][position.my] >= 1 && board[position.mx][position.my] <= 6; } @@ -26,7 +27,7 @@ char* get_readable_coords(vector_t position) { return output; } //gets the proper algebraic notation for the move -char* get_move_name(int board[8][8], vector_t origin, vector_t end) { +char* get_move_name(int** board, vector_t origin, vector_t end) { int piece = board[origin.mx][origin.my]; if(piece > 6) { piece -= 6; @@ -59,11 +60,12 @@ char* get_move_name(int board[8][8], vector_t origin, vector_t end) { return output; } } -int** clone_board(int board[8][8]) { - int** newBoard = malloc(8 * 8 * sizeof(int)); +int** clone_board(int** board) { + int** newBoard = malloc(8 * sizeof(int*)); for(int r = 0; r < 8; r++) { + newBoard[r] = malloc(8 * sizeof(int)); for(int c = 0; c < 8; c++) { - newBoard[c][r] = board[c][r]; + newBoard[r][c] = board[r][c]; } } return newBoard; -- cgit v1.3.1