-
Notifications
You must be signed in to change notification settings - Fork 0
/
A_star.c
68 lines (51 loc) · 1.65 KB
/
A_star.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
57
58
59
60
61
62
63
64
65
66
67
68
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <error.h>
#include "D:/Desktop/PAR_scripts/router-dijkstra/headers/prototypes.h"
#include "D:/Desktop/PAR_scripts/router-dijkstra/headers/aStar.h"
#include "D:/Desktop/PAR_scripts/router-dijkstra/headers/Heap.h"
#include "D:/Desktop/PAR_scripts/router-dijkstra/headers/grid.h"
int main(int argc, char **argv) {
printf("\nA-star initialized\n");
if (argc != 7) {
printf("Uso: ./grid_maker.exe <width> <length> <src.row> <src.col> <dest.row> <dest.col>\n");
return 1;
}
int width;
int height;
pair src, dest;
sscanf(argv[1], "%d", &width);
sscanf(argv[2], "%d", &height);
sscanf(argv[3], "%d", &src.row);
sscanf(argv[4], "%d", &src.col);
sscanf(argv[5], "%d", &dest.row);
sscanf(argv[6], "%d", &dest.col);
pair gridDim;
gridDim.col = width;
gridDim.row = height;
int** grid = allocateGrid(gridDim.row, gridDim.col);
const char* filename = "D:/Desktop/PAR_scripts/router-dijkstra/gridCell.txt"; // File with grid
// int width = gridDim.col;
// int height = gridDim.row;
readGrid(filename, grid, gridDim.col, gridDim.row);
if (grid == NULL) {
printf("grid null.\n");
return 1;
}
// Source is the left-most bottom-most corner
// pair src;
// src.row = 0;
// src.col = 0;
// Destination is the left-most top-most corner
// pair dest;
// dest.row = 1250;
// dest.col = 10;
// dest.row = 0;
// dest.col = 10;
if(aStar(grid, gridDim, src, dest)!=0)
printf("Error\n");
freeGrid(grid, gridDim.row);
return 0;
}