-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.m
57 lines (51 loc) · 1.11 KB
/
main.m
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
clear
start1 = [1,250];
start2 = [570,250];
goal = [285,250];
path1 = [10,20;20,30;30,50];
path2 = [100,200;200,300;300,500];
tree1 = [];
tree2 = [];
time1 = 0;
time2 = 0;
done1 = false;
done2 = false;
%map = generateMap();
map = generateEasyMap();
map(183,500)
fmap = figure;
imshow(map')
hold on
scatter(start1(1,1),start1(1,2),'red')
scatter(start2(1,1),start2(1,2),'blue')
scatter(goal(1,1),goal(1,2))
pause;
for i = 1:10000000
if done1 == false
tic;
[path1, tree1, done1] = algorithm1(map, path1, tree1, start1, goal)
time1 = time1 + toc;
else
plot(path1(:,1),path1(:,2),'r')
end
if done2 == false
tic;
%algorithm 2
%[path2, tree2, done2] = algorithm2(map, path1, tree2, start1, goal)
time2 = time2 +toc;
else
%plot(path2(:,1),path2(:,2),'b')
end
%plot tree and path
plotTree1(tree1);
%plotTree2(tree2);
drawnow
text1 = sprintf('Player 1 time: %f \n',time1);
text2 = sprintf('Player 2 time: %f \n',time2);
clc
disp(text1);
disp(text2);
if(done1 && done2)
break;
end
end