-
Notifications
You must be signed in to change notification settings - Fork 0
/
hidato_solver.c
56 lines (49 loc) · 1.01 KB
/
hidato_solver.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "hidato_solver.h"
int main(int argc, char *argv[])
{
BOOL backtracking, smart, hillclimbing;
char input[MAX_FILE_LENGTH];
struct Board board;
struct Num_Coordinates numbers;
backtracking = smart = hillclimbing = FALSE;
printf("\n WELCOME TO HIDATO!\n\n");
if (argc != 3)
{
printf("Invalid input: Please specify the algorithm: -b or -sb or -h");
printf(", and a valid file.");
}
else
{
if (strcmp(argv[ALGORITHM], "-b") == 0)
{
backtracking = TRUE;
}
else if (strcmp(argv[ALGORITHM], "-sb") == 0)
{
backtracking = TRUE;
smart = TRUE;
}
else if (strcmp(argv[ALGORITHM], "-h") == 0)
{
hillclimbing = TRUE;
}
else
{
printf("Invalid input: Please specify a valid algorithm: -b or -sb or -h.\n");
}
file_to_string(argv[FILE_NAME], input);
}
if (initialise_state(input, &board, &numbers))
{
if (backtracking)
{
run_backtracker(&board, &numbers, smart);
}
else if (hillclimbing)
{
run_hillclimber(&board, &numbers);
}
}
(void)getchar();
return 0;
}