-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheader.h
37 lines (26 loc) · 1.05 KB
/
header.h
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
#include <stdbool.h>
#ifndef CONNECT4_HEADER_H
#define CONNECT4_HEADER_H
#define ROWS 6
#define COLS 7
#define red 1
#define yellow 2
// Iterates over the indices of the array and prints them.
void display_board(int board [ROWS][COLS]);
// Sets all the elements in the array to "-"
void setup_board (int board[ROWS][COLS]);
bool column_full (int board[ROWS][COLS], int col);
// prompts the user to enter a move, and checks that it is valid
// for the supplied board and board size
// Returns the column that the user has entered, once it is valid (1-COLS)
int get_move (int board[ROWS][COLS], int color);
// adds a token of the given value (1 or 2) to the board at the
// given column (col between 1 and COLS inclusive)
// Returns 0 if successful, -1 otherwise
void add_move (int b[ROWS][COLS], int col, int colour );
// determines if the board is completely full or not
bool board_full (int board[ROWS][COLS]);
// determines who (if anybody) has won. Returns the player id of the
// winner, otherwise 0
int winner (int[ROWS][COLS]) ;
#endif //CONNECT4_HEADER_H