I am making a connect 4 board game in c. My problem is trying to make the logic to calculate if the array has been filled up.
I have tried changing my logic multiple times, but only using if statement. I am basically clueless at this point
// Returns TRUE if the specified column in the board is completely full
// FALSE otherwise
// col should be between 1 and COLS
int column_full ( int board[COLS][ROWS], int col ){
// check the TOP spot in the specified column (remember column is between 1 and COLS, NOT 0 and COLS-1 so you'll need to modify slightly
// if top spot isn't empty (0 is empty) then the column is full, return 1
if (board[col -1][0]!=0){
return(1);
}
// otherwise, return 0
return(0);
//return column_full_lib ( board, col ) ;
}
Expected result is when board is filled, it should return 0: When it is not filled up as in column 2, it should return 1
[x][][][][]
[o][x][][][]
[o][o][][][]
[x][o][][][]
[o][x][][][]
[x][x][][][]
Aucun commentaire:
Enregistrer un commentaire