-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.h
37 lines (29 loc) · 1017 Bytes
/
game.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
#ifndef GAME_H
#define GAME_H
typedef int bool;
#define true 1
#define false 0
#define ADMIN_USERNAME "admin"
typedef struct
{
char name[10];
char piece; //either x or o
int isHuman; //true(1) for human player, false(0) for computer player
#ifdef SOCKET_V
int fd;
char *buf;
int buf_len;
#endif
} player;
enum game_state_t { START_STATE, PLAYER_STATE, GAME_STATE, END_STATE };
int isWin(int *moves);
void resetGame(player **players, int *moves, int *num_moves, int *player_num);
void makeMove(player **players, int *num_moves, int *moves, int *player_num);
void write_move(int *num_moves, int *moves, int *player_num, int move);
int move_to_win(int *moves, int player_num);
void ai_move(player **players, int *moves, int *player_num, int *num_moves);
void player_move(player **players, int *moves, int *player_num, int *num_moves);
player **initGame(int *moves, int *num_moves, int *player_num);
void free_players(player **players);
void drawBoard(player **players, int num_moves, int *moves);
#endif