Made configuring column size easier

This commit is contained in:
AnnaSnoeijs 2025-06-06 21:31:59 +02:00
parent b7a6b41b38
commit 07e65019bc
2 changed files with 21 additions and 14 deletions

View file

@ -19,6 +19,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#include <limits.h>
#include <getopt.h> #include <getopt.h>
#include "macros.h" #include "macros.h"
#include "config.h" #include "config.h"
@ -131,10 +132,14 @@ int main( int argc, char *argv[] ){
fprintf( stderr, "ERR: AMOUT OF ROWS MUST BE AT LEAST 1\n" ); fprintf( stderr, "ERR: AMOUT OF ROWS MUST BE AT LEAST 1\n" );
return -1; return -1;
} }
if( playboard.rows >= 32 ){ #define ROWOVERFLOW ( sizeof(column_t) * CHAR_BIT )
fprintf( stderr, "ERR: AMOUT OF ROWS MUST BE LESS THAN 32\n" ); if( playboard.rows >= ROWOVERFLOW ){
fprintf( stderr,
"ERR: AMOUT OF ROWS MUST BE LESS THAN %d\n", (int)ROWOVERFLOW
);
return -1; return -1;
} }
#undef ROWOVERFLOW
// Start the actual program // Start the actual program
printf( printf(
VERSIONSTRING VERSIONSTRING

26
types.h
View file

@ -11,23 +11,25 @@ typedef enum {
MOVECOUNT MOVECOUNT
} move_t; } move_t;
typedef int column_t;
typedef struct { typedef struct {
int player; int player;
int *height; column_t *height;
int *column; column_t *column;
uint8_t rows; uint8_t rows;
uint8_t columns; uint8_t columns;
} board_t; } board_t;
typedef struct { typedef struct {
int *vertical2; column_t *vertical2;
int *horizontal2; column_t *horizontal2;
int *diagonalUp2; column_t *diagonalUp2;
int *diagonalDown2; column_t *diagonalDown2;
int *vertical4; column_t *vertical4;
int *horizontal4; column_t *horizontal4;
int *diagonalUp4; column_t *diagonalUp4;
int *diagonalDown4; column_t *diagonalDown4;
} directions_t; } directions_t;
typedef struct { typedef struct {
@ -41,7 +43,7 @@ typedef struct {
typedef struct { typedef struct {
wincount_t count0; wincount_t count0;
wincount_t count1; wincount_t count1;
int *win0; column_t *win0;
int *win1; column_t *win1;
directions_t same; directions_t same;
} wins_t; } wins_t;