-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.h
71 lines (57 loc) · 1.7 KB
/
utils.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
#ifndef __UTILS__
#define __UTILS__
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <termios.h>
#include <stdbool.h>
#include <stdint.h>
#include <time.h>
#include <signal.h>
#define SIZE 4
#define _XOPEN_SOURCE 500
/**
* Data structure containing the information about the game state
* Variables have the same name as the global variables in pacman.c
* representing the state of the game.
*/
struct state_s{
int Loc[5][2]; //Location of Ghosts and Pacman
int Dir[5][2]; //Direction of Ghosts and Pacman
int StartingPoints[5][2]; //Default location in case Pacman/Ghosts die
int Invincible; //Check for invincibility
int Food; //Number of pellets left in level
int Level[29][28]; //Main level array
int LevelNumber; //What level number are we on?
int GhostsInARow; //Keep track of how many points to give for eating ghosts
int tleft; //How long left for invincibility
int Points; //Initial points
int Lives;
};
typedef struct state_s state_t;
/**
* Move type
*/
typedef enum moves{
left=0,
right=1,
up=2,
down=3
} move_t;
/**
* Back Propagation type
*/
typedef enum propagation{
max=0,
avg=1
} propagation_t;
/**
* Executes an action, updates the board and the score, and return true if the direction of Pacman has changed,
* and false otherwise
*/
bool execute_move_t(state_t* state, move_t move);
void MovePacmanSim(state_t* state);
void MoveGhostsSim(state_t* state);
void CheckCollisionSim(state_t* state);
#endif