-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
83 lines (77 loc) · 2.64 KB
/
main.cpp
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
//
// main.cpp
// A_Star_
//
// Created by Balaji Krishnamurthy on 1/3/21.
// Copyright © 2021 Balaji Krishnamurthy. All rights reserved.
//
#include "a_star_.hpp"
int main(int argc, const char * argv[]) {
std::cout << "\nWelcome to the A-Star path planning demo. You will enter the grid size of your choice or proceed with the default grid. \nThe obstacles are generated by random.\n\n";
std::cout << "Enter the grid size m by n. \nOtherwise, enter twice to proceed with the default. The default is 6 X 6.\n\n";
int m = 6;
int n = 6;
std::string str_m = "";
std::string str_n = "";
std::getline(std::cin, str_m);
std::getline(std::cin, str_n);
if(!str_m.empty())
{
std::stringstream ss (str_m);
ss >> m;
}
if(!str_n.empty())
{
std::stringstream ss (str_n);
ss >> n;
}
std::cout << "\n\nEnter the no. of obstacles you want to throw into the grid. Default is 5.\n\n";
int obs = 5;
std::string str_obs = "";
std::getline(std::cin, str_obs);
if(!str_obs.empty())
{
std::stringstream ss (str_obs);
ss >> obs;
}
std::cout << "\n\n";
std::cout << "Enter the starting node. The default is (0,0)\n\n";
std::pair<int, int> start_point = {0, 0};
std::string str_start_point_first = "";
std::string str_start_point_second = "";
std::getline(std::cin, str_start_point_first);
std::getline(std::cin, str_start_point_second);
if(!str_start_point_first.empty())
{
std::stringstream ss (str_start_point_first);
ss >> start_point.first;
}
if(!str_start_point_second.empty())
{
std::stringstream ss (str_start_point_second);
ss >> start_point.second;
}
std::cout << "\n\n";
std::cout << "Enter the goal node. The default is (4,5)\n\n";
std::pair<int, int> goal_point = {4,5};
std::string str_goal_point_first = "";
std::string str_goal_point_second = "";
std::getline(std::cin, str_goal_point_first);
std::getline(std::cin, str_goal_point_second);
if(!str_goal_point_first.empty())
{
std::stringstream ss (str_goal_point_first);
ss >> goal_point.first;
}
if(!str_goal_point_second.empty())
{
std::stringstream ss (str_goal_point_second);
ss >> goal_point.second;
}
std::cout << "\n\n\n";
Finder F(start_point, goal_point, m, n, obs);
F.ComputePath();
F.PrintResult();
std::cout << std::endl;
return 0;
}