diff --git a/.idea/.idea.RobotIntelFinal/.idea/contentModel.xml b/.idea/.idea.RobotIntelFinal/.idea/contentModel.xml
index 94ec944..8bae461 100644
--- a/.idea/.idea.RobotIntelFinal/.idea/contentModel.xml
+++ b/.idea/.idea.RobotIntelFinal/.idea/contentModel.xml
@@ -7,9 +7,11 @@
+
+
@@ -35,10 +37,10 @@
-
-
-
-
+
+
+
+
@@ -46,7 +48,6 @@
-
@@ -56,6 +57,7 @@
+
diff --git a/.idea/.idea.RobotIntelFinal/.idea/workspace.xml b/.idea/.idea.RobotIntelFinal/.idea/workspace.xml
index 8de59d7..9ff8581 100644
--- a/.idea/.idea.RobotIntelFinal/.idea/workspace.xml
+++ b/.idea/.idea.RobotIntelFinal/.idea/workspace.xml
@@ -18,29 +18,21 @@
-
+
+
-
-
-
+
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
@@ -129,7 +121,6 @@
-
@@ -138,19 +129,22 @@
-
-
-
-
+
+
+
+
+
+
+
@@ -228,7 +222,7 @@
-
+
diff --git a/ConsoleApp/ConsoleApp.csproj b/ConsoleApp/ConsoleApp.csproj
index 3bc0189..f73aec2 100644
--- a/ConsoleApp/ConsoleApp.csproj
+++ b/ConsoleApp/ConsoleApp.csproj
@@ -22,7 +22,7 @@
PreserveNewest
-
+
PreserveNewest
diff --git a/ConsoleApp/CoreModule.cs b/ConsoleApp/CoreModule.cs
index e0e2585..0db5b04 100644
--- a/ConsoleApp/CoreModule.cs
+++ b/ConsoleApp/CoreModule.cs
@@ -15,6 +15,7 @@ namespace ConsoleApp
container.Register(Reuse.Singleton);
container.Register(Reuse.Singleton);
container.Register(Reuse.Singleton);
+ container.Register(Reuse.Singleton);
}
diff --git a/ConsoleApp/plot.py b/ConsoleApp/HexPlot.py
similarity index 85%
rename from ConsoleApp/plot.py
rename to ConsoleApp/HexPlot.py
index bf2fd78..a10fbe8 100644
--- a/ConsoleApp/plot.py
+++ b/ConsoleApp/HexPlot.py
@@ -10,7 +10,7 @@ if __name__ == "__main__":
ym = []
xf = []
yf = []
- with open("/Users/brady.bodily/Documents/Repositories/CS5890_Robot_Intelligence/RobotIntelFinal/ConsoleApp/Output/SavedList.txt") as c:
+ with open("/Users/brady.bodily/Documents/Repositories/CS5890_Robot_Intelligence/RobotIntelFinal/ConsoleApp/Output/HexPath.txt") as c:
for line in c:
x, y = line.split()
xc.append(int(x))
@@ -22,7 +22,7 @@ if __name__ == "__main__":
xm.append(int(x))
ym.append(int(y))
- with open("/Users/brady.bodily/Documents/Repositories/CS5890_Robot_Intelligence/RobotIntelFinal/ConsoleApp/Output/DetectedMines.txt") as f:
+ with open("/Users/brady.bodily/Documents/Repositories/CS5890_Robot_Intelligence/RobotIntelFinal/ConsoleApp/Output/HexDetectedMines.txt") as f:
for line in f:
x, y = line.split()
xf.append(int(x))
@@ -32,8 +32,8 @@ if __name__ == "__main__":
plt.plot(xc, yc, 'o', label='vehicle', color='blue')
plt.plot(xm, ym, 'o', label='all mines', color='red')
plt.plot(xf, yf, 'o', label='detected mines', color='orange')
- plt.title('test 9')
+ plt.title('Hex Simulation')
plt.legend(loc='lower left', fontsize='xx-small')
- matplotlib.pyplot.savefig('/Users/brady.bodily/Documents/Repositories/CS5890_Robot_Intelligence/RobotIntelFinal/ConsoleApp/Output/test.png')
+ matplotlib.pyplot.savefig('/Users/brady.bodily/Documents/Repositories/CS5890_Robot_Intelligence/RobotIntelFinal/ConsoleApp/Output/HexTest.png')
plt.close(fig)
\ No newline at end of file
diff --git a/ConsoleApp/ISimulationResults.cs b/ConsoleApp/ISimulationResults.cs
new file mode 100644
index 0000000..e8f930a
--- /dev/null
+++ b/ConsoleApp/ISimulationResults.cs
@@ -0,0 +1,19 @@
+using System.Collections.Generic;
+using ConsoleApp.Maps;
+using HexCore;
+
+namespace ConsoleApp
+{
+ public interface ISimulationResults
+ {
+ void WriteResults();
+ int HexTotalMoves { get; set; }
+ int HexBombsFound { get; set; }
+ int TotalBombs { get; set; }
+ List HexPath { get; set; }
+ List HexMappedBombs { get; set; }
+ List Mines { get; set; }
+ int HexClearedCells { get; set; }
+ int HexUnClearedCells { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/ConsoleApp/Maps/IMineMap.cs b/ConsoleApp/Maps/IMineMap.cs
index 5e66fff..5a13a56 100644
--- a/ConsoleApp/Maps/IMineMap.cs
+++ b/ConsoleApp/Maps/IMineMap.cs
@@ -1,3 +1,5 @@
+using System.Collections.Generic;
+
namespace ConsoleApp.Maps
{
public interface IMineMap
@@ -6,5 +8,6 @@ namespace ConsoleApp.Maps
int TotalBombs { get; }
bool GetCell(int x, int y);
+ List PlacedMines { get; }
}
}
\ No newline at end of file
diff --git a/ConsoleApp/Maps/MineMap.cs b/ConsoleApp/Maps/MineMap.cs
index c157a45..7b0fa6d 100644
--- a/ConsoleApp/Maps/MineMap.cs
+++ b/ConsoleApp/Maps/MineMap.cs
@@ -12,23 +12,19 @@ namespace ConsoleApp.Maps
private int _y;
public bool[,] Map { get; }
public int TotalBombs { get; }
- private List _placedMines;
+ public List PlacedMines { get; }
public MineMap(int x, int y, double minePercentage)
{
_x = x;
_y = y;
- _placedMines = new List();
+ PlacedMines = new List();
_mineCount = (int)(x*y*(minePercentage/100));
TotalBombs = _mineCount;
Map = new bool[x, y];
Map.Fill2DArray(false);
PlaceMines();
- using(TextWriter tw = new StreamWriter("/Users/brady.bodily/Documents/Repositories/CS5890_Robot_Intelligence/RobotIntelFinal/ConsoleApp/Output/Mines.txt"))
- {
- foreach (var s in _placedMines)
- tw.WriteLine($"{s.X} {s.Y}");
- }
+
}
public bool GetCell(int x, int y) => Map[x,y];
@@ -47,7 +43,7 @@ namespace ConsoleApp.Maps
else
{
Map[x, y] = true;
- _placedMines.Add(new Cell(x,y));
+ PlacedMines.Add(new Cell(x,y));
}
}
}
diff --git a/ConsoleApp/Output/Data.txt b/ConsoleApp/Output/Data.txt
new file mode 100644
index 0000000..a3ad04a
--- /dev/null
+++ b/ConsoleApp/Output/Data.txt
@@ -0,0 +1,7 @@
+General:
+ Total Mines: 23
+Hex:
+ Total Moves: 927
+ Bombs Found: 23
+ Cleared Cell Count: 2295
+ Uncleared Cell Count: 9
diff --git a/ConsoleApp/Output/DetectedMines.txt b/ConsoleApp/Output/DetectedMines.txt
deleted file mode 100644
index cc278b8..0000000
--- a/ConsoleApp/Output/DetectedMines.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-8 5
-8 6
-5 11
-9 10
-13 9
-13 14
-10 13
diff --git a/ConsoleApp/Output/HexDetectedMines.txt b/ConsoleApp/Output/HexDetectedMines.txt
new file mode 100644
index 0000000..e69de29
diff --git a/ConsoleApp/Output/HexPath.txt b/ConsoleApp/Output/HexPath.txt
new file mode 100644
index 0000000..032288e
--- /dev/null
+++ b/ConsoleApp/Output/HexPath.txt
@@ -0,0 +1,927 @@
+0 0
+1 0
+2 0
+3 0
+4 0
+5 0
+6 0
+7 0
+8 0
+9 0
+10 0
+11 0
+12 0
+13 0
+14 0
+15 0
+16 0
+17 0
+18 0
+19 0
+20 0
+21 0
+22 0
+23 0
+24 0
+25 0
+26 0
+27 0
+28 0
+29 0
+30 0
+31 0
+32 0
+33 0
+34 0
+35 0
+36 0
+37 0
+38 0
+39 0
+40 0
+41 0
+42 0
+43 0
+44 0
+45 0
+46 0
+47 0
+47 1
+47 2
+47 3
+46 3
+45 3
+44 3
+43 3
+42 3
+41 3
+40 3
+39 3
+38 3
+37 3
+36 3
+35 3
+34 3
+33 3
+32 3
+31 3
+30 3
+29 3
+28 3
+27 3
+26 3
+25 3
+24 3
+23 3
+22 3
+21 3
+20 3
+19 3
+18 3
+17 3
+16 3
+15 3
+14 3
+13 3
+12 3
+11 3
+10 3
+9 3
+8 3
+7 3
+6 3
+5 3
+4 3
+3 3
+2 3
+1 3
+0 3
+1 4
+0 5
+0 6
+1 6
+2 6
+3 6
+4 6
+5 6
+6 6
+7 6
+6 5
+7 4
+8 4
+9 4
+10 4
+10 5
+11 6
+12 6
+13 6
+14 6
+15 6
+16 6
+17 6
+18 6
+19 6
+20 6
+21 6
+20 5
+21 4
+22 4
+23 4
+24 4
+24 5
+25 6
+26 6
+27 6
+28 6
+29 6
+30 6
+31 6
+32 6
+33 6
+34 6
+35 6
+36 6
+37 6
+38 6
+39 6
+40 6
+41 6
+42 6
+43 6
+44 6
+45 6
+46 6
+47 6
+47 7
+47 8
+47 9
+46 9
+45 9
+44 9
+43 9
+42 9
+41 9
+40 9
+39 9
+38 9
+37 9
+36 9
+35 9
+34 9
+33 9
+32 9
+31 9
+30 9
+29 9
+28 9
+27 9
+27 8
+26 8
+25 8
+24 9
+24 9
+24 10
+23 10
+23 11
+23 12
+22 12
+21 12
+20 12
+19 11
+19 10
+18 9
+17 9
+16 9
+15 9
+14 9
+13 9
+12 9
+12 9
+13 10
+12 11
+12 12
+13 12
+13 13
+13 14
+12 15
+12 16
+11 16
+10 16
+9 16
+8 15
+8 14
+7 13
+7 12
+6 11
+6 10
+5 9
+4 9
+3 9
+2 9
+1 9
+0 9
+1 10
+0 11
+0 12
+1 12
+2 12
+3 12
+4 12
+5 12
+6 12
+7 12
+8 12
+8 12
+7 13
+8 14
+8 15
+9 16
+10 16
+11 16
+12 16
+12 15
+13 14
+13 13
+13 12
+14 12
+15 12
+16 12
+17 12
+18 12
+19 12
+20 12
+21 12
+22 12
+22 12
+21 13
+21 14
+20 13
+19 13
+19 14
+18 15
+18 16
+18 17
+19 18
+19 19
+20 19
+21 19
+22 19
+23 18
+23 17
+23 18
+23 19
+24 19
+25 19
+26 19
+27 18
+27 17
+28 16
+28 15
+29 14
+29 13
+30 12
+31 12
+32 12
+33 12
+34 12
+35 12
+36 12
+37 12
+38 12
+39 12
+40 12
+41 12
+42 12
+43 12
+44 12
+45 12
+46 12
+47 12
+47 13
+47 14
+47 15
+46 15
+45 15
+44 15
+43 15
+42 15
+41 15
+41 14
+40 14
+39 14
+38 15
+37 15
+36 15
+35 15
+34 15
+33 15
+32 15
+31 15
+30 15
+29 15
+28 15
+27 15
+27 15
+28 16
+27 17
+27 18
+26 19
+25 19
+24 19
+23 19
+22 19
+21 19
+20 19
+19 19
+19 18
+18 17
+18 16
+18 15
+17 15
+16 15
+15 15
+14 15
+13 15
+12 15
+12 15
+12 16
+11 16
+10 16
+9 16
+8 15
+7 15
+6 15
+5 15
+4 15
+3 15
+2 15
+1 15
+0 15
+1 16
+0 17
+0 18
+1 18
+2 18
+3 18
+4 18
+5 18
+6 18
+5 17
+6 16
+7 16
+8 16
+9 16
+9 17
+10 16
+11 16
+12 16
+12 17
+13 18
+14 18
+15 18
+16 18
+17 18
+18 18
+19 18
+19 18
+19 19
+20 19
+21 19
+22 19
+23 18
+23 18
+23 19
+24 19
+25 19
+26 19
+27 18
+28 18
+29 18
+30 18
+31 18
+32 18
+33 18
+34 18
+35 18
+36 18
+37 18
+38 18
+38 18
+38 19
+39 20
+40 20
+41 20
+42 20
+42 19
+43 18
+44 18
+45 18
+46 18
+47 18
+47 19
+47 20
+47 21
+46 21
+45 21
+44 21
+43 21
+42 21
+41 21
+40 21
+39 21
+38 21
+37 21
+36 21
+36 20
+35 20
+34 20
+33 21
+32 21
+31 21
+30 21
+29 21
+28 21
+27 21
+26 21
+25 21
+24 21
+23 21
+22 21
+21 21
+20 21
+19 21
+18 21
+17 21
+16 21
+15 21
+14 21
+13 21
+12 21
+12 21
+12 22
+11 22
+10 22
+9 22
+8 22
+7 22
+6 22
+5 21
+4 21
+3 21
+2 21
+1 21
+0 21
+1 22
+0 23
+0 24
+1 24
+2 24
+3 24
+4 24
+5 24
+6 24
+7 24
+6 23
+7 22
+8 22
+9 22
+10 22
+10 23
+11 24
+12 24
+13 24
+14 24
+15 24
+16 24
+17 24
+18 24
+19 24
+20 24
+21 24
+22 24
+23 24
+24 24
+25 24
+26 24
+27 24
+28 24
+29 24
+30 24
+31 24
+32 24
+31 24
+30 25
+30 26
+30 27
+31 28
+31 29
+32 29
+33 29
+34 29
+35 28
+35 27
+36 26
+37 26
+37 25
+38 24
+39 24
+40 24
+41 24
+42 24
+43 24
+44 24
+45 24
+46 24
+47 24
+47 25
+47 26
+47 27
+46 27
+45 27
+44 27
+43 27
+42 27
+41 27
+40 27
+39 27
+38 27
+37 27
+36 27
+35 27
+35 27
+35 28
+34 29
+33 29
+32 29
+31 29
+31 28
+30 27
+29 27
+28 27
+27 27
+26 27
+25 27
+24 27
+23 27
+22 27
+21 27
+20 27
+19 27
+18 27
+17 27
+16 27
+15 27
+14 27
+13 27
+12 27
+11 27
+12 27
+13 28
+12 29
+12 30
+11 31
+10 31
+9 31
+8 31
+8 30
+7 29
+7 28
+6 27
+5 27
+4 27
+3 27
+2 27
+1 27
+0 27
+1 28
+0 29
+0 30
+1 30
+2 30
+3 30
+4 30
+5 30
+5 29
+6 29
+7 29
+8 30
+8 30
+8 31
+9 31
+10 31
+11 31
+12 30
+13 30
+14 30
+15 30
+16 30
+17 30
+18 30
+18 30
+17 31
+18 32
+18 33
+19 33
+20 33
+21 33
+22 32
+22 31
+23 30
+24 30
+25 30
+26 30
+27 30
+28 30
+29 30
+30 30
+31 30
+32 30
+33 30
+34 30
+35 30
+36 30
+37 30
+38 30
+39 30
+40 30
+41 30
+42 30
+43 30
+44 30
+45 30
+46 30
+47 30
+47 31
+47 32
+47 33
+46 33
+45 33
+44 33
+43 33
+42 33
+41 33
+40 33
+39 33
+40 32
+39 31
+38 31
+37 31
+36 31
+36 32
+35 33
+34 33
+33 33
+32 33
+31 33
+30 33
+29 33
+28 33
+27 33
+26 33
+25 33
+24 33
+23 33
+22 33
+21 33
+20 33
+19 33
+18 33
+17 33
+16 33
+15 33
+14 33
+13 33
+12 33
+11 33
+10 33
+9 33
+8 33
+8 33
+8 34
+7 35
+6 35
+5 35
+4 35
+4 34
+3 33
+2 33
+1 33
+0 33
+1 34
+0 35
+0 36
+1 36
+2 36
+3 36
+4 36
+5 36
+6 36
+7 36
+8 36
+9 36
+10 36
+11 36
+12 36
+13 36
+14 36
+15 36
+16 36
+17 36
+18 36
+18 35
+19 35
+19 34
+19 33
+20 33
+21 33
+22 33
+23 34
+23 35
+24 36
+25 36
+26 36
+27 36
+28 36
+29 36
+29 35
+30 35
+31 35
+32 36
+33 36
+34 36
+35 36
+36 36
+36 36
+36 37
+37 37
+38 37
+39 37
+40 36
+41 36
+42 36
+43 36
+44 36
+45 36
+46 36
+47 36
+47 37
+47 38
+47 39
+46 39
+45 39
+44 39
+43 39
+42 39
+41 39
+40 39
+39 39
+38 39
+38 39
+38 39
+38 40
+37 41
+37 42
+36 42
+35 42
+34 42
+33 41
+33 40
+32 39
+32 39
+32 40
+31 41
+30 41
+29 41
+28 41
+28 40
+27 39
+26 39
+25 39
+24 39
+23 39
+22 39
+21 39
+21 39
+21 40
+20 41
+19 41
+18 41
+17 41
+17 40
+16 39
+15 39
+14 39
+13 39
+12 39
+11 39
+10 39
+9 39
+8 39
+7 39
+6 39
+5 39
+4 39
+3 39
+2 39
+1 39
+0 39
+1 40
+0 41
+0 42
+1 42
+2 42
+3 42
+4 42
+5 42
+6 42
+7 42
+8 42
+9 42
+10 42
+11 42
+12 42
+13 42
+14 42
+15 42
+16 42
+17 42
+18 42
+19 42
+20 42
+21 42
+22 42
+23 42
+24 42
+25 42
+26 42
+27 42
+28 42
+29 42
+30 42
+31 42
+32 42
+33 42
+34 42
+35 42
+36 42
+37 42
+38 42
+39 42
+40 42
+41 42
+42 42
+43 42
+44 42
+45 42
+46 42
+47 42
+47 43
+47 44
+47 45
+46 45
+45 45
+44 45
+43 45
+42 45
+41 45
+40 45
+39 45
+38 45
+37 45
+36 45
+35 45
+34 45
+33 45
+32 45
+31 45
+30 45
+29 45
+28 45
+27 45
+26 45
+25 45
+24 45
+23 45
+22 45
+21 45
+20 45
+19 45
+18 45
+17 45
+16 45
+15 45
+14 45
+13 45
+12 45
+11 45
+10 45
+9 45
+8 45
+7 45
+6 45
+5 45
+4 45
+3 45
+2 45
+1 45
+0 45
diff --git a/ConsoleApp/Output/HexTest.png b/ConsoleApp/Output/HexTest.png
new file mode 100644
index 0000000..0dccbf7
Binary files /dev/null and b/ConsoleApp/Output/HexTest.png differ
diff --git a/ConsoleApp/Output/Mines.txt b/ConsoleApp/Output/Mines.txt
deleted file mode 100644
index a2cd0e2..0000000
--- a/ConsoleApp/Output/Mines.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-5 11
-8 6
-13 14
-9 10
-13 9
-10 13
-10 6
-8 5
diff --git a/ConsoleApp/Output/SavedList.txt b/ConsoleApp/Output/SavedList.txt
deleted file mode 100644
index 1c83a93..0000000
--- a/ConsoleApp/Output/SavedList.txt
+++ /dev/null
@@ -1,150 +0,0 @@
-0 0
-1 0
-2 0
-3 0
-4 0
-5 0
-6 0
-7 0
-8 0
-9 0
-10 0
-11 0
-12 0
-13 0
-14 0
-15 0
-16 0
-17 0
-18 0
-19 0
-19 1
-19 2
-19 3
-18 3
-17 3
-16 3
-15 3
-14 3
-13 3
-12 3
-11 3
-10 3
-9 3
-9 2
-8 2
-7 2
-6 3
-5 3
-4 3
-3 3
-2 3
-1 3
-0 3
-1 4
-0 5
-0 6
-1 6
-2 6
-3 6
-4 6
-5 6
-6 6
-5 7
-6 8
-6 9
-7 9
-14 6
-15 6
-16 6
-17 6
-18 6
-19 6
-19 7
-19 8
-19 9
-18 9
-17 9
-16 9
-15 9
-16 10
-15 11
-15 12
-14 12
-15 12
-15 13
-16 14
-15 15
-15 16
-14 17
-13 17
-12 17
-11 17
-11 16
-10 15
-10 16
-9 16
-8 15
-8 14
-7 13
-6 14
-5 14
-4 14
-3 13
-3 12
-2 11
-3 10
-3 9
-1 9
-0 9
-1 10
-0 11
-0 12
-1 12
-2 12
-3 12
-3 13
-4 14
-4 15
-5 16
-5 17
-6 17
-7 17
-8 17
-9 17
-10 17
-11 17
-12 17
-13 17
-14 17
-15 16
-15 15
-16 14
-15 13
-15 12
-17 12
-18 12
-19 12
-19 13
-19 14
-19 15
-18 15
-17 15
-16 15
-15 15
-15 16
-14 17
-13 17
-12 17
-11 17
-11 16
-10 16
-9 16
-8 15
-6 15
-5 15
-4 15
-3 15
-2 15
-1 15
-0 15
diff --git a/ConsoleApp/Output/test.png b/ConsoleApp/Output/test.png
deleted file mode 100644
index 5b5e68a..0000000
Binary files a/ConsoleApp/Output/test.png and /dev/null differ
diff --git a/ConsoleApp/Program.cs b/ConsoleApp/Program.cs
index 625b13b..d90d0e7 100644
--- a/ConsoleApp/Program.cs
+++ b/ConsoleApp/Program.cs
@@ -15,34 +15,14 @@ namespace ConsoleApp
static void Main(string[] args)
{
_bootstrapper = BootStrapper.BootstrapSystem(new CoreModule());
+ var simResults = _bootstrapper.Resolve();
_userConsole = new UserConsole();
Initialization();
- GenerateImages();
+ simResults.WriteResults();
Console.WriteLine("Program Completed");
}
- private static void GenerateImages()
- {
- // var generateMap= "python3 ConsoleApp/plot.py";
- // System.Diagnostics.Process.Start("CMD.exe",generateMap);
- //
- var file = Path.Combine("./",Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"plot.py");
- ProcessStartInfo startInfo = new ProcessStartInfo()
- {
- FileName = "python3",
- Arguments = file,
- UseShellExecute = true
- };
- Process proc = new Process()
- {
- StartInfo = startInfo,
- };
- proc.Start();
- while (!proc.HasExited)
- {
- Thread.Sleep(500);
- }
- }
+
private static void Initialization()
{
diff --git a/ConsoleApp/SimRunner.cs b/ConsoleApp/SimRunner.cs
index 647a15c..66a089d 100644
--- a/ConsoleApp/SimRunner.cs
+++ b/ConsoleApp/SimRunner.cs
@@ -24,19 +24,23 @@ namespace ConsoleApp
private IReactivePathPlanner _reactivePathPlanner;
private HashSet hexBombsFound = new HashSet();
private List testingPath = new List();
+ private ISimulationResults _simulationResults;
- public SimRunner(IMapFactory mapFactory, IVehicle vehicle, IPathPlanner pathPlanner, IReactivePathPlanner reactivePathPlanner)
+ public SimRunner(IMapFactory mapFactory, IVehicle vehicle, IPathPlanner pathPlanner, IReactivePathPlanner reactivePathPlanner, ISimulationResults simulationResults)
{
_mapFactory = mapFactory;
_vehicle = vehicle;
_pathPlanner = pathPlanner;
_reactivePathPlanner = reactivePathPlanner;
+ _simulationResults = simulationResults;
}
public void Run()
{
_mineMap = _mapFactory.GetMineMap();
+ _simulationResults.Mines = _mineMap.PlacedMines;
+ _simulationResults.TotalBombs = _mineMap.TotalBombs;
SquareSimulation();
HexSimulation();
// while(!squareTask.IsCompleted && !hexTask.IsCompleted){Thread.Sleep(500);}
@@ -48,13 +52,12 @@ namespace ConsoleApp
var hexMap = _mapFactory.GetHexMap();
_vehicle.CurrentHexCell = new Coordinate2D(0, 0, OffsetTypes.OddRowsRight);
var optimalPath = _pathPlanner.GenerateOptimalHexPath(hexMap, _vehicle);
- var minimumMoves = optimalPath.Count;
var finished = false;
var totalMoves = 0;
while (!finished)
{
totalMoves += 1;
- testingPath.Add(_vehicle.CurrentHexCell);
+ _simulationResults.HexPath.Add(_vehicle.CurrentHexCell);
var detectionCells = DetectionHead.GetCoveredCells(hexMap.Graph, _vehicle.CurrentHexCell, _vehicle.DetectorRadius, _vehicle.TurnRadius);
//Check Cells for mine
@@ -80,63 +83,38 @@ namespace ConsoleApp
break;
}
- var replan = false;
- //if the next optimal cell is blocked then we need to replan around it.
- while (hexMap.Graph.IsCellBlocked(nextOptimal))
+ if (hexMap.Graph.IsCellBlocked(nextOptimal))
{
- replan = true;
- if (optimalPath.TryDequeue(out nextOptimal)) continue;
- finished = true;
- break;
+ _reactivePathPlanner.GenerateReactiveHexPath(hexMap, optimalPath, _vehicle.CurrentHexCell);
}
- if(replan)
- {
- var tmpPath =
- hexMap.Graph.GetShortestPath(_vehicle.CurrentHexCell, nextOptimal, hexMap.DefaultMovement);
- if (Math.Abs(_vehicle.CurrentHexCell.X - nextOptimal.X) > 1 || Math.Abs(_vehicle.CurrentHexCell.Y - nextOptimal.Y) > 1)
- optimalPath.Dequeue();
- tmpPath.AddRange(optimalPath);
-
- optimalPath.Clear();
- foreach (var cell in tmpPath)
- {
- optimalPath.Enqueue(cell);
- }
- optimalPath.TryDequeue(out nextOptimal);
- }
-
- var last = testingPath[testingPath.Count-1];
- if (Math.Abs(last.X - nextOptimal.X) > 1 || Math.Abs(last.Y - nextOptimal.Y) > 1)
- Console.WriteLine("To big of a gap");
-
- _vehicle.CurrentHexCell = nextOptimal;
+ else
+ _vehicle.CurrentHexCell = nextOptimal;
}
}
//Debugging information
- using(TextWriter tw = new StreamWriter("/Users/brady.bodily/Documents/Repositories/CS5890_Robot_Intelligence/RobotIntelFinal/ConsoleApp/Output/SavedList.txt"))
- {
- foreach (Coordinate2D s in testingPath)
- tw.WriteLine($"{s.X} {s.Y}");
- }
- using(TextWriter tw = new StreamWriter("/Users/brady.bodily/Documents/Repositories/CS5890_Robot_Intelligence/RobotIntelFinal/ConsoleApp/Output/DetectedMines.txt"))
- {
- foreach (Coordinate2D s in hexBombsFound)
- tw.WriteLine($"{s.X} {s.Y}");
- }
- var covered = CoveredCells();
- Console.WriteLine($"Total cells traversed: {totalMoves} \n" +
- $"Minimum required: {minimumMoves}");
- Console.WriteLine($"Total bombs found: {hexBombsFound.Count}/{_mineMap.TotalBombs}");
-
+ var (cleared, uncleared) = CoveredCells();
+ _simulationResults.HexClearedCells = cleared;
+ _simulationResults.HexUnClearedCells = uncleared;
+ _simulationResults.HexTotalMoves = totalMoves;
+ _simulationResults.HexBombsFound = hexBombsFound.Count;
}
- private int CoveredCells()
+ private (int, int) CoveredCells()
{
+ var cleared = 0;
+ var uncleared = 0;
var hexMap = _mapFactory.GetHexMap();
- //for()
- return 0;
+ foreach (var cellState in hexMap.Graph.GetAllCells())
+ {
+ if (cellState.TerrainType.Id == hexMap.ClearedTerrain.Id)
+ cleared++;
+ if (cellState.TerrainType.Id == hexMap.UnclearedTerrain.Id)
+ uncleared++;
+ }
+
+ return (cleared, uncleared);
}
@@ -158,11 +136,6 @@ namespace ConsoleApp
var cellsToBlock = hexMap.Graph.GetRange(cell, _vehicle.Width / 2);
hexMap.Graph.BlockCells(cellsToBlock);
- // //debugging
- // foreach (var celllll in cellsToBlock)
- // {
- // Console.WriteLine($"({celllll.X}, {celllll.Y}) Blocked: {hexMap.Graph.GetCellState(celllll).IsBlocked}");
- // }
}
diff --git a/ConsoleApp/SimulationResults.cs b/ConsoleApp/SimulationResults.cs
new file mode 100644
index 0000000..c2a2ca8
--- /dev/null
+++ b/ConsoleApp/SimulationResults.cs
@@ -0,0 +1,104 @@
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Reflection;
+using System.Threading;
+using ConsoleApp.Maps;
+using HexCore;
+
+namespace ConsoleApp
+{
+ public class SimulationResults : ISimulationResults
+ {
+ public int HexTotalMoves { get; set; }
+ public int HexBombsFound { get; set; }
+ public int TotalBombs { get; set; }
+ public List HexPath { get; set; }
+ public List HexMappedBombs { get; set; }
+ public List Mines { get; set; }
+ public int HexClearedCells { get; set; }
+ public int HexUnClearedCells { get; set; }
+
+ public SimulationResults()
+ {
+ HexTotalMoves = 0;
+ HexBombsFound = 0;
+ TotalBombs = 0;
+ HexPath = new List();
+ HexMappedBombs = new List();
+ Mines = new List| ();
+ HexClearedCells = 0;
+ HexUnClearedCells = 0;
+ }
+
+ public void WriteResults()
+ {
+ WriteData();
+ WriteMines();
+ WritePaths();
+ WriteDetectedMines();
+ GenerateImages();
+ }
+
+ private static void GenerateImages()
+ {
+ var file = Path.Combine("./",Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"HexPlot.py");
+ ProcessStartInfo startInfo = new ProcessStartInfo()
+ {
+ FileName = "python3",
+ Arguments = file,
+ UseShellExecute = true
+ };
+ Process proc = new Process()
+ {
+ StartInfo = startInfo,
+ };
+ proc.Start();
+ while (!proc.HasExited)
+ {
+ Thread.Sleep(500);
+ }
+ }
+
+ private void WriteData()
+ {
+ using(TextWriter tw = new StreamWriter("/Users/brady.bodily/Documents/Repositories/CS5890_Robot_Intelligence/RobotIntelFinal/ConsoleApp/Output/Data.txt"))
+ {
+ tw.WriteLine($"General:");
+ tw.WriteLine($"\t Total Mines: {TotalBombs}");
+ tw.WriteLine($"Hex: ");
+ tw.WriteLine($"\t Total Moves: {HexTotalMoves}");
+ tw.WriteLine($"\t Bombs Found: {HexBombsFound}");
+ tw.WriteLine($"\t Cleared Cell Count: {HexClearedCells}");
+ tw.WriteLine($"\t Uncleared Cell Count: {HexUnClearedCells}");
+ }
+ }
+
+ private void WriteMines()
+ {
+ using(TextWriter tw = new StreamWriter("/Users/brady.bodily/Documents/Repositories/CS5890_Robot_Intelligence/RobotIntelFinal/ConsoleApp/Output/Mines.txt"))
+ {
+ foreach (var s in Mines)
+ tw.WriteLine($"{s.X} {s.Y}");
+ }
+ }
+
+ private void WriteDetectedMines()
+ {
+ using(TextWriter tw = new StreamWriter("/Users/brady.bodily/Documents/Repositories/CS5890_Robot_Intelligence/RobotIntelFinal/ConsoleApp/Output/HexDetectedMines.txt"))
+ {
+ foreach (Coordinate2D s in HexMappedBombs)
+ tw.WriteLine($"{s.X} {s.Y}");
+ }
+ }
+
+ private void WritePaths()
+ {
+ using(TextWriter tw = new StreamWriter("/Users/brady.bodily/Documents/Repositories/CS5890_Robot_Intelligence/RobotIntelFinal/ConsoleApp/Output/HexPath.txt"))
+ {
+ foreach (Coordinate2D s in HexPath)
+ tw.WriteLine($"{s.X} {s.Y}");
+ }
+ }
+ }
+}
\ No newline at end of file
| | | | | | | |