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
|
#ifndef GHOSTS_H_SENTRY
#define GHOSTS_H_SENTRY
#include "field.h"
enum {
red_y = 14,
red_x = 15,
red_home_y = -1,
red_home_x = 25,
pink_y = red_y + 1,
pink_x = red_x - 2,
pink_home_y = red_home_y,
pink_home_x = 2,
blue_y = red_y,
blue_x = red_x-1,
blue_home_y = 29,
blue_home_x = 27,
orange_y = red_y + 1,
orange_x = red_x - 3,
orange_home_y = blue_home_y,
orange_home_x = 0,
pink_shift = 4,
blue_shift = 2,
orange_search_limit = 8,
red_prison_y = 14,
red_prison_x = 14,
pink_prison_y = red_prison_y + 1,
pink_prison_x = red_prison_x,
blue_prison_y = red_prison_y,
blue_prison_x = red_prison_x - 1,
orange_prison_y = red_prison_y + 1,
orange_prison_x = red_prison_x - 1,
liberation_y = 12
};
enum ghost_color { red, pink, blue, orange };
enum behavior_mode { chase, scatter, frightened };
enum movement_direction { left, right, up, down, none };
struct coordinates {
int y;
int x;
};
struct prison {
int prison_counter;
struct coordinates position;
int active;
};
struct capture {
struct coordinates previous_pac_position;
struct coordinates previous_ghost_position;
int status;
};
struct ghost_type {
struct coordinates position;
struct coordinates home_position;
enum ghost_color color;
enum movement_direction direction;
struct prison prison_params;
struct capture capture_info;
int reached_pacman;
};
void initialize_ghost(struct ghost_type *ghost, enum ghost_color color);
void pull_out_ghosts(int *get_out_stage,
struct ghost_type *red_ghost,
struct ghost_type *pink_ghost,
struct ghost_type *blue_ghost,
struct ghost_type *orange_ghost);
struct queue;
void clear_ghost_positions(game_space field, const struct queue *eaten_coins,
const struct ghost_type *red_ghost,
const struct ghost_type *pink_ghost,
const struct ghost_type *blue_ghost,
const struct ghost_type *orange_ghost);
void make_ghost_moves(game_space field,
struct ghost_type *red_ghost,
struct ghost_type *pink_ghost,
struct ghost_type *blue_ghost,
struct ghost_type *orange_ghost,
struct queue *eaten_coins);
struct pacman;
void redirect(game_space field, enum intersection_type paths,
struct ghost_type *ghost, struct coordinates target_point,
void (*pathfinder)(game_space, struct ghost_type*,
struct coordinates target_point));
void random_redirect(game_space field, struct ghost_type *ghost);
void breadth_first_search(game_space field, struct ghost_type *ghost,
struct coordinates target_point);
void compute_distance_between_points(game_space field, struct ghost_type *ghost,
struct coordinates target_point);
struct coordinates identify_target_in_front(struct pacman pac, int shift);
struct coordinates identify_blue_target(struct pacman pac,
const struct ghost_type *red_ghost);
void reverse_all_ghosts(struct ghost_type *red_ghost,
struct ghost_type *pink_ghost,
struct ghost_type *blue_ghost,
struct ghost_type *orange_ghost);
void set_frightened_status(int status, struct ghost_type *red_ghost,
struct ghost_type *pink_ghost,
struct ghost_type *blue_ghost,
struct ghost_type *orange_ghost);
int is_pac_nearby(struct pacman pac, struct ghost_type ghost);
void set_capture_info(struct ghost_type *ghost, const struct pacman *pac);
void catch_ghost(const game_space field, struct ghost_type *ghost);
#endif
|