43 lines
901 B
C
43 lines
901 B
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
#pragma once
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include <limits.h>
|
|
#include "config.h"
|
|
|
|
// Use fastest available ints unless it's 64 bits because that is doing silly
|
|
#if INT_FAST16_MAX == INT_FAST64_MAX
|
|
typedef int rowsint_t;
|
|
typedef unsigned columnsint_t;
|
|
#define QUITCOLUMN UINT_MAX
|
|
typedef unsigned winint_t;
|
|
typedef unsigned 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 {
|
|
winint_t total;
|
|
winint_t horizontal;
|
|
winint_t vertical;
|
|
winint_t diagonalUp;
|
|
winint_t diagonalDown;
|
|
} wincount_t;
|
|
|
|
typedef struct {
|
|
bool player;
|
|
rowsint_t *height;
|
|
column_t *column;
|
|
rowsint_t rows;
|
|
columnsint_t columns;
|
|
wincount_t count0;
|
|
wincount_t count1;
|
|
} board_t;
|