aboutsummaryrefslogtreecommitdiff
path: root/voerbak/board.h
blob: 47f39b2882b50b714eb216ce47fa854083a2b774 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#pragma once
#include <stdbool.h>

/**
 * @brief Structure to store a board
 *
 * @param width Board width
 * @param height Board height
 * @param length Board state array length (width * height)
 * @param board Board state array
 */
typedef struct {
	int width;
	int height;
	int length;
	int* board;
} Board;

/**
 * @brief Create new board
 *
 * @param width Board width
 * @param height Board height
 *
 * @return Empty board
 */
Board* createBoard(int, int);

/**
 * @brief Create a copy of board
 *
 * @param board Original board
 *
 * @return Pointer to new board
 */
Board* createCopy(Board*);

/**
 * @brief Print the board array
 */
void printBoard(Board*);

/**
 * @brief Check if the board is full (draw)
 *
 * @return `true` board is full
 */
bool boardFull(Board*);

/**
 * @brief Drop a disc into the board
 *
 * @return New disc position or -1 if disc wasn't dropped
 */
int dropFisje(Board*, int, int);