-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboard.h
133 lines (116 loc) · 2.96 KB
/
board.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
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include "CAN/CAN.h"
#define DIM 15
// Definizione delle costanti per gli shift
#define PLAYER_ID_SHIFT 24
#define MOVE_TYPE_SHIFT 20
#define WALL_ORIENTATION_SHIFT 16
#define NEW_X_POS_SHIFT 8
#define NEW_Y_POS_SHIFT 0
// Definizione delle costanti per le maschere
#define PLAYER_ID_MASK 0xFF
#define MOVE_TYPE_MASK 0xF
#define WALL_ORIENTATION_MASK 0xF
#define NEW_X_POS_MASK 0xFF
#define NEW_Y_POS_MASK 0xFF
typedef enum {
None,
SingleBoard,
TwoBoard
} BoardType;
typedef enum {
NA,
Human,
NPC
} GameMode;
typedef enum {
EASY,
HARD
} NPCMode;
typedef enum {
FROZEN,
MENU,
MOVEPLAYER,
MOVEWALL
} Mode;
typedef enum {
NOTVISITED,
VISITED
} Visit;
typedef enum {
NOTMOVING,
MOVEDAWAY,
MOVING
} StateWall;
typedef enum {
UNKNOWN,
EMPTY,
MKEMPTY,
POSSMOVE,
SELMOVE,
PLAYER1,
PLAYER2,
NOWALL,
WALL
} StateCell;
typedef enum {
NONE,
CROSS,
VERTICAL,
HORIZONTAL
} OrientationWall;
// Struttura dati per rappresentare una casella della scacchiera
typedef struct {
StateCell state;
double x_pos;
double y_pos;
OrientationWall orWall;
StateWall wallState;
} Cell;
typedef struct {
StateCell state;
} testCell;
// Struttura dati per rappresentare la scacchiera di gioco
typedef struct {
Cell cells[DIM][DIM];
} Board;
typedef struct {
testCell cells[DIM][DIM];
} testBoard;
bool CheckWin(Board* board, StateCell PLAYER);
void initBoard(Board* board);
void resetBoard(Board* board);
void calcPossMovesPlayer(Board* board, StateCell PLAYER);
void testcalcPossMovesPlayer(testBoard* board, StateCell PLAYER);
void MovePlayerUp(Board* board, StateCell PLAYER);
void MovePlayerRight(Board* board, StateCell PLAYER);
void MovePlayerLeft(Board* board, StateCell PLAYER);
void MovePlayerDown(Board* board, StateCell PLAYER);
void MovePlayerDownLeft(Board* board, StateCell PLAYER);
void MovePlayerDownRight(Board* board, StateCell PLAYER);
void MovePlayerUpLeft(Board* board, StateCell PLAYER);
void MovePlayerUpRight(Board* board, StateCell PLAYER);
void MoveWallUp(Board* board);
void MoveWallLeft(Board* board);
void MoveWallRight(Board* board);
void MoveWallDown(Board* board);
void UnsetPossMoves(testBoard *board);
void UnsetSelMoves(testBoard *board);
void RotateMovingWall(Board* board);
void UnsetMovingWalls(Board *board);
void UnsetMovedWalls(Board *board);
void ConfirmMovePlayer(Board* board, StateCell PLAYER);
void testConfirmMovePlayer(testBoard* board, StateCell PLAYER);
bool ConfirmMoveWall(Board* board);
void testConfirmMoveWall(Board* board);
void copyBoard(testBoard* dest, Board* source);
void copytestBoard(testBoard* dest, testBoard* source);
bool explore_possMoves(testBoard* board, StateCell PLAYER);
bool CheckValidWall(Board* board);
void bestPathNPC(testBoard* board, StateCell NPC, int *best_distance, int depth);
void MakeOpponentMove(Board* board, Move* opponentMove);
void MakeNPCMove(Board* board, StateCell NPC);