59 lines
1.2 KiB
C
59 lines
1.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
#pragma once
|
|
|
|
#include <stdint.h>
|
|
#include <limits.h>
|
|
#include "config.h"
|
|
|
|
// Only use big ints on architectures where it doesn't impact speed
|
|
#if INT_FAST16_MAX == INT_FAST64_MAX
|
|
typedef int rowsint_t;
|
|
typedef unsigned columnsint_t;
|
|
#define QUITCOLUMN UINT_MAX
|
|
typedef unsigned winint_t;
|
|
typedef uintmax_t column_t;
|
|
#else
|
|
typedef int_fast8_t rowsint_t;
|
|
typedef uint_fast8_t columnsint_t;
|
|
#define QUITCOLUMN UINT_FAST8_MAX
|
|
typedef uint_fast8_t winint_t;
|
|
typedef uint_fast8_t column_t;
|
|
#endif
|
|
|
|
#define WININT_FORMAT "%3d"
|
|
|
|
|
|
typedef struct {
|
|
bool player;
|
|
rowsint_t *height;
|
|
column_t *column;
|
|
rowsint_t rows;
|
|
columnsint_t columns;
|
|
} board_t;
|
|
|
|
typedef struct {
|
|
column_t *vertical2;
|
|
column_t *horizontal2;
|
|
column_t *diagonalUp2;
|
|
column_t *diagonalDown2;
|
|
column_t *vertical4;
|
|
column_t *horizontal4;
|
|
column_t *diagonalUp4;
|
|
column_t *diagonalDown4;
|
|
} directions_t;
|
|
|
|
typedef struct {
|
|
winint_t total;
|
|
winint_t horizontal;
|
|
winint_t vertical;
|
|
winint_t diagonalUp;
|
|
winint_t diagonalDown;
|
|
} wincount_t;
|
|
|
|
typedef struct {
|
|
wincount_t count0;
|
|
wincount_t count1;
|
|
column_t *win0;
|
|
column_t *win1;
|
|
directions_t same;
|
|
} wins_t;
|