-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.h
76 lines (63 loc) · 1.73 KB
/
main.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
71
72
73
74
75
76
#ifndef MAIN_HEADER_H
#define MAIN_HEADER_H
#define ANSI_COLOR_RED "\x1b[31m"
#define ANSI_COLOR_GREEN "\x1b[32m"
#define ANSI_COLOR_YELLOW "\x1b[33m"
#define ANSI_COLOR_BLUE "\x1b[34m"
#define ANSI_COLOR_MAGENTA "\x1b[35m"
#define ANSI_COLOR_CYAN "\x1b[36m"
#define ANSI_COLOR_RESET "\x1b[0m"
//'define BUF 256
#define BUF 512
#define KEY 6543
#define SHMSIZE 2*sizeof(int)+BUF+2*sizeof(pid_t)+160
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <signal.h>
#include <sys/socket.h>
extern void error(char message[BUF]);
extern void signalHandler(int signal);
extern int shmID;
extern void printBoard();
extern struct Configuration setConfig(char* file);
extern int connectToServer(int* sock, char* host, int port);
extern int performConnection(char* gameID, char* player, char* gamekind, int* sock);
extern int communication(int *socket, int pipe);
extern char* think();
extern int readServer(int *socket, char *buffer);
extern int writeServer(int *socket, char *buffer, char message[BUF]);
struct Spieldaten {
char gameName[BUF];
int playerNumber;
int playerCount;
pid_t thinker;
pid_t connector;
char field[8][8];
int thinkFlag;
};
struct Configuration{
char hostname[BUF];
int portnumber;
char gamekind[BUF];
};
struct moeglicherZug{
char zug[64];
int gewichtung;
};
struct queenData{
struct moeglicherZug bestMove;
int x; //akt Position
int y; //akt Position
int success; //erfolg 1 (also schlagen) sonst 0
char moveATM[64];
char field[8][8];
char enemyColour[2];
char ownColour;
};
#endif