-
Notifications
You must be signed in to change notification settings - Fork 1
/
struct.h
205 lines (149 loc) · 4.51 KB
/
struct.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/*description of the different structurs*/
#ifndef STRUCT_H
#define STRUCT_H
#define nbrW 7
#define nbrOfPlayer 3
#include <panel.h>
#include <ncurses.h>
#include "labyrinthAPI.h"
/*! \file struct.h
\brief Data structures use in the program.
\author Maeva Arlandis et Alexis Devillard
\version 6.2
\date 10 janvier 2017
*/
typedef struct _LStep{//case of lab to create path
struct _LStep* from;
struct _LStep* next;
int nature;//a lab movement or a player movement
int X;//position or row/line to move
int Y;
int lvlEnergy;//the curent level of enery at this step
int cost;
int heuristic;
}Lcase;
/**
* \struct _Node
* \brief Node is a case from the map.
* It is used in Astar mode.
*/
typedef struct _Node{//the nodes
int X,Y; /**< Position of the node in the map. */
int cost; /**< Distance from the player to the current node */
int heuristic; /**< Distance between the player and the treasure as the crows fly */
char *ncase; /**< Pointer to a case of the map in order to get the data of */
struct _Node * pathParent; /**< Pointer to get the Node evaluated before */
struct _Node * pathChild; /**< Pointer to get the Node evaluated after */
struct _Node * listNext; /**< Used if in Closedlist and Openlist */
}Node;
/**
* \struct _DijkstraNode
* \brief Node is a case from the map.
* It is used in Astar mode.
*/
typedef struct _DijkstraNode{//the nodes
int X,Y; /**< Position of the node in the map. */
int cost; /**< Distance from the player to the current node */
struct _DijkstraNode * listNext; /**< Used if in Closedlist and Openlist */
}DijkstraNode;
/**
* \struct _Graph
* \brief
*/
typedef struct _Graph {
int **grid; /**< */
int heigth;
int width;
int xG,yG;
int depth;
struct _Graph ** rotGraph[4];
}Graph;
/**
* \struct _Movement
* \brief Node is a case from the map.
* It is used in Astar mode.
*/
typedef struct _Movement{//the nodes for the clever mode
int pos[nbrOfPlayer][2]; /**< Position of the node in the map. */
t_move move;
int value;
Graph *graph;
int **map;
char *node;
int cost; /**< Distance from the player to the current node */
int heuristic; /**< Distance between the player and the treasure as the crows fly */
char *ncase; /**< Pointer to a case of the map in order to get the data of */
int energy[2];
int typeRot;
int valueRot;
int opCost;
struct _Movement * listNext;
struct _Movement * parent;
struct _Movement * childs;
}Movement;
/**
* \struct _Path
* \brief List of lab node and its size.
* It is used in Astar mode.
*/
typedef struct _Path {
Node * first; /**< Pointer to the first node of the path */
int size; /**< Number of cases in the Path */
}Path;
/**
* \struct _Player
* \brief Contains informations of position, energy and mode of a player.
*/
typedef struct _Player {
int lastX; /**< Last X position of the player */
int lastY;/**< Last Y position of the player */
int X;/**< Current X position of the player */
int Y; /**< Current Y position of the player */
int turn; /**< 1 if it is the turn of the player, 0 if it is the turn of the opponnent */
int energy; /**< Energy of the player, +1 every turn, -5 if the move is a rotation */
int mode; /**< Dumb, manual, random, A*, smart A* */
Path *toOtherP; /**< Path to go to the opponnent */
Path *toGoal; /**< Path to go to the treasure */
}Player;
/**
* \struct _Win
* \brief
*/
typedef struct _Win {
WINDOW *win; /**< */
char label[50]; /**< */
char **labButt; /**< */
int **posButt; /**< */
int numButt; /**< */
}Win;
/**
* \struct _Map
* \brief Contains informations of the Map.
*/
typedef struct _Map {//the labyrinth
//WINDOW *win;// to use with ncurses
char** listPlrName; /**< */
char** listSvrName; /**< */
char** listTimeOut; /**< */
char** listPrtName; /**< */
char PlayerName[25]; /**< Name of our player */
char ServerName[50]; /**< Server data */
int offline;
int contest;
char TimeOut[10]; /**< Max Time to Play */
char PortName[10]; /**< Port Name */
char name[50]; /**< Map Name */
char infoP1[10][50]; /**< Info Player 1 */
char infoP2[10][50]; /**< Info Player 2 */
int width; /**< Width of the map */
int heigth; /**< Heigth of the map */
char comments[5][100]; /**<comments to send to the opponnent */
char **cases; /**< */
Graph *graph;
Player* players[3];//[P1;P2;Tresor] /**< P1 is the opponnent, P2 is our player, P3 is the treasure */
PANEL *panels[nbrW+1]; /**< */
Win **guiWins; /**< */
int mvC,mvL; /**< */
int turn; /**< Number of played turn */
}Map;
#endif