-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdecide.c
42 lines (35 loc) · 983 Bytes
/
decide.c
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
// decide.c
// where should the mouse go next?
#include <stdbool.h>
#include "walls.h"
#include "decide.h"
#include "flood.h"
#include "direction.h"
#include "tremaux.h"
// all functions should return a turn value
// L_TURN R_TURN U_TURN or NO_TURN
int r_wall(void) {
// decide while getting walls
if (right_wall() == false) return R_TURN;
else if (front_wall() == false) return NO_TURN;
else if (left_wall() == false) return L_TURN;
else return U_TURN;
}
int l_wall(void) {
// decide while getting walls
if (left_wall() == false) return L_TURN;
else if (front_wall() == false) return NO_TURN;
else if (right_wall() == false) return R_TURN;
else return U_TURN;
}
int tremaux(Maze * maze, Mouse * mouse) {
// place values
// return decision
return tremaux_decide(maze, mouse);
}
int flood(Maze * maze, Mouse * mouse, int x, int y) {
// flood maze
flood_maze(maze, x, y);
// get turn
return flood_turn(maze, mouse);
}