-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNAC.h
70 lines (56 loc) · 1.45 KB
/
NAC.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef NAC_H
#define NAC_H
#include <stdbool.h>
#define tableSize 3
typedef struct Move {
int x;
int y;
} Move;
typedef struct gameState *Game;
typedef enum { Naught, Cross, None =-1 } Player;
/*
Returns True if game is over, otherwise false.
*/
bool gameIsOver(Game g);
/*
Takes in a move, and if move is valid in current game state, the game state is updated
and the move is entered.
*/
void enterMove(Game g, Move m);
/*
Returns true if move is valid in current game state, otherwise returns false.
*/
bool validMove(Game g, Move m);
/*
Creates a new game, with p player being the player with the starting move.
*/
Game newGame(Player p);
/*
Removes all game related data specified by given game instance.
*/
void endGame(Game g);
/*
Returns the player who has the current turn.
*/
Player getPlayerTurn(Game g);
/*
Returns the player who made a move at position given.
If no move has been made at the position then -1 is returned.
*/
Player getCoordState(Game g, int x, int y);
/*
Returns an integer, representing the number of slots on the board that
has not been occupied by a player move yet.
*/
int getEmptySlots(Game g);
/*
Returns the player who has won the game. If the game has not been
won by any player, returns -1.
*/
Player getWinner(Game g);
/*
Returns true if game has ended, and game is a draw
otherwise returns false
*/
bool gameIsDraw(Game g);
#endif