Compare commits
7 Commits
SquareMap
...
SquareSimu
| Author | SHA1 | Date | |
|---|---|---|---|
| 588c004c1b | |||
| 74035a16eb | |||
| e335ce3c68 | |||
| a792de99f3 | |||
| e8ffbd3151 | |||
| f8ce6d0c83 | |||
| cf432a348b |
20
.idea/.idea.RobotIntelFinal/.idea/contentModel.xml
generated
20
.idea/.idea.RobotIntelFinal/.idea/contentModel.xml
generated
@@ -10,9 +10,11 @@
|
|||||||
<e p="IJsonDeserializor.cs" t="Include" />
|
<e p="IJsonDeserializor.cs" t="Include" />
|
||||||
<e p="IModule.cs" t="Include" />
|
<e p="IModule.cs" t="Include" />
|
||||||
<e p="ISimRunner.cs" t="Include" />
|
<e p="ISimRunner.cs" t="Include" />
|
||||||
|
<e p="ISimulationResults.cs" t="Include" />
|
||||||
<e p="IUserConsole.cs" t="Include" />
|
<e p="IUserConsole.cs" t="Include" />
|
||||||
<e p="JsonDeserializor.cs" t="Include" />
|
<e p="JsonDeserializor.cs" t="Include" />
|
||||||
<e p="Maps" t="Include">
|
<e p="Maps" t="Include">
|
||||||
|
<e p="AstarSquareSearch.cs" t="Include" />
|
||||||
<e p="Cell.cs" t="Include" />
|
<e p="Cell.cs" t="Include" />
|
||||||
<e p="GlobalDirection.cs" t="Include" />
|
<e p="GlobalDirection.cs" t="Include" />
|
||||||
<e p="Heading.cs" t="Include" />
|
<e p="Heading.cs" t="Include" />
|
||||||
@@ -34,12 +36,29 @@
|
|||||||
</e>
|
</e>
|
||||||
</e>
|
</e>
|
||||||
</e>
|
</e>
|
||||||
|
<e p="Output" t="Include">
|
||||||
|
<e p="Data.txt" t="Include" />
|
||||||
|
<e p="HexCoverage.png" t="Include" />
|
||||||
|
<e p="HexCoveredCells.txt" t="Include" />
|
||||||
|
<e p="HexDetectedMines.txt" t="Include" />
|
||||||
|
<e p="HexPath.txt" t="Include" />
|
||||||
|
<e p="HexTest.png" t="Include" />
|
||||||
|
<e p="Mines.txt" t="Include" />
|
||||||
|
<e p="SquareCoverage.png" t="Include" />
|
||||||
|
<e p="SquareCoveredCells.txt" t="Include" />
|
||||||
|
<e p="SquareDetectedMines.txt" t="Include" />
|
||||||
|
<e p="SquarePath.txt" t="Include" />
|
||||||
|
<e p="SquareTest.png" t="Include" />
|
||||||
|
</e>
|
||||||
|
<e p="Output 2.zip" t="Include" />
|
||||||
|
<e p="Output.zip" t="Include" />
|
||||||
<e p="PathPlanners" t="Include">
|
<e p="PathPlanners" t="Include">
|
||||||
<e p="IPathPlanner.cs" t="Include" />
|
<e p="IPathPlanner.cs" t="Include" />
|
||||||
<e p="IReactivePathPlanner.cs" t="Include" />
|
<e p="IReactivePathPlanner.cs" t="Include" />
|
||||||
<e p="PathPlanner.cs" t="Include" />
|
<e p="PathPlanner.cs" t="Include" />
|
||||||
<e p="ReactivePathPlanner.cs" t="Include" />
|
<e p="ReactivePathPlanner.cs" t="Include" />
|
||||||
</e>
|
</e>
|
||||||
|
<e p="plotGraphs.py" t="Include" />
|
||||||
<e p="Program.cs" t="Include" />
|
<e p="Program.cs" t="Include" />
|
||||||
<e p="Sim" t="Include">
|
<e p="Sim" t="Include">
|
||||||
<e p="DetectionHead.cs" t="Include" />
|
<e p="DetectionHead.cs" t="Include" />
|
||||||
@@ -49,6 +68,7 @@
|
|||||||
<e p="VehicleConfiguration.json" t="Include" />
|
<e p="VehicleConfiguration.json" t="Include" />
|
||||||
</e>
|
</e>
|
||||||
<e p="SimRunner.cs" t="Include" />
|
<e p="SimRunner.cs" t="Include" />
|
||||||
|
<e p="SimulationResults.cs" t="Include" />
|
||||||
<e p="UserConsole.cs" t="Include" />
|
<e p="UserConsole.cs" t="Include" />
|
||||||
</e>
|
</e>
|
||||||
<e p="packages" t="ExcludeRecursive" />
|
<e p="packages" t="ExcludeRecursive" />
|
||||||
|
|||||||
148
.idea/.idea.RobotIntelFinal/.idea/workspace.xml
generated
148
.idea/.idea.RobotIntelFinal/.idea/workspace.xml
generated
@@ -18,29 +18,24 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="dafcaeb7-80aa-43a3-a480-786fafb78c0b" name="Default Changelist" comment="">
|
<list default="true" id="dafcaeb7-80aa-43a3-a480-786fafb78c0b" name="Default Changelist" comment="">
|
||||||
<change afterPath="$PROJECT_DIR$/ConsoleApp/Maps/IMineMap.cs" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/ConsoleApp/Maps/MapExtensions.cs" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/ConsoleApp/Maps/MineMap.cs" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/ConsoleApp/PathPlanners/IReactivePathPlanner.cs" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/ConsoleApp/PathPlanners/ReactivePathPlanner.cs" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.RobotIntelFinal/.idea/contentModel.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.RobotIntelFinal/.idea/contentModel.xml" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.RobotIntelFinal/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.RobotIntelFinal/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/.idea.RobotIntelFinal/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.RobotIntelFinal/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/ConsoleApp/ConsoleApp.csproj" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/ConsoleApp.csproj" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/ConsoleApp/ConsoleApp.csproj" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/ConsoleApp.csproj" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/ConsoleApp/CoreModule.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/CoreModule.cs" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/ConsoleApp/HexPlot.py" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/plotGraphs.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/ConsoleApp/Maps/Cell.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/Maps/Cell.cs" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/ConsoleApp/Output/Data.txt" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/Output/Data.txt" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/ConsoleApp/Maps/ICell.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/Maps/ICell.cs" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/ConsoleApp/Output/HexCoverage.png" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/Output/HexCoverage.png" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/ConsoleApp/Maps/IMapFactory.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/Maps/IMapFactory.cs" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/ConsoleApp/Output/HexCoveredCells.txt" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/Output/HexCoveredCells.txt" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/ConsoleApp/Maps/MapFactory.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/Maps/MapFactory.cs" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/ConsoleApp/Output/HexDetectedMines.txt" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/Output/HexDetectedMines.txt" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/ConsoleApp/PathPlanners/IPathPlanner.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/PathPlanners/IPathPlanner.cs" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/ConsoleApp/Output/HexPath.txt" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/Output/HexPath.txt" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/ConsoleApp/Output/HexTest.png" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/Output/HexTest.png" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/ConsoleApp/Output/Mines.txt" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/Output/Mines.txt" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/ConsoleApp/Output/SquareCoverage.png" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/Output/SquareCoverage.png" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/ConsoleApp/Output/SquareCoveredCells.txt" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/Output/SquareCoveredCells.txt" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/ConsoleApp/Output/SquareDetectedMines.txt" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/Output/SquareDetectedMines.txt" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/ConsoleApp/Output/SquarePath.txt" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/Output/SquarePath.txt" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/ConsoleApp/Output/SquareTest.png" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/Output/SquareTest.png" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/ConsoleApp/PathPlanners/PathPlanner.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/PathPlanners/PathPlanner.cs" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/ConsoleApp/PathPlanners/PathPlanner.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/PathPlanners/PathPlanner.cs" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/ConsoleApp/Program.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/Program.cs" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/ConsoleApp/Program.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/Program.cs" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/ConsoleApp/SimRunner.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/SimRunner.cs" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/ConsoleApp/UserConsole.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/UserConsole.cs" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/ConsoleApp/UserConsole.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/UserConsole.cs" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/ConsoleApp/Vehicle/DetectionHead.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/Sim/DetectionHead.cs" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/ConsoleApp/Vehicle/IVehicle.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/Sim/IVehicle.cs" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/ConsoleApp/Vehicle/Vehicle.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/Sim/Vehicle.cs" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/ConsoleApp/Vehicle/VehicleConfiguration.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/Sim/VehicleConfiguration.cs" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/ConsoleApp/Vehicle/VehicleConfiguration.json" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/Sim/VehicleConfiguration.json" afterDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@@ -59,28 +54,38 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="HighlightingSettingsPerFile">
|
<component name="HighlightingSettingsPerFile">
|
||||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/EE5CA5D4-EDEB-48AE-9C0D-FE354330FB77/0b/0953c23b/GraphFactory.cs" root0="SKIP_HIGHLIGHTING" />
|
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/EE5CA5D4-EDEB-48AE-9C0D-FE354330FB77/0b/0953c23b/GraphFactory.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
|
||||||
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
|
||||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/EE5CA5D4-EDEB-48AE-9C0D-FE354330FB77/f7/268fdeac/Graph.cs" root0="SKIP_HIGHLIGHTING" />
|
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/EE5CA5D4-EDEB-48AE-9C0D-FE354330FB77/f7/268fdeac/Graph.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/EB067793-5C3F-4219-AEF1-3AB117C20649/133/Thread.CoreCLR.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/7AFCB195-1BDF-4087-9F2D-5BFCFC407B2B/46/ThrowHelper.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/EE5CA5D4-EDEB-48AE-9C0D-FE354330FB77/84/4eb9c798/GraphUtils.cs" root0="SKIP_HIGHLIGHTING" />
|
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/EE5CA5D4-EDEB-48AE-9C0D-FE354330FB77/84/4eb9c798/GraphUtils.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/EB067793-5C3F-4219-AEF1-3AB117C20649/39B/EqualityComparer.CoreCLR.cs" root0="SKIP_HIGHLIGHTING" />
|
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/EB067793-5C3F-4219-AEF1-3AB117C20649/39B/EqualityComparer.CoreCLR.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/EE5CA5D4-EDEB-48AE-9C0D-FE354330FB77/da/c3cabb46/AStarSearch.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/EB067793-5C3F-4219-AEF1-3AB117C20649/11/Array.cs" root0="SKIP_HIGHLIGHTING" />
|
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/EB067793-5C3F-4219-AEF1-3AB117C20649/11/Array.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/EB067793-5C3F-4219-AEF1-3AB117C20649/3A4/List.cs" root0="SKIP_HIGHLIGHTING" />
|
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/EB067793-5C3F-4219-AEF1-3AB117C20649/3A4/List.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/7AFCB195-1BDF-4087-9F2D-5BFCFC407B2B/30/Where.cs" root0="SKIP_HIGHLIGHTING" />
|
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/7AFCB195-1BDF-4087-9F2D-5BFCFC407B2B/30/Where.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/EB067793-5C3F-4219-AEF1-3AB117C20649/CD/ThrowHelper.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/8B2EA1A3-95EB-49F7-AF97-CA55CE776F10/4/Container.cs" root0="SKIP_HIGHLIGHTING" />
|
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/8B2EA1A3-95EB-49F7-AF97-CA55CE776F10/4/Container.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/EB067793-5C3F-4219-AEF1-3AB117C20649/389/Comparer.cs" root0="SKIP_HIGHLIGHTING" />
|
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/EB067793-5C3F-4219-AEF1-3AB117C20649/389/Comparer.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/EB067793-5C3F-4219-AEF1-3AB117C20649/B5/Random.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/EE5CA5D4-EDEB-48AE-9C0D-FE354330FB77/3d/c367b191/Coordinate3D.cs" root0="SKIP_HIGHLIGHTING" />
|
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/EE5CA5D4-EDEB-48AE-9C0D-FE354330FB77/3d/c367b191/Coordinate3D.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/1C5C65AB-6C84-402C-B333-F3A5A7121EFE/D/Queue.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
|
||||||
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/EE5CA5D4-EDEB-48AE-9C0D-FE354330FB77/14/12025305/MovementTypes.cs" root0="SKIP_HIGHLIGHTING" />
|
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/EE5CA5D4-EDEB-48AE-9C0D-FE354330FB77/14/12025305/MovementTypes.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
</component>
|
</component>
|
||||||
@@ -95,34 +100,41 @@
|
|||||||
<option value="$PROJECT_DIR$/ConsoleApp/IVehicle.cs" />
|
<option value="$PROJECT_DIR$/ConsoleApp/IVehicle.cs" />
|
||||||
<option value="$PROJECT_DIR$/ConsoleApp/Maps/IMap.cs" />
|
<option value="$PROJECT_DIR$/ConsoleApp/Maps/IMap.cs" />
|
||||||
<option value="$PROJECT_DIR$/ConsoleApp/Vehicle.cs" />
|
<option value="$PROJECT_DIR$/ConsoleApp/Vehicle.cs" />
|
||||||
<option value="$PROJECT_DIR$/ConsoleApp/Maps/IHexMap.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/ConsoleApp/Maps/HexMap.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/ConsoleApp/Maps/ISquareMap.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/ConsoleApp/Vehicle/DetectionHead.cs" />
|
<option value="$PROJECT_DIR$/ConsoleApp/Vehicle/DetectionHead.cs" />
|
||||||
<option value="$PROJECT_DIR$/ConsoleApp/Vehicle/Vehicle.cs" />
|
<option value="$PROJECT_DIR$/ConsoleApp/Vehicle/Vehicle.cs" />
|
||||||
<option value="$PROJECT_DIR$/ConsoleApp/Vehicle/VehicleConfiguration.cs" />
|
<option value="$PROJECT_DIR$/ConsoleApp/Vehicle/VehicleConfiguration.cs" />
|
||||||
<option value="$PROJECT_DIR$/ConsoleApp/Vehicle/IVehicle.cs" />
|
<option value="$PROJECT_DIR$/ConsoleApp/Vehicle/IVehicle.cs" />
|
||||||
<option value="$PROJECT_DIR$/ConsoleApp/Sim/DetectionHead.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/ConsoleApp/Maps/Cell.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/ConsoleApp/Maps/ICell.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/ConsoleApp/PathPlanners/IPathPlanner.cs" />
|
<option value="$PROJECT_DIR$/ConsoleApp/PathPlanners/IPathPlanner.cs" />
|
||||||
<option value="$PROJECT_DIR$/ConsoleApp/ConsoleApp.csproj" />
|
<option value="$PROJECT_DIR$/ConsoleApp/ConsoleApp.csproj" />
|
||||||
<option value="$PROJECT_DIR$/ConsoleApp/Sim/Vehicle.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/ConsoleApp/PathPlanners/PathPlanner.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/ConsoleApp/Sim/VehicleConfiguration.json" />
|
|
||||||
<option value="$PROJECT_DIR$/ConsoleApp/CoreModule.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/ConsoleApp/UserConsole.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/ConsoleApp/Program.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/ConsoleApp/Maps/CellExtensions.cs" />
|
<option value="$PROJECT_DIR$/ConsoleApp/Maps/CellExtensions.cs" />
|
||||||
<option value="$PROJECT_DIR$/ConsoleApp/Maps/MapExtensions.cs" />
|
<option value="$PROJECT_DIR$/ConsoleApp/Sim/IVehicle.cs" />
|
||||||
<option value="$PROJECT_DIR$/ConsoleApp/Maps/SquareMap.cs" />
|
<option value="$PROJECT_DIR$/ConsoleApp/Maps/IHexMap.cs" />
|
||||||
<option value="$PROJECT_DIR$/ConsoleApp/Maps/MineMap.cs" />
|
<option value="$PROJECT_DIR$/ConsoleApp/Maps/HexMap.cs" />
|
||||||
<option value="$PROJECT_DIR$/ConsoleApp/Maps/IMineMap.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/ConsoleApp/Maps/MapFactory.cs" />
|
<option value="$PROJECT_DIR$/ConsoleApp/Maps/MapFactory.cs" />
|
||||||
<option value="$PROJECT_DIR$/ConsoleApp/Maps/IMapFactory.cs" />
|
<option value="$PROJECT_DIR$/ConsoleApp/Maps/IMapFactory.cs" />
|
||||||
<option value="$PROJECT_DIR$/ConsoleApp/SimRunner.cs" />
|
<option value="$PROJECT_DIR$/ConsoleApp/Sim/VehicleConfiguration.cs" />
|
||||||
|
<option value="$PROJECT_DIR$/ConsoleApp/Sim/Vehicle.cs" />
|
||||||
|
<option value="$PROJECT_DIR$/ConsoleApp/CoreModule.cs" />
|
||||||
|
<option value="$PROJECT_DIR$/ConsoleApp/plot.py" />
|
||||||
|
<option value="$PROJECT_DIR$/ConsoleApp/Maps/MineMap.cs" />
|
||||||
|
<option value="$PROJECT_DIR$/ConsoleApp/Maps/IMineMap.cs" />
|
||||||
|
<option value="$PROJECT_DIR$/ConsoleApp/Maps/ICell.cs" />
|
||||||
|
<option value="$PROJECT_DIR$/ConsoleApp/Maps/MapExtensions.cs" />
|
||||||
<option value="$PROJECT_DIR$/ConsoleApp/PathPlanners/IReactivePathPlanner.cs" />
|
<option value="$PROJECT_DIR$/ConsoleApp/PathPlanners/IReactivePathPlanner.cs" />
|
||||||
<option value="$PROJECT_DIR$/ConsoleApp/PathPlanners/ReactivePathPlanner.cs" />
|
<option value="$PROJECT_DIR$/ConsoleApp/PathPlanners/ReactivePathPlanner.cs" />
|
||||||
|
<option value="$PROJECT_DIR$/ConsoleApp/Maps/AstarSquareSearch.cs" />
|
||||||
|
<option value="$PROJECT_DIR$/ConsoleApp/Maps/Cell.cs" />
|
||||||
|
<option value="$PROJECT_DIR$/ConsoleApp/Maps/SquareMap.cs" />
|
||||||
|
<option value="$PROJECT_DIR$/ConsoleApp/Maps/ISquareMap.cs" />
|
||||||
|
<option value="$PROJECT_DIR$/ConsoleApp/ISimulationResults.cs" />
|
||||||
|
<option value="$PROJECT_DIR$/ConsoleApp/SimulationResults.cs" />
|
||||||
|
<option value="$PROJECT_DIR$/ConsoleApp/Sim/DetectionHead.cs" />
|
||||||
|
<option value="$PROJECT_DIR$/ConsoleApp/SimRunner.cs" />
|
||||||
|
<option value="$PROJECT_DIR$/ConsoleApp/Sim/VehicleConfiguration.json" />
|
||||||
|
<option value="$PROJECT_DIR$/ConsoleApp/PathPlanners/PathPlanner.cs" />
|
||||||
|
<option value="$PROJECT_DIR$/ConsoleApp/UserConsole.cs" />
|
||||||
|
<option value="$PROJECT_DIR$/ConsoleApp/HexPlot.py" />
|
||||||
|
<option value="$PROJECT_DIR$/ConsoleApp/Program.cs" />
|
||||||
</changedPaths>
|
</changedPaths>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectId" id="1lIZ7IfsUjzqV2Jb1obOFvGFAfp" />
|
<component name="ProjectId" id="1lIZ7IfsUjzqV2Jb1obOFvGFAfp" />
|
||||||
@@ -134,13 +146,13 @@
|
|||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent">
|
<component name="PropertiesComponent">
|
||||||
<property name="DebuggerViewTab_PTCS_FirstProportionKey" value="0.3496007" />
|
<property name="DebuggerViewTab_PTCS_FirstProportionKey" value="0.22508793" />
|
||||||
<property name="DebuggerViewTab_PTCS_LastProportionKey" value="0.0" />
|
<property name="DebuggerViewTab_PTCS_LastProportionKey" value="0.0" />
|
||||||
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
|
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
|
||||||
<property name="WebServerToolWindowFactoryState" value="false" />
|
<property name="WebServerToolWindowFactoryState" value="false" />
|
||||||
<property name="nodejs_package_manager_path" value="npm" />
|
<property name="nodejs_package_manager_path" value="npm" />
|
||||||
<property name="restartRequiresConfirmation" value="false" />
|
<property name="restartRequiresConfirmation" value="false" />
|
||||||
<property name="settings.editor.selected.configurable" value="project.propDebugger" />
|
<property name="settings.editor.selected.configurable" value="configurable.group.build" />
|
||||||
<property name="vue.rearranger.settings.migration" value="true" />
|
<property name="vue.rearranger.settings.migration" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="RunManager" selected=".NET Project.ConsoleApp">
|
<component name="RunManager" selected=".NET Project.ConsoleApp">
|
||||||
@@ -200,7 +212,9 @@
|
|||||||
<workItem from="1607982179018" duration="634000" />
|
<workItem from="1607982179018" duration="634000" />
|
||||||
<workItem from="1607983288378" duration="86000" />
|
<workItem from="1607983288378" duration="86000" />
|
||||||
<workItem from="1607983862958" duration="7777000" />
|
<workItem from="1607983862958" duration="7777000" />
|
||||||
<workItem from="1607993290571" duration="36241000" />
|
<workItem from="1607993290571" duration="88336000" />
|
||||||
|
<workItem from="1608146906461" duration="175000" />
|
||||||
|
<workItem from="1608147111263" duration="16256000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
@@ -225,48 +239,10 @@
|
|||||||
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
|
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="XDebuggerManager">
|
<component name="XDebuggerManager">
|
||||||
<breakpoint-manager>
|
<pin-to-top-manager>
|
||||||
<breakpoints>
|
<pinned-members>
|
||||||
<line-breakpoint enabled="true" type="DotNet Breakpoints">
|
<PinnedItemInfo parentTag="Frame#ConsoleApp.PathPlanners.PathPlanner.GenerateOptimalHexPath" memberName="path" />
|
||||||
<url>file://$PROJECT_DIR$/ConsoleApp/PathPlanners/PathPlanner.cs</url>
|
</pinned-members>
|
||||||
<line>34</line>
|
</pin-to-top-manager>
|
||||||
<properties documentPath="$PROJECT_DIR$/ConsoleApp/PathPlanner.cs" initialLine="34" containingFunctionPresentation="method 'GenerateOptimalSquarePath'">
|
|
||||||
<startOffsets>
|
|
||||||
<option value="1527" />
|
|
||||||
</startOffsets>
|
|
||||||
<endOffsets>
|
|
||||||
<option value="1543" />
|
|
||||||
</endOffsets>
|
|
||||||
</properties>
|
|
||||||
<option name="timeStamp" value="24" />
|
|
||||||
</line-breakpoint>
|
|
||||||
<line-breakpoint enabled="true" type="DotNet Breakpoints">
|
|
||||||
<url>file://$PROJECT_DIR$/ConsoleApp/PathPlanners/PathPlanner.cs</url>
|
|
||||||
<line>87</line>
|
|
||||||
<properties documentPath="$PROJECT_DIR$/ConsoleApp/PathPlanners/PathPlanner.cs" initialLine="87" containingFunctionPresentation="method 'GenerateOptimalHexPath'">
|
|
||||||
<startOffsets>
|
|
||||||
<option value="3651" />
|
|
||||||
</startOffsets>
|
|
||||||
<endOffsets>
|
|
||||||
<option value="3667" />
|
|
||||||
</endOffsets>
|
|
||||||
</properties>
|
|
||||||
<option name="timeStamp" value="44" />
|
|
||||||
</line-breakpoint>
|
|
||||||
<line-breakpoint enabled="true" type="DotNet Breakpoints">
|
|
||||||
<url>file://$PROJECT_DIR$/ConsoleApp/PathPlanners/PathPlanner.cs</url>
|
|
||||||
<line>85</line>
|
|
||||||
<properties documentPath="$PROJECT_DIR$/ConsoleApp/PathPlanners/PathPlanner.cs" initialLine="85" containingFunctionPresentation="method 'GenerateOptimalHexPath'">
|
|
||||||
<startOffsets>
|
|
||||||
<option value="3546" />
|
|
||||||
</startOffsets>
|
|
||||||
<endOffsets>
|
|
||||||
<option value="3612" />
|
|
||||||
</endOffsets>
|
|
||||||
</properties>
|
|
||||||
<option name="timeStamp" value="46" />
|
|
||||||
</line-breakpoint>
|
|
||||||
</breakpoints>
|
|
||||||
</breakpoint-manager>
|
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
BIN
ConsoleApp/.DS_Store
vendored
Normal file
BIN
ConsoleApp/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -22,6 +22,13 @@
|
|||||||
<None Update="Sim\VehicleConfiguration.json">
|
<None Update="Sim\VehicleConfiguration.json">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
<None Update="plotGraphs.py">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Output" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ namespace ConsoleApp
|
|||||||
container.Register<IJsonDeserializor, JsonDeserializor>(Reuse.Singleton);
|
container.Register<IJsonDeserializor, JsonDeserializor>(Reuse.Singleton);
|
||||||
container.Register<IPathPlanner, PathPlanner>(Reuse.Singleton);
|
container.Register<IPathPlanner, PathPlanner>(Reuse.Singleton);
|
||||||
container.Register<IReactivePathPlanner, ReactivePathPlanner>(Reuse.Singleton);
|
container.Register<IReactivePathPlanner, ReactivePathPlanner>(Reuse.Singleton);
|
||||||
|
container.Register<ISimulationResults, SimulationResults>(Reuse.Singleton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
27
ConsoleApp/ISimulationResults.cs
Normal file
27
ConsoleApp/ISimulationResults.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
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<Coordinate2D> HexPath { get; set; }
|
||||||
|
List<Coordinate2D> HexMappedBombs { get; set; }
|
||||||
|
List<Cell> Mines { get; set; }
|
||||||
|
int HexClearedCells { get; set; }
|
||||||
|
int HexUnClearedCells { get; set; }
|
||||||
|
List<ICell> SquarePath { get; set; }
|
||||||
|
List<ICell> SquareMappedBombs { get; set; }
|
||||||
|
int SquareCellsUncleared { get; set; }
|
||||||
|
int SquareCellsCleared { get; set; }
|
||||||
|
int SquareBombsFound { get; set; }
|
||||||
|
int SquareTotalMoves { get; set; }
|
||||||
|
List<ICell> SquareCoveredCells { get; set; }
|
||||||
|
List<Coordinate2D> HexCoveredCells { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
60
ConsoleApp/Maps/AstarSquareSearch.cs
Normal file
60
ConsoleApp/Maps/AstarSquareSearch.cs
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using HexCore;
|
||||||
|
|
||||||
|
namespace ConsoleApp.Maps
|
||||||
|
{
|
||||||
|
public class AstarSquareSearch
|
||||||
|
{
|
||||||
|
private static double Heuristic(ICell a, ICell b)
|
||||||
|
{
|
||||||
|
return Math.Abs(a.X - b.X) + Math.Abs(a.Y - b.Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<ICell> FindShortestPath(ISquareMap graph, ICell start, ICell goal)
|
||||||
|
{
|
||||||
|
var costSoFar = new Dictionary<ICell, int>();
|
||||||
|
var cameFrom = new Dictionary<ICell, ICell>();
|
||||||
|
var frontier = new PriorityQueue<ICell>();
|
||||||
|
|
||||||
|
frontier.Enqueue(start, 0);
|
||||||
|
cameFrom[start] = start;
|
||||||
|
costSoFar[start] = 0;
|
||||||
|
|
||||||
|
while (frontier.Count > 0)
|
||||||
|
{
|
||||||
|
var current = frontier.Dequeue();
|
||||||
|
|
||||||
|
if (current.Equals(goal)) break;
|
||||||
|
|
||||||
|
foreach (var next in graph.GetPassableNeighbors(current))
|
||||||
|
{
|
||||||
|
var newCost = costSoFar[current] + (int)graph.GetCell(next.X, next.Y).Coverage;
|
||||||
|
if (costSoFar.ContainsKey(next) && newCost >= costSoFar[next]) continue;
|
||||||
|
costSoFar[next] = newCost;
|
||||||
|
var priority = newCost + Heuristic(next, goal);
|
||||||
|
frontier.Enqueue(next, priority);
|
||||||
|
cameFrom[next] = current;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var path = new List<ICell>();
|
||||||
|
var pathWasNotFound = !cameFrom.ContainsKey(goal);
|
||||||
|
|
||||||
|
// Returning an empty list if the path wasn't found
|
||||||
|
if (pathWasNotFound) return path;
|
||||||
|
|
||||||
|
// Reconstructing path
|
||||||
|
var curr = goal;
|
||||||
|
while (!curr.Equals(start))
|
||||||
|
{
|
||||||
|
path.Add(curr);
|
||||||
|
curr = cameFrom[curr];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reverse it to start at actual start point
|
||||||
|
path.Reverse();
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,20 +4,23 @@ namespace ConsoleApp.Maps
|
|||||||
{
|
{
|
||||||
public enum Coverage
|
public enum Coverage
|
||||||
{
|
{
|
||||||
Uncoverd,
|
//Order here matters these are cast to ints for the heuristic algorithm
|
||||||
|
Uncovered,
|
||||||
Covered
|
Covered
|
||||||
}
|
}
|
||||||
public struct Cell : ICell
|
public class Cell : ICell
|
||||||
{
|
{
|
||||||
public int X { get; }
|
public int X { get; }
|
||||||
public int Y { get; }
|
public int Y { get; }
|
||||||
public Coverage Coverage { get; set; }
|
public Coverage Coverage { get; set; }
|
||||||
|
public bool Blocked { get; set; }
|
||||||
|
|
||||||
public Cell(int x, int y)
|
public Cell(int x, int y)
|
||||||
{
|
{
|
||||||
X = x;
|
X = x;
|
||||||
Y = y;
|
Y = y;
|
||||||
Coverage = Coverage.Uncoverd;
|
Coverage = Coverage.Uncovered;
|
||||||
|
Blocked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ namespace ConsoleApp.Maps
|
|||||||
|
|
||||||
public OffsetTypes OffsetType { get; }
|
public OffsetTypes OffsetType { get; }
|
||||||
public MovementType DefaultMovement { get; }
|
public MovementType DefaultMovement { get; }
|
||||||
|
public TerrainType ClearedTerrain { get; }
|
||||||
|
|
||||||
|
public TerrainType UnclearedTerrain { get; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -28,33 +31,26 @@ namespace ConsoleApp.Maps
|
|||||||
{
|
{
|
||||||
//Set Offset Type for 2d -> 3d conversion
|
//Set Offset Type for 2d -> 3d conversion
|
||||||
OffsetType = OffsetTypes.OddRowsRight;
|
OffsetType = OffsetTypes.OddRowsRight;
|
||||||
//convert to cm
|
|
||||||
x *= 100;
|
|
||||||
y *= 100;
|
|
||||||
|
|
||||||
//calculate number of cells on x and y axis
|
Height = y;
|
||||||
var xCellCount = (int)Math.Ceiling((decimal) (x) / 25);
|
Width = x;
|
||||||
var yCellCount = (int)Math.Ceiling((decimal) (y) / 25);
|
|
||||||
|
|
||||||
Height = yCellCount;
|
UnclearedTerrain = new TerrainType(1, "uncleared");
|
||||||
Width = xCellCount;
|
ClearedTerrain = new TerrainType(2, "cleared");
|
||||||
|
|
||||||
var unclearedTerrain = new TerrainType(1, "uncleared");
|
|
||||||
var clearedTerrain = new TerrainType(2, "cleared");
|
|
||||||
|
|
||||||
DefaultMovement = new MovementType(1, "default");
|
DefaultMovement = new MovementType(1, "default");
|
||||||
var movementTypes = new MovementTypes(
|
var movementTypes = new MovementTypes(
|
||||||
new ITerrainType[] { unclearedTerrain, clearedTerrain },
|
new ITerrainType[] { UnclearedTerrain, ClearedTerrain },
|
||||||
new Dictionary<IMovementType, Dictionary<ITerrainType, int>>
|
new Dictionary<IMovementType, Dictionary<ITerrainType, int>>
|
||||||
{
|
{
|
||||||
[DefaultMovement] = new Dictionary<ITerrainType, int>
|
[DefaultMovement] = new Dictionary<ITerrainType, int>
|
||||||
{
|
{
|
||||||
[unclearedTerrain] = 1,
|
[UnclearedTerrain] = 1,
|
||||||
[clearedTerrain] = 2
|
[ClearedTerrain] = 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
Graph = GraphFactory.CreateRectangularGraph(Width, Height, movementTypes, unclearedTerrain);
|
Graph = GraphFactory.CreateRectangularGraph(Width, Height, movementTypes, UnclearedTerrain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,5 +5,6 @@ namespace ConsoleApp.Maps
|
|||||||
int X { get; }
|
int X { get; }
|
||||||
int Y { get; }
|
int Y { get; }
|
||||||
Coverage Coverage { get; set; }
|
Coverage Coverage { get; set; }
|
||||||
|
bool Blocked { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,5 +9,7 @@ namespace ConsoleApp.Maps
|
|||||||
int Width { get; }
|
int Width { get; }
|
||||||
int Height { get; }
|
int Height { get; }
|
||||||
MovementType DefaultMovement { get; }
|
MovementType DefaultMovement { get; }
|
||||||
|
public TerrainType ClearedTerrain { get; }
|
||||||
|
public TerrainType UnclearedTerrain { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,6 @@ namespace ConsoleApp.Maps
|
|||||||
{
|
{
|
||||||
int Height { get; }
|
int Height { get; }
|
||||||
int Width { get; }
|
int Width { get; }
|
||||||
int CellWidth { get; }
|
|
||||||
void GenerateMaps(int x, int y, double minePercentage);
|
void GenerateMaps(int x, int y, double minePercentage);
|
||||||
IHexMap GetHexMap();
|
IHexMap GetHexMap();
|
||||||
ISquareMap GetSquareMap();
|
ISquareMap GetSquareMap();
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace ConsoleApp.Maps
|
namespace ConsoleApp.Maps
|
||||||
{
|
{
|
||||||
public interface IMineMap
|
public interface IMineMap
|
||||||
{
|
{
|
||||||
bool[,] Map { get; }
|
bool[,] Map { get; }
|
||||||
|
|
||||||
|
int TotalBombs { get; }
|
||||||
|
bool GetCell(int x, int y);
|
||||||
|
List<Cell> PlacedMines { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,9 @@ namespace ConsoleApp.Maps
|
|||||||
Cell GetCell(int x, int y);
|
Cell GetCell(int x, int y);
|
||||||
int Height { get; }
|
int Height { get; }
|
||||||
int Width { get; }
|
int Width { get; }
|
||||||
List<Cell> GetRange(Cell centerCell, int radius);
|
List<Cell> GetRange(ICell centerCell, int radius);
|
||||||
|
List<Cell> GetNeighbors(ICell cell);
|
||||||
|
List<ICell> GetPassableNeighbors(ICell cell);
|
||||||
|
List<ICell> GetShortestPath(ICell start, ICell goal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using Example;
|
||||||
|
|
||||||
namespace ConsoleApp.Maps
|
namespace ConsoleApp.Maps
|
||||||
{
|
{
|
||||||
|
|
||||||
public static class MapExtensions
|
public static class MapExtensions
|
||||||
{
|
{
|
||||||
public static void Fill2DArray<T>(this T[,] arr, T value)
|
public static void Fill2DArray<T>(this T[,] arr, T value)
|
||||||
@@ -15,6 +22,5 @@ namespace ConsoleApp.Maps
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,6 @@ namespace ConsoleApp.Maps
|
|||||||
private int _defaultWidth;
|
private int _defaultWidth;
|
||||||
public int Height { get; protected set; }
|
public int Height { get; protected set; }
|
||||||
public int Width { get; protected set; }
|
public int Width { get; protected set; }
|
||||||
public int CellWidth { get; }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -22,11 +21,17 @@ namespace ConsoleApp.Maps
|
|||||||
|
|
||||||
public void GenerateMaps(int x, int y, double minePercentage)
|
public void GenerateMaps(int x, int y, double minePercentage)
|
||||||
{
|
{
|
||||||
Width = x;
|
//convert to cm
|
||||||
Height = y;
|
x *= 100;
|
||||||
_squareMap = new SquareMap(x, y);
|
y *= 100;
|
||||||
_hexMap = new HexMap(x, y);
|
//calculate number of cells on x and y axis
|
||||||
_mineMap = new MineMap(x, y, minePercentage);
|
var xCellCount = (int)Math.Ceiling((decimal) (x) / 25);
|
||||||
|
var yCellCount = (int)Math.Ceiling((decimal) (y) / 25);
|
||||||
|
Width = xCellCount;
|
||||||
|
Height = yCellCount;
|
||||||
|
_squareMap = new SquareMap(xCellCount, yCellCount);
|
||||||
|
_hexMap = new HexMap(xCellCount, yCellCount);
|
||||||
|
_mineMap = new MineMap(xCellCount, yCellCount, minePercentage);
|
||||||
}
|
}
|
||||||
public IHexMap GetHexMap() => _hexMap ?? throw new NullReferenceException("hex map not initialized");
|
public IHexMap GetHexMap() => _hexMap ?? throw new NullReferenceException("hex map not initialized");
|
||||||
public ISquareMap GetSquareMap() => _squareMap ?? throw new NullReferenceException("square map not initialized");
|
public ISquareMap GetSquareMap() => _squareMap ?? throw new NullReferenceException("square map not initialized");
|
||||||
@@ -34,7 +39,6 @@ namespace ConsoleApp.Maps
|
|||||||
|
|
||||||
public MapFactory(IVehicle vehicle)
|
public MapFactory(IVehicle vehicle)
|
||||||
{
|
{
|
||||||
CellWidth = vehicle.Width/2;
|
|
||||||
_defaultHeight = 0;
|
_defaultHeight = 0;
|
||||||
_defaultWidth = 0;
|
_defaultWidth = 0;
|
||||||
Height = _defaultHeight;
|
Height = _defaultHeight;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using HexCore;
|
||||||
|
|
||||||
namespace ConsoleApp.Maps
|
namespace ConsoleApp.Maps
|
||||||
{
|
{
|
||||||
@@ -9,24 +11,40 @@ namespace ConsoleApp.Maps
|
|||||||
private int _x;
|
private int _x;
|
||||||
private int _y;
|
private int _y;
|
||||||
public bool[,] Map { get; }
|
public bool[,] Map { get; }
|
||||||
|
public int TotalBombs { get; }
|
||||||
|
public List<Cell> PlacedMines { get; }
|
||||||
|
|
||||||
public MineMap(int x, int y, double minePercentage)
|
public MineMap(int x, int y, double minePercentage)
|
||||||
{
|
{
|
||||||
_x = x;
|
_x = x;
|
||||||
_y = y;
|
_y = y;
|
||||||
_mineCount = x*y*((int)minePercentage/100);
|
PlacedMines = new List<Cell>();
|
||||||
|
_mineCount = (int)(x*y*(minePercentage/100));
|
||||||
|
TotalBombs = _mineCount;
|
||||||
Map = new bool[x, y];
|
Map = new bool[x, y];
|
||||||
Map.Fill2DArray(false);
|
Map.Fill2DArray(false);
|
||||||
PlaceMines();
|
PlaceMines();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public bool GetCell(int x, int y) => Map[x,y];
|
||||||
|
|
||||||
|
|
||||||
private void PlaceMines()
|
private void PlaceMines()
|
||||||
{
|
{
|
||||||
var rand = new Random();
|
var rand = new Random();
|
||||||
for (int i = 0; i < _mineCount; i++)
|
for (var i = 0; i < _mineCount; i++)
|
||||||
|
{
|
||||||
|
var x = rand.Next(5,_x-5);
|
||||||
|
var y = rand.Next(5,_y-5);
|
||||||
|
if (Map[x, y] == true)
|
||||||
|
{
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
var x = rand.Next(_x);
|
|
||||||
var y = rand.Next(_y);
|
|
||||||
Map[x, y] = true;
|
Map[x, y] = true;
|
||||||
|
PlacedMines.Add(new Cell(x,y));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection.Metadata.Ecma335;
|
||||||
|
using System.Threading;
|
||||||
|
using HexCore;
|
||||||
|
|
||||||
|
|
||||||
namespace ConsoleApp.Maps
|
namespace ConsoleApp.Maps
|
||||||
@@ -19,30 +23,27 @@ namespace ConsoleApp.Maps
|
|||||||
/// <param name="y"></param>
|
/// <param name="y"></param>
|
||||||
public SquareMap(int x, int y)
|
public SquareMap(int x, int y)
|
||||||
{
|
{
|
||||||
//convert to cm
|
|
||||||
x *= 100;
|
|
||||||
y *= 100;
|
|
||||||
//calculate number of cells on x and y axis
|
|
||||||
var xCellCount = (int)Math.Ceiling((decimal) (x) / 25);
|
|
||||||
var yCellCount = (int)Math.Ceiling((decimal) (y) / 25);
|
|
||||||
|
|
||||||
//set Width and height Properties
|
//set Width and height Properties
|
||||||
Width = xCellCount-1;
|
Width = x-1;
|
||||||
Height = yCellCount-1;
|
Height = y-1;
|
||||||
|
|
||||||
|
|
||||||
//Initialize Map
|
//Initialize Map
|
||||||
Map = new Cell[xCellCount, yCellCount];
|
Map = new Cell[x, y];
|
||||||
|
|
||||||
//set last cell;
|
|
||||||
StartingCell = Map[0, 0];
|
for (int i = 0; i < x; i++)
|
||||||
for (int i = 0; i < xCellCount; i++)
|
|
||||||
{
|
{
|
||||||
for (int j = 0; j < yCellCount; j++)
|
for (int j = 0; j < y; j++)
|
||||||
{
|
{
|
||||||
Map[i,j] = new Cell(i, j);
|
Map[i,j] = new Cell(i, j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//set Starting cell;
|
||||||
|
StartingCell = GetCell(0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -62,7 +63,12 @@ namespace ConsoleApp.Maps
|
|||||||
return possibles;
|
return possibles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Cell> GetRange(Cell centerCell, int radius)
|
public List<ICell> GetShortestPath(ICell start, ICell goal)
|
||||||
|
{
|
||||||
|
return AstarSquareSearch.FindShortestPath(this, start, goal);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Cell> GetRange(ICell centerCell, int radius)
|
||||||
{
|
{
|
||||||
var inRange = new List<Cell>();
|
var inRange = new List<Cell>();
|
||||||
var cx = centerCell.X;
|
var cx = centerCell.X;
|
||||||
@@ -82,6 +88,32 @@ namespace ConsoleApp.Maps
|
|||||||
return inRange;
|
return inRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ICell> GetPassableNeighbors(ICell cell) =>
|
||||||
|
GetNeighbors(cell).Where(neighbor => !neighbor.Blocked).Cast<ICell>().ToList();
|
||||||
|
|
||||||
|
|
||||||
|
private static int ComputeHScore(ICell src, Cell dest)
|
||||||
|
{
|
||||||
|
return Math.Abs(dest.X - src.X) + Math.Abs(dest.Y - src.Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<Cell> GetNeighbors(ICell cell)
|
||||||
|
{
|
||||||
|
var rlist = new List<Cell>();
|
||||||
|
var rowOperations = new int[] { -1, 0, 0, 1};
|
||||||
|
var colOperations = new int[] {0, -1, 1, 0};
|
||||||
|
for (var i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
var curCell = GetCell(cell.X + rowOperations[i], cell.Y + colOperations[i]);
|
||||||
|
if (curCell != default)
|
||||||
|
{
|
||||||
|
rlist.Add(curCell);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rlist;
|
||||||
|
}
|
||||||
|
|
||||||
private Cell GetTopCellInBoundingBox(int cx, int cy, int radius)
|
private Cell GetTopCellInBoundingBox(int cx, int cy, int radius)
|
||||||
{
|
{
|
||||||
int topX, topY;
|
int topX, topY;
|
||||||
@@ -96,16 +128,21 @@ namespace ConsoleApp.Maps
|
|||||||
private Cell GetBottomCellInBoundingBox(int cx, int cy, int radius)
|
private Cell GetBottomCellInBoundingBox(int cx, int cy, int radius)
|
||||||
{
|
{
|
||||||
int bottomX, bottomY;
|
int bottomX, bottomY;
|
||||||
if (cy - radius > 0) bottomY = 0;
|
if (cy - radius < 0) bottomY = 0;
|
||||||
else
|
else
|
||||||
bottomY = cy - radius;
|
bottomY = cy - radius;
|
||||||
if (cx + radius < Width) bottomX = Width;
|
if (cx + radius > Width) bottomX = Width;
|
||||||
else
|
else
|
||||||
bottomX = cx + radius;
|
bottomX = cx + radius;
|
||||||
return Map[bottomX, bottomY];
|
return Map[bottomX, bottomY];
|
||||||
}
|
}
|
||||||
|
|
||||||
public Cell GetCell(int x, int y) => Map[x, y];
|
public Cell GetCell(int x, int y)
|
||||||
|
{
|
||||||
|
if (x > Width || y > Height || x < 0 || y < 0)
|
||||||
|
return default;
|
||||||
|
return Map[x, y];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BIN
ConsoleApp/Output 2.zip
Normal file
BIN
ConsoleApp/Output 2.zip
Normal file
Binary file not shown.
BIN
ConsoleApp/Output.zip
Normal file
BIN
ConsoleApp/Output.zip
Normal file
Binary file not shown.
14
ConsoleApp/Output/Data.txt
Normal file
14
ConsoleApp/Output/Data.txt
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
General:
|
||||||
|
Total Mines: 36
|
||||||
|
Hex:
|
||||||
|
Total Moves: 687
|
||||||
|
Bombs Found: 35
|
||||||
|
Cleared Cell Count: 3591
|
||||||
|
Uncleared Cell Count: 9
|
||||||
|
Percentage Cleared: 99.75
|
||||||
|
Square:
|
||||||
|
Total Moves: 1045
|
||||||
|
Bombs Found: 34
|
||||||
|
Cleared Cell Count: 3251
|
||||||
|
Uncleared Cell Count: 349
|
||||||
|
Percentage Cleared: 90.30555555555554
|
||||||
BIN
ConsoleApp/Output/HexCoverage.png
Normal file
BIN
ConsoleApp/Output/HexCoverage.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
3591
ConsoleApp/Output/HexCoveredCells.txt
Normal file
3591
ConsoleApp/Output/HexCoveredCells.txt
Normal file
File diff suppressed because it is too large
Load Diff
35
ConsoleApp/Output/HexDetectedMines.txt
Normal file
35
ConsoleApp/Output/HexDetectedMines.txt
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
48 7
|
||||||
|
47 13
|
||||||
|
35 8
|
||||||
|
12 8
|
||||||
|
5 18
|
||||||
|
31 14
|
||||||
|
28 20
|
||||||
|
36 14
|
||||||
|
37 12
|
||||||
|
42 18
|
||||||
|
49 16
|
||||||
|
45 23
|
||||||
|
42 23
|
||||||
|
49 27
|
||||||
|
42 29
|
||||||
|
6 22
|
||||||
|
10 28
|
||||||
|
9 31
|
||||||
|
19 27
|
||||||
|
54 29
|
||||||
|
16 39
|
||||||
|
10 34
|
||||||
|
26 40
|
||||||
|
33 42
|
||||||
|
50 42
|
||||||
|
52 53
|
||||||
|
45 48
|
||||||
|
38 48
|
||||||
|
36 51
|
||||||
|
34 51
|
||||||
|
29 54
|
||||||
|
30 50
|
||||||
|
27 54
|
||||||
|
26 49
|
||||||
|
12 49
|
||||||
687
ConsoleApp/Output/HexPath.txt
Normal file
687
ConsoleApp/Output/HexPath.txt
Normal file
@@ -0,0 +1,687 @@
|
|||||||
|
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
|
||||||
|
48 0
|
||||||
|
49 0
|
||||||
|
50 0
|
||||||
|
51 0
|
||||||
|
52 0
|
||||||
|
53 0
|
||||||
|
54 0
|
||||||
|
55 0
|
||||||
|
56 0
|
||||||
|
57 0
|
||||||
|
58 0
|
||||||
|
59 0
|
||||||
|
59 1
|
||||||
|
59 2
|
||||||
|
59 3
|
||||||
|
59 4
|
||||||
|
59 5
|
||||||
|
59 6
|
||||||
|
59 7
|
||||||
|
58 7
|
||||||
|
57 7
|
||||||
|
56 7
|
||||||
|
55 7
|
||||||
|
54 7
|
||||||
|
53 7
|
||||||
|
52 7
|
||||||
|
51 7
|
||||||
|
51 7
|
||||||
|
51 7
|
||||||
|
51 8
|
||||||
|
50 9
|
||||||
|
50 10
|
||||||
|
49 10
|
||||||
|
48 10
|
||||||
|
47 10
|
||||||
|
46 9
|
||||||
|
46 8
|
||||||
|
45 7
|
||||||
|
44 7
|
||||||
|
43 7
|
||||||
|
42 7
|
||||||
|
41 7
|
||||||
|
40 7
|
||||||
|
39 7
|
||||||
|
38 7
|
||||||
|
37 7
|
||||||
|
37 7
|
||||||
|
37 6
|
||||||
|
36 5
|
||||||
|
35 5
|
||||||
|
34 5
|
||||||
|
33 5
|
||||||
|
33 6
|
||||||
|
32 7
|
||||||
|
31 7
|
||||||
|
30 7
|
||||||
|
29 7
|
||||||
|
28 7
|
||||||
|
27 7
|
||||||
|
26 7
|
||||||
|
25 7
|
||||||
|
24 7
|
||||||
|
23 7
|
||||||
|
22 7
|
||||||
|
21 7
|
||||||
|
20 7
|
||||||
|
19 7
|
||||||
|
18 7
|
||||||
|
17 7
|
||||||
|
16 7
|
||||||
|
15 7
|
||||||
|
14 7
|
||||||
|
14 7
|
||||||
|
14 6
|
||||||
|
13 5
|
||||||
|
12 5
|
||||||
|
11 5
|
||||||
|
10 5
|
||||||
|
10 6
|
||||||
|
9 7
|
||||||
|
8 7
|
||||||
|
7 7
|
||||||
|
6 7
|
||||||
|
5 7
|
||||||
|
4 7
|
||||||
|
3 7
|
||||||
|
2 7
|
||||||
|
1 7
|
||||||
|
0 7
|
||||||
|
1 8
|
||||||
|
1 9
|
||||||
|
2 10
|
||||||
|
1 11
|
||||||
|
1 12
|
||||||
|
0 13
|
||||||
|
0 14
|
||||||
|
1 14
|
||||||
|
2 14
|
||||||
|
3 14
|
||||||
|
4 14
|
||||||
|
5 14
|
||||||
|
6 14
|
||||||
|
7 14
|
||||||
|
8 14
|
||||||
|
9 14
|
||||||
|
10 14
|
||||||
|
11 14
|
||||||
|
12 14
|
||||||
|
13 14
|
||||||
|
14 14
|
||||||
|
15 14
|
||||||
|
16 14
|
||||||
|
17 14
|
||||||
|
18 14
|
||||||
|
19 14
|
||||||
|
20 14
|
||||||
|
21 14
|
||||||
|
22 14
|
||||||
|
23 14
|
||||||
|
24 14
|
||||||
|
25 14
|
||||||
|
26 14
|
||||||
|
27 14
|
||||||
|
28 14
|
||||||
|
28 14
|
||||||
|
28 14
|
||||||
|
28 15
|
||||||
|
29 16
|
||||||
|
29 17
|
||||||
|
30 17
|
||||||
|
31 17
|
||||||
|
32 17
|
||||||
|
33 17
|
||||||
|
33 17
|
||||||
|
34 17
|
||||||
|
35 17
|
||||||
|
36 17
|
||||||
|
37 17
|
||||||
|
38 16
|
||||||
|
38 15
|
||||||
|
39 14
|
||||||
|
40 14
|
||||||
|
41 14
|
||||||
|
42 14
|
||||||
|
43 14
|
||||||
|
44 14
|
||||||
|
45 14
|
||||||
|
45 14
|
||||||
|
45 15
|
||||||
|
46 16
|
||||||
|
46 17
|
||||||
|
47 18
|
||||||
|
47 19
|
||||||
|
48 19
|
||||||
|
49 19
|
||||||
|
50 19
|
||||||
|
51 18
|
||||||
|
51 17
|
||||||
|
52 16
|
||||||
|
51 15
|
||||||
|
52 14
|
||||||
|
53 14
|
||||||
|
54 14
|
||||||
|
55 14
|
||||||
|
56 14
|
||||||
|
57 14
|
||||||
|
58 14
|
||||||
|
59 14
|
||||||
|
59 15
|
||||||
|
59 16
|
||||||
|
59 17
|
||||||
|
59 18
|
||||||
|
59 19
|
||||||
|
59 20
|
||||||
|
59 21
|
||||||
|
58 21
|
||||||
|
57 21
|
||||||
|
56 21
|
||||||
|
55 21
|
||||||
|
54 21
|
||||||
|
53 21
|
||||||
|
52 21
|
||||||
|
51 21
|
||||||
|
50 21
|
||||||
|
49 21
|
||||||
|
48 21
|
||||||
|
47 21
|
||||||
|
47 21
|
||||||
|
47 20
|
||||||
|
46 20
|
||||||
|
45 20
|
||||||
|
46 20
|
||||||
|
47 20
|
||||||
|
47 21
|
||||||
|
48 22
|
||||||
|
48 23
|
||||||
|
48 24
|
||||||
|
47 25
|
||||||
|
47 26
|
||||||
|
46 26
|
||||||
|
45 26
|
||||||
|
44 26
|
||||||
|
43 26
|
||||||
|
42 26
|
||||||
|
41 26
|
||||||
|
40 25
|
||||||
|
40 24
|
||||||
|
39 23
|
||||||
|
39 22
|
||||||
|
38 21
|
||||||
|
37 21
|
||||||
|
36 21
|
||||||
|
35 21
|
||||||
|
34 21
|
||||||
|
33 21
|
||||||
|
32 21
|
||||||
|
31 21
|
||||||
|
30 21
|
||||||
|
30 21
|
||||||
|
30 22
|
||||||
|
29 23
|
||||||
|
28 23
|
||||||
|
27 23
|
||||||
|
26 23
|
||||||
|
26 22
|
||||||
|
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
|
||||||
|
11 21
|
||||||
|
10 21
|
||||||
|
9 21
|
||||||
|
8 21
|
||||||
|
8 21
|
||||||
|
9 22
|
||||||
|
8 23
|
||||||
|
8 24
|
||||||
|
7 25
|
||||||
|
6 25
|
||||||
|
5 25
|
||||||
|
4 25
|
||||||
|
4 24
|
||||||
|
3 23
|
||||||
|
3 22
|
||||||
|
2 21
|
||||||
|
1 21
|
||||||
|
0 21
|
||||||
|
1 22
|
||||||
|
1 23
|
||||||
|
2 24
|
||||||
|
1 25
|
||||||
|
1 26
|
||||||
|
0 27
|
||||||
|
0 28
|
||||||
|
1 28
|
||||||
|
2 28
|
||||||
|
3 28
|
||||||
|
4 28
|
||||||
|
5 28
|
||||||
|
6 28
|
||||||
|
7 28
|
||||||
|
7 28
|
||||||
|
7 27
|
||||||
|
8 26
|
||||||
|
8 25
|
||||||
|
9 25
|
||||||
|
10 25
|
||||||
|
11 25
|
||||||
|
12 26
|
||||||
|
12 27
|
||||||
|
13 28
|
||||||
|
14 28
|
||||||
|
15 28
|
||||||
|
16 28
|
||||||
|
17 28
|
||||||
|
17 28
|
||||||
|
17 29
|
||||||
|
18 30
|
||||||
|
19 30
|
||||||
|
20 30
|
||||||
|
21 30
|
||||||
|
21 29
|
||||||
|
22 28
|
||||||
|
23 28
|
||||||
|
24 28
|
||||||
|
25 28
|
||||||
|
26 28
|
||||||
|
27 28
|
||||||
|
28 28
|
||||||
|
29 28
|
||||||
|
30 28
|
||||||
|
31 28
|
||||||
|
32 28
|
||||||
|
33 28
|
||||||
|
34 28
|
||||||
|
35 28
|
||||||
|
36 28
|
||||||
|
37 28
|
||||||
|
38 28
|
||||||
|
39 28
|
||||||
|
40 28
|
||||||
|
40 28
|
||||||
|
40 27
|
||||||
|
41 26
|
||||||
|
42 26
|
||||||
|
43 26
|
||||||
|
44 26
|
||||||
|
44 27
|
||||||
|
45 28
|
||||||
|
46 28
|
||||||
|
47 28
|
||||||
|
47 28
|
||||||
|
47 29
|
||||||
|
48 30
|
||||||
|
49 30
|
||||||
|
50 30
|
||||||
|
51 30
|
||||||
|
51 29
|
||||||
|
52 28
|
||||||
|
52 27
|
||||||
|
53 26
|
||||||
|
54 26
|
||||||
|
55 26
|
||||||
|
56 26
|
||||||
|
56 27
|
||||||
|
57 28
|
||||||
|
58 28
|
||||||
|
59 28
|
||||||
|
59 29
|
||||||
|
59 30
|
||||||
|
59 31
|
||||||
|
59 32
|
||||||
|
59 33
|
||||||
|
59 34
|
||||||
|
59 35
|
||||||
|
58 35
|
||||||
|
57 35
|
||||||
|
56 35
|
||||||
|
55 35
|
||||||
|
54 35
|
||||||
|
53 35
|
||||||
|
52 35
|
||||||
|
51 35
|
||||||
|
50 35
|
||||||
|
49 35
|
||||||
|
48 35
|
||||||
|
47 35
|
||||||
|
46 35
|
||||||
|
45 35
|
||||||
|
44 35
|
||||||
|
43 35
|
||||||
|
42 35
|
||||||
|
41 35
|
||||||
|
40 35
|
||||||
|
39 35
|
||||||
|
38 35
|
||||||
|
37 35
|
||||||
|
36 35
|
||||||
|
35 35
|
||||||
|
34 35
|
||||||
|
33 35
|
||||||
|
32 35
|
||||||
|
31 35
|
||||||
|
30 35
|
||||||
|
29 35
|
||||||
|
28 35
|
||||||
|
27 35
|
||||||
|
26 35
|
||||||
|
25 35
|
||||||
|
24 35
|
||||||
|
23 35
|
||||||
|
22 35
|
||||||
|
21 35
|
||||||
|
20 35
|
||||||
|
19 35
|
||||||
|
18 35
|
||||||
|
17 35
|
||||||
|
16 35
|
||||||
|
15 35
|
||||||
|
14 35
|
||||||
|
13 35
|
||||||
|
12 35
|
||||||
|
12 35
|
||||||
|
12 36
|
||||||
|
11 37
|
||||||
|
10 37
|
||||||
|
9 37
|
||||||
|
8 37
|
||||||
|
8 36
|
||||||
|
7 35
|
||||||
|
6 35
|
||||||
|
5 35
|
||||||
|
4 35
|
||||||
|
3 35
|
||||||
|
2 35
|
||||||
|
1 35
|
||||||
|
0 35
|
||||||
|
1 36
|
||||||
|
1 37
|
||||||
|
2 38
|
||||||
|
1 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
|
||||||
|
24 42
|
||||||
|
24 43
|
||||||
|
25 43
|
||||||
|
26 43
|
||||||
|
27 43
|
||||||
|
28 42
|
||||||
|
29 42
|
||||||
|
30 42
|
||||||
|
30 42
|
||||||
|
30 42
|
||||||
|
30 43
|
||||||
|
31 44
|
||||||
|
31 45
|
||||||
|
32 45
|
||||||
|
33 45
|
||||||
|
34 45
|
||||||
|
35 44
|
||||||
|
35 43
|
||||||
|
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 42
|
||||||
|
47 42
|
||||||
|
47 43
|
||||||
|
48 44
|
||||||
|
48 45
|
||||||
|
49 45
|
||||||
|
50 45
|
||||||
|
51 45
|
||||||
|
52 44
|
||||||
|
52 43
|
||||||
|
53 42
|
||||||
|
54 42
|
||||||
|
55 42
|
||||||
|
56 42
|
||||||
|
57 42
|
||||||
|
58 42
|
||||||
|
59 42
|
||||||
|
59 43
|
||||||
|
59 44
|
||||||
|
59 45
|
||||||
|
59 46
|
||||||
|
59 47
|
||||||
|
59 48
|
||||||
|
59 49
|
||||||
|
58 49
|
||||||
|
57 49
|
||||||
|
56 49
|
||||||
|
55 49
|
||||||
|
54 49
|
||||||
|
53 49
|
||||||
|
52 49
|
||||||
|
51 49
|
||||||
|
50 49
|
||||||
|
49 49
|
||||||
|
48 49
|
||||||
|
47 49
|
||||||
|
47 49
|
||||||
|
47 50
|
||||||
|
46 51
|
||||||
|
45 51
|
||||||
|
44 51
|
||||||
|
43 51
|
||||||
|
43 50
|
||||||
|
42 49
|
||||||
|
41 49
|
||||||
|
40 49
|
||||||
|
40 49
|
||||||
|
40 50
|
||||||
|
39 51
|
||||||
|
39 52
|
||||||
|
38 53
|
||||||
|
38 54
|
||||||
|
37 54
|
||||||
|
36 54
|
||||||
|
35 54
|
||||||
|
34 54
|
||||||
|
33 54
|
||||||
|
32 53
|
||||||
|
32 54
|
||||||
|
31 55
|
||||||
|
31 56
|
||||||
|
30 57
|
||||||
|
29 57
|
||||||
|
28 57
|
||||||
|
27 57
|
||||||
|
26 57
|
||||||
|
25 57
|
||||||
|
25 56
|
||||||
|
24 55
|
||||||
|
24 54
|
||||||
|
24 53
|
||||||
|
24 52
|
||||||
|
23 51
|
||||||
|
23 50
|
||||||
|
23 49
|
||||||
|
22 49
|
||||||
|
21 49
|
||||||
|
20 49
|
||||||
|
19 49
|
||||||
|
18 49
|
||||||
|
17 49
|
||||||
|
16 49
|
||||||
|
15 49
|
||||||
|
15 49
|
||||||
|
15 49
|
||||||
|
15 50
|
||||||
|
14 51
|
||||||
|
14 52
|
||||||
|
13 52
|
||||||
|
12 52
|
||||||
|
11 52
|
||||||
|
10 51
|
||||||
|
10 50
|
||||||
|
9 49
|
||||||
|
8 49
|
||||||
|
7 49
|
||||||
|
6 49
|
||||||
|
5 49
|
||||||
|
4 49
|
||||||
|
3 49
|
||||||
|
2 49
|
||||||
|
1 49
|
||||||
|
0 49
|
||||||
|
1 50
|
||||||
|
1 51
|
||||||
|
2 52
|
||||||
|
1 53
|
||||||
|
1 54
|
||||||
|
0 55
|
||||||
|
0 56
|
||||||
|
1 56
|
||||||
|
2 56
|
||||||
|
3 56
|
||||||
|
4 56
|
||||||
|
5 56
|
||||||
|
6 56
|
||||||
|
7 56
|
||||||
|
8 56
|
||||||
|
9 56
|
||||||
|
10 56
|
||||||
|
11 56
|
||||||
|
12 56
|
||||||
|
13 56
|
||||||
|
14 56
|
||||||
|
15 56
|
||||||
|
16 56
|
||||||
|
17 56
|
||||||
|
18 56
|
||||||
|
19 56
|
||||||
|
20 56
|
||||||
|
21 56
|
||||||
|
22 56
|
||||||
|
23 56
|
||||||
|
24 56
|
||||||
|
25 56
|
||||||
|
25 56
|
||||||
|
25 57
|
||||||
|
26 57
|
||||||
|
27 57
|
||||||
|
28 57
|
||||||
|
29 57
|
||||||
|
30 57
|
||||||
|
31 56
|
||||||
|
32 56
|
||||||
|
33 56
|
||||||
|
34 56
|
||||||
|
35 56
|
||||||
|
36 56
|
||||||
|
37 56
|
||||||
|
38 56
|
||||||
|
39 56
|
||||||
|
40 56
|
||||||
|
41 56
|
||||||
|
42 56
|
||||||
|
43 56
|
||||||
|
44 56
|
||||||
|
45 56
|
||||||
|
46 56
|
||||||
|
47 56
|
||||||
|
48 56
|
||||||
|
49 56
|
||||||
|
50 56
|
||||||
|
51 56
|
||||||
|
52 56
|
||||||
|
53 56
|
||||||
|
54 56
|
||||||
|
55 56
|
||||||
|
56 56
|
||||||
|
57 56
|
||||||
|
58 56
|
||||||
|
59 56
|
||||||
BIN
ConsoleApp/Output/HexTest.png
Normal file
BIN
ConsoleApp/Output/HexTest.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
36
ConsoleApp/Output/Mines.txt
Normal file
36
ConsoleApp/Output/Mines.txt
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
30 50
|
||||||
|
48 7
|
||||||
|
16 39
|
||||||
|
42 18
|
||||||
|
47 13
|
||||||
|
50 42
|
||||||
|
52 53
|
||||||
|
49 16
|
||||||
|
36 14
|
||||||
|
54 29
|
||||||
|
6 22
|
||||||
|
26 49
|
||||||
|
28 20
|
||||||
|
10 34
|
||||||
|
27 54
|
||||||
|
49 27
|
||||||
|
35 8
|
||||||
|
26 40
|
||||||
|
38 48
|
||||||
|
10 28
|
||||||
|
12 8
|
||||||
|
5 18
|
||||||
|
42 23
|
||||||
|
45 23
|
||||||
|
42 29
|
||||||
|
36 51
|
||||||
|
37 12
|
||||||
|
29 54
|
||||||
|
34 51
|
||||||
|
33 12
|
||||||
|
45 48
|
||||||
|
19 27
|
||||||
|
12 49
|
||||||
|
31 14
|
||||||
|
33 42
|
||||||
|
9 31
|
||||||
BIN
ConsoleApp/Output/SquareCoverage.png
Normal file
BIN
ConsoleApp/Output/SquareCoverage.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
3251
ConsoleApp/Output/SquareCoveredCells.txt
Normal file
3251
ConsoleApp/Output/SquareCoveredCells.txt
Normal file
File diff suppressed because it is too large
Load Diff
34
ConsoleApp/Output/SquareDetectedMines.txt
Normal file
34
ConsoleApp/Output/SquareDetectedMines.txt
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
48 7
|
||||||
|
47 13
|
||||||
|
49 16
|
||||||
|
35 8
|
||||||
|
12 8
|
||||||
|
31 14
|
||||||
|
28 20
|
||||||
|
36 14
|
||||||
|
42 18
|
||||||
|
42 23
|
||||||
|
42 29
|
||||||
|
49 27
|
||||||
|
54 29
|
||||||
|
45 23
|
||||||
|
6 22
|
||||||
|
5 18
|
||||||
|
9 31
|
||||||
|
10 28
|
||||||
|
10 34
|
||||||
|
16 39
|
||||||
|
19 27
|
||||||
|
26 40
|
||||||
|
33 42
|
||||||
|
38 48
|
||||||
|
34 51
|
||||||
|
36 51
|
||||||
|
30 50
|
||||||
|
26 49
|
||||||
|
27 54
|
||||||
|
29 54
|
||||||
|
45 48
|
||||||
|
52 53
|
||||||
|
50 42
|
||||||
|
12 49
|
||||||
1045
ConsoleApp/Output/SquarePath.txt
Normal file
1045
ConsoleApp/Output/SquarePath.txt
Normal file
File diff suppressed because it is too large
Load Diff
BIN
ConsoleApp/Output/SquareTest.png
Normal file
BIN
ConsoleApp/Output/SquareTest.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using ConsoleApp.Maps;
|
||||||
using HexCore;
|
using HexCore;
|
||||||
|
|
||||||
namespace ConsoleApp.PathPlanners
|
namespace ConsoleApp.PathPlanners
|
||||||
@@ -6,5 +7,11 @@ namespace ConsoleApp.PathPlanners
|
|||||||
public interface IReactivePathPlanner
|
public interface IReactivePathPlanner
|
||||||
{
|
{
|
||||||
Queue<Coordinate2D> ReactiveHexPath { get; }
|
Queue<Coordinate2D> ReactiveHexPath { get; }
|
||||||
|
void GenerateReactiveHexPath(IHexMap hexMap, Queue<Coordinate2D> optimalPath, Coordinate2D vehicleCurrentHexCell);
|
||||||
|
|
||||||
|
Queue<ICell> ReactiveSquarePath { get; }
|
||||||
|
|
||||||
|
void GenerateReactiveSquarePath(ISquareMap squareMap, Queue<ICell> optimalPath,
|
||||||
|
ICell vehicleCurrentSquareCell);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,49 +11,49 @@ namespace ConsoleApp.PathPlanners
|
|||||||
{
|
{
|
||||||
public Queue<ICell> GenerateOptimalSquarePath(ISquareMap map, IVehicle vehicle)
|
public Queue<ICell> GenerateOptimalSquarePath(ISquareMap map, IVehicle vehicle)
|
||||||
{
|
{
|
||||||
var path = new Queue<ICell>();
|
var currentPostion = vehicle.CurrentSquareCell;
|
||||||
var myCell = map.StartingCell;
|
var currentHeading = GlobalDirection.East;
|
||||||
var finished = false;
|
var finished = false;
|
||||||
var width_cm = (double)(vehicle.DetectorRadius) * 100 * 2;
|
var path = new List<ICell>();
|
||||||
var swathOffset = (int)Math.Floor((decimal) (width_cm) / 25) + 1;
|
|
||||||
var currentHeading = GlobalDirection.North;
|
|
||||||
while (!finished)
|
while (!finished)
|
||||||
{
|
{
|
||||||
var availableMoves = map.PossibleMoves(myCell);
|
//Heading East
|
||||||
if (availableMoves.Contains(GlobalDirection.North) && currentHeading == GlobalDirection.North &&
|
if (currentHeading == GlobalDirection.East)
|
||||||
myCell.Y != map.Height)
|
|
||||||
{
|
{
|
||||||
path.Enqueue(map.GetCell(myCell.X, myCell.Y + 1));
|
path.AddRange(
|
||||||
myCell = map.GetCell(myCell.X, myCell.Y + 1);
|
map.GetShortestPath(currentPostion, map.GetCell(map.Width - 1, currentPostion.Y)));
|
||||||
|
currentPostion = new Cell(map.Width - 1, currentPostion.Y);
|
||||||
}
|
}
|
||||||
else if (availableMoves.Contains(GlobalDirection.South) && currentHeading == GlobalDirection.South && myCell.Y != 0)
|
//Heading West
|
||||||
|
else if (currentHeading == GlobalDirection.West)
|
||||||
{
|
{
|
||||||
path.Enqueue(map.GetCell(myCell.X, myCell.Y - 1));
|
path.AddRange(
|
||||||
myCell = map.GetCell(myCell.X, myCell.Y - 1);
|
map.GetShortestPath(currentPostion, map.GetCell(0, currentPostion.Y)));
|
||||||
|
currentPostion = new Cell(0, currentPostion.Y);
|
||||||
}
|
}
|
||||||
else
|
//Check for finish
|
||||||
{
|
if (currentPostion.Y + (vehicle.DetectorRadius * 2) >= map.Height)
|
||||||
if (myCell.X + swathOffset >= map.Width)
|
|
||||||
{
|
{
|
||||||
finished = true;
|
finished = true;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Move up X Axis
|
||||||
|
path.AddRange(
|
||||||
|
map.GetShortestPath(
|
||||||
|
currentPostion,
|
||||||
|
map.GetCell(currentPostion.X, currentPostion.Y + (vehicle.DetectorRadius * 2) - 1)));
|
||||||
|
|
||||||
|
currentPostion = new Cell(currentPostion.X, currentPostion.Y + (vehicle.DetectorRadius * 2) -1);
|
||||||
|
if (currentHeading == GlobalDirection.East)
|
||||||
|
currentHeading = GlobalDirection.West;
|
||||||
else
|
else
|
||||||
{
|
currentHeading = GlobalDirection.East;
|
||||||
for (int i = myCell.X; i < myCell.X + swathOffset; i++)
|
|
||||||
{
|
|
||||||
path.Enqueue(map.GetCell(i, myCell.Y));
|
|
||||||
}
|
|
||||||
myCell = map.GetCell(myCell.X+swathOffset, myCell.Y);
|
|
||||||
if (currentHeading == GlobalDirection.North)
|
|
||||||
currentHeading = GlobalDirection.South;
|
|
||||||
else if (currentHeading == GlobalDirection.South)
|
|
||||||
currentHeading = GlobalDirection.North;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return path;
|
|
||||||
|
return new Queue<ICell>(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Queue<Coordinate2D> GenerateOptimalHexPath(IHexMap hexMap, IVehicle vehicle)
|
public Queue<Coordinate2D> GenerateOptimalHexPath(IHexMap hexMap, IVehicle vehicle)
|
||||||
@@ -64,16 +64,17 @@ namespace ConsoleApp.PathPlanners
|
|||||||
var path = new List<Coordinate2D>();
|
var path = new List<Coordinate2D>();
|
||||||
while (!finished)
|
while (!finished)
|
||||||
{
|
{
|
||||||
|
//Heading East
|
||||||
if (currentHeading == GlobalDirection.East)
|
if (currentHeading == GlobalDirection.East)
|
||||||
{
|
{
|
||||||
path.AddRange(hexMap.Graph.GetShortestPath(
|
path.AddRange(hexMap.Graph.GetShortestPath(
|
||||||
currentPostion,
|
currentPostion,
|
||||||
new Coordinate2D(hexMap.Width, currentPostion.Y, hexMap.OffsetType),
|
new Coordinate2D(hexMap.Width-1, currentPostion.Y, hexMap.OffsetType),
|
||||||
hexMap.DefaultMovement));
|
hexMap.DefaultMovement));
|
||||||
currentPostion = new Coordinate2D(hexMap.Width, currentPostion.Y, hexMap.OffsetType);
|
currentPostion = new Coordinate2D(hexMap.Width-1, currentPostion.Y, hexMap.OffsetType);
|
||||||
}
|
}
|
||||||
|
//Heading West
|
||||||
else if(currentHeading == GlobalDirection.West)
|
else if (currentHeading == GlobalDirection.West)
|
||||||
{
|
{
|
||||||
path.AddRange(hexMap.Graph.GetShortestPath(
|
path.AddRange(hexMap.Graph.GetShortestPath(
|
||||||
currentPostion,
|
currentPostion,
|
||||||
@@ -83,36 +84,24 @@ namespace ConsoleApp.PathPlanners
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentPostion.Y + vehicle.DetectorRadius * 2 > hexMap.Height)
|
//Check for finish
|
||||||
|
if (currentPostion.Y + (vehicle.DetectorRadius * 2) >= hexMap.Height - 1)
|
||||||
{
|
{
|
||||||
finished = true;
|
finished = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Coordinate2D tmpPosition;
|
//Move Up edges of map
|
||||||
if(currentHeading == GlobalDirection.East)
|
var tmpPosition = currentPostion;
|
||||||
tmpPosition = new Coordinate3D(
|
var range = hexMap.Graph.GetRange(currentPostion, vehicle.DetectorRadius * 2);
|
||||||
currentPostion.To3D().X-1,
|
for (var i = currentPostion.Y; i < currentPostion.Y + vehicle.DetectorRadius * 2; i++)
|
||||||
currentPostion.To3D().Y,
|
|
||||||
currentPostion.To3D().Z+1).To2D(hexMap.OffsetType);
|
|
||||||
else
|
|
||||||
tmpPosition = new Coordinate3D(
|
|
||||||
currentPostion.To3D().X,
|
|
||||||
currentPostion.To3D().Y-1,
|
|
||||||
currentPostion.To3D().Z+1).To2D(hexMap.OffsetType);
|
|
||||||
while (hexMap.Graph.GetRange(currentPostion, vehicle.DetectorRadius*2).Contains(tmpPosition))
|
|
||||||
{
|
{
|
||||||
if(currentHeading == GlobalDirection.East)
|
var newCoord = new Coordinate2D(currentPostion.X, i, hexMap.OffsetType);
|
||||||
tmpPosition = new Coordinate3D(
|
if (range.Contains(newCoord))
|
||||||
tmpPosition.To3D().X-1,
|
tmpPosition = newCoord;
|
||||||
tmpPosition.To3D().Y,
|
|
||||||
tmpPosition.To3D().Z+1).To2D(hexMap.OffsetType);
|
|
||||||
else
|
|
||||||
tmpPosition = new Coordinate3D(
|
|
||||||
tmpPosition.To3D().X,
|
|
||||||
tmpPosition.To3D().Y-1,
|
|
||||||
tmpPosition.To3D().Z+1).To2D(hexMap.OffsetType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
path.AddRange(hexMap.Graph.GetShortestPath(
|
path.AddRange(hexMap.Graph.GetShortestPath(
|
||||||
currentPostion,
|
currentPostion,
|
||||||
tmpPosition,
|
tmpPosition,
|
||||||
@@ -124,7 +113,9 @@ namespace ConsoleApp.PathPlanners
|
|||||||
currentHeading = GlobalDirection.East;
|
currentHeading = GlobalDirection.East;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Queue<Coordinate2D>(path);
|
return new Queue<Coordinate2D>(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,76 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using ConsoleApp.Maps;
|
||||||
using HexCore;
|
using HexCore;
|
||||||
|
|
||||||
namespace ConsoleApp.PathPlanners
|
namespace ConsoleApp.PathPlanners
|
||||||
{
|
{
|
||||||
public class ReactivePathPlanner : IReactivePathPlanner
|
public class ReactivePathPlanner : IReactivePathPlanner
|
||||||
{
|
{
|
||||||
public Queue<Coordinate2D> ReactiveHexPath { get; }
|
private Queue<Coordinate2D> _reactiveHexPath;
|
||||||
|
private Queue<ICell> _reactiveSquarePath;
|
||||||
|
public Queue<Coordinate2D> ReactiveHexPath => _reactiveHexPath;
|
||||||
|
public Queue<ICell> ReactiveSquarePath => _reactiveSquarePath;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public ReactivePathPlanner()
|
public ReactivePathPlanner()
|
||||||
{
|
{
|
||||||
ReactiveHexPath = new Queue<Coordinate2D>();
|
_reactiveHexPath = new Queue<Coordinate2D>();
|
||||||
|
_reactiveSquarePath = new Queue<ICell>();
|
||||||
|
|
||||||
|
}
|
||||||
|
public void GenerateReactiveHexPath(IHexMap hexMap, Queue<Coordinate2D> optimalPath,
|
||||||
|
Coordinate2D vehicleCurrentHexCell)
|
||||||
|
{
|
||||||
|
//Clean out any old path
|
||||||
|
_reactiveHexPath.Clear();
|
||||||
|
|
||||||
|
//If the optimal path is empty well we are done, otherwise pop 1
|
||||||
|
if (!optimalPath.TryDequeue(out var convergentPoint))
|
||||||
|
return;
|
||||||
|
|
||||||
|
//Dequeue until the cell is not blocked
|
||||||
|
while (hexMap.Graph.IsCellBlocked(convergentPoint))
|
||||||
|
{
|
||||||
|
//if optimal path is empty were done and we can not clear around this position, otherwise
|
||||||
|
//lest pop another.
|
||||||
|
if (!optimalPath.TryDequeue(out convergentPoint))
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateReactiveHexPath(Graph graph, ref List<Coordinate3D> optimalPath, Coordinate2D minePosition)
|
var reactivePath = hexMap.Graph.GetShortestPath(vehicleCurrentHexCell, convergentPoint, hexMap.DefaultMovement);
|
||||||
|
foreach (var node in reactivePath)
|
||||||
{
|
{
|
||||||
|
_reactiveHexPath.Enqueue(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void GenerateReactiveSquarePath(ISquareMap squareMap, Queue<ICell> optimalPath,
|
||||||
|
ICell vehicleCurrentSquareCell)
|
||||||
|
{
|
||||||
|
//Clean out old path
|
||||||
|
_reactiveSquarePath.Clear();
|
||||||
|
|
||||||
|
//If the optimal path is empty well we are done, otherwise pop 1
|
||||||
|
if (!optimalPath.TryDequeue(out ICell convergentPoint))
|
||||||
|
return;
|
||||||
|
|
||||||
|
//Dequeue until the cell is not blocked
|
||||||
|
while (squareMap.GetCell(convergentPoint.X, convergentPoint.Y).Blocked)
|
||||||
|
{
|
||||||
|
//if optimal path is empty were done and we can not clear around this position, otherwise
|
||||||
|
//lest pop another.
|
||||||
|
if (!optimalPath.TryDequeue(out convergentPoint))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var map = (SquareMap)squareMap;
|
||||||
|
var reactivePath = map.GetShortestPath(vehicleCurrentSquareCell, convergentPoint);
|
||||||
|
foreach (var node in reactivePath)
|
||||||
|
{
|
||||||
|
_reactiveSquarePath.Enqueue(node);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Threading;
|
||||||
using ConsoleApp.Maps;
|
using ConsoleApp.Maps;
|
||||||
|
|
||||||
namespace ConsoleApp
|
namespace ConsoleApp
|
||||||
@@ -11,26 +15,22 @@ namespace ConsoleApp
|
|||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
_bootstrapper = BootStrapper.BootstrapSystem(new CoreModule());
|
_bootstrapper = BootStrapper.BootstrapSystem(new CoreModule());
|
||||||
|
var simResults = _bootstrapper.Resolve<ISimulationResults>();
|
||||||
_userConsole = new UserConsole();
|
_userConsole = new UserConsole();
|
||||||
Initialization();
|
Initialization();
|
||||||
|
simResults.WriteResults();
|
||||||
|
GenerateImages();
|
||||||
Console.WriteLine("Program Completed");
|
Console.WriteLine("Program Completed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static void Initialization()
|
private static void Initialization()
|
||||||
{
|
|
||||||
_userConsole.PrintStartMenu();
|
|
||||||
var input = UserConsole.GetUserInput();
|
|
||||||
if (input == "1")
|
|
||||||
{
|
{
|
||||||
var (x,y) = _userConsole.GetMapDimensions();
|
var (x,y) = _userConsole.GetMapDimensions();
|
||||||
var minePercentage = UserConsole.GetMinePercentage();
|
var minePercentage = 1;
|
||||||
RunSimulation(x, y, minePercentage);
|
RunSimulation(x, y, minePercentage);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
UserConsole.PrintInvalidInput();
|
|
||||||
Initialization();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void RunSimulation(int x, int y, double minePercentage)
|
private static void RunSimulation(int x, int y, double minePercentage)
|
||||||
@@ -42,5 +42,25 @@ namespace ConsoleApp
|
|||||||
simRunner.Run();
|
simRunner.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void GenerateImages()
|
||||||
|
{
|
||||||
|
var file = Path.Combine("./",Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"plotGraphs.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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,11 +10,20 @@ namespace ConsoleApp.Sim
|
|||||||
Graph graph,
|
Graph graph,
|
||||||
Coordinate2D centerCoordinate,
|
Coordinate2D centerCoordinate,
|
||||||
int detectorRadius,
|
int detectorRadius,
|
||||||
GlobalDirection direction) => graph.GetRange(centerCoordinate, detectorRadius);
|
int vehicleTurnRadius)
|
||||||
|
{
|
||||||
|
var detectorCells = graph.GetRange(centerCoordinate, detectorRadius);
|
||||||
|
// var vehicleCells = graph.GetRange(centerCoordinate, vehicleTurnRadius);
|
||||||
|
// foreach (var vehicleCell in vehicleCells)
|
||||||
|
// {
|
||||||
|
// detectorCells.Remove(vehicleCell);
|
||||||
|
// }
|
||||||
|
return detectorCells;
|
||||||
|
}
|
||||||
|
|
||||||
public static List<Cell> GetCoveredCells(
|
public static List<Cell> GetCoveredCells(
|
||||||
ISquareMap squareMap,
|
ISquareMap squareMap,
|
||||||
Cell centerCell,
|
Cell centerCell,
|
||||||
int detectorRadius) => squareMap.GetRange(centerCell, detectorRadius);
|
int detectorRadius) => squareMap.GetRange(centerCell, detectorRadius * 2 - detectorRadius%2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using ConsoleApp.Maps;
|
using ConsoleApp.Maps;
|
||||||
|
using HexCore;
|
||||||
|
|
||||||
namespace ConsoleApp.Sim
|
namespace ConsoleApp.Sim
|
||||||
{
|
{
|
||||||
@@ -6,11 +7,9 @@ namespace ConsoleApp.Sim
|
|||||||
{
|
{
|
||||||
int Length { get; }
|
int Length { get; }
|
||||||
int Width { get; }
|
int Width { get; }
|
||||||
int DetectorOffset { get;}
|
int TurnRadius { get; }
|
||||||
int DetectorRadius { get;}
|
int DetectorRadius { get;}
|
||||||
HexCore.Coordinate2D CurrentHexCell { get; set; }
|
Coordinate2D CurrentHexCell { get; set; }
|
||||||
Heading HexHeading { get; set; }
|
Cell CurrentSquareCell { get; set; }
|
||||||
Heading SquareHeading { get; set; }
|
|
||||||
ICell CurrentSquareCell { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using ConsoleApp.Maps;
|
using ConsoleApp.Maps;
|
||||||
|
|
||||||
namespace ConsoleApp.Sim
|
namespace ConsoleApp.Sim
|
||||||
@@ -6,13 +8,10 @@ namespace ConsoleApp.Sim
|
|||||||
{
|
{
|
||||||
public int Length { get; }
|
public int Length { get; }
|
||||||
public int Width { get; }
|
public int Width { get; }
|
||||||
|
public int TurnRadius { get; }
|
||||||
public int DetectorOffset { get;}
|
|
||||||
public int DetectorRadius { get;}
|
public int DetectorRadius { get;}
|
||||||
public HexCore.Coordinate2D CurrentHexCell { get; set; }
|
public HexCore.Coordinate2D CurrentHexCell { get; set; }
|
||||||
public Heading HexHeading { get; set; }
|
public Cell CurrentSquareCell { get; set; }
|
||||||
public Heading SquareHeading { get; set; }
|
|
||||||
public ICell CurrentSquareCell { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -20,12 +19,17 @@ namespace ConsoleApp.Sim
|
|||||||
public Vehicle(IJsonDeserializor jsonDeserializor)
|
public Vehicle(IJsonDeserializor jsonDeserializor)
|
||||||
{
|
{
|
||||||
var config = jsonDeserializor.DeserializeObject<VehicleConfiguration>("/Users/brady.bodily/Documents/Repositories/CS5890_Robot_Intelligence/RobotIntelFinal/ConsoleApp/Sim/VehicleConfiguration.json");
|
var config = jsonDeserializor.DeserializeObject<VehicleConfiguration>("/Users/brady.bodily/Documents/Repositories/CS5890_Robot_Intelligence/RobotIntelFinal/ConsoleApp/Sim/VehicleConfiguration.json");
|
||||||
Length = config.Length;
|
var length = config.Length;
|
||||||
Width = config.Width;
|
length *= 100;
|
||||||
DetectorRadius = config.DetectorRadius;
|
Length = (int)Math.Ceiling((decimal)length/ 25);
|
||||||
DetectorOffset = config.DetectorOffset;
|
var width = config.Width;
|
||||||
CurrentHexCell = default;
|
width *= 100;
|
||||||
CurrentSquareCell = default;
|
Width = (int)Math.Ceiling((decimal)width/ 25);
|
||||||
|
DetectorRadius = (int)Math.Floor(((decimal)config.DetectorRadius * 100)/25)/2;
|
||||||
|
TurnRadius = (int)Math.Ceiling(Math.Sqrt(Math.Pow(config.Length, 2) * Math.Pow(config.Width, 2))/2);
|
||||||
|
// if (DetectorRadius <= TurnRadius)
|
||||||
|
// throw new ArgumentException("Detection radius must be larger than the vehicle turn radius");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,5 @@ namespace ConsoleApp.Sim
|
|||||||
public int Length { get; set; }
|
public int Length { get; set; }
|
||||||
public int Width { get; set; }
|
public int Width { get; set; }
|
||||||
public int DetectorRadius { get; set; }
|
public int DetectorRadius { get; set; }
|
||||||
public int DetectorOffset { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
"Length": 3,
|
"Length": 1,
|
||||||
"Width": 2,
|
"Width": 1,
|
||||||
"DetectorRadius": 3,
|
"DetectorRadius": 2
|
||||||
"DetectorOffset": 2
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using ConsoleApp.Maps;
|
using ConsoleApp.Maps;
|
||||||
using ConsoleApp.PathPlanners;
|
using ConsoleApp.PathPlanners;
|
||||||
using ConsoleApp.Sim;
|
using ConsoleApp.Sim;
|
||||||
@@ -14,46 +13,241 @@ namespace ConsoleApp
|
|||||||
private IMapFactory _mapFactory;
|
private IMapFactory _mapFactory;
|
||||||
private IVehicle _vehicle;
|
private IVehicle _vehicle;
|
||||||
|
|
||||||
private int _cellWidth;
|
|
||||||
private IPathPlanner _pathPlanner;
|
private IPathPlanner _pathPlanner;
|
||||||
private IMineMap _mineMap;
|
private IMineMap _mineMap;
|
||||||
private IReactivePathPlanner _reactivePathPlanner;
|
private IReactivePathPlanner _reactivePathPlanner;
|
||||||
|
private HashSet<Coordinate2D> hexBombsFound = new HashSet<Coordinate2D>();
|
||||||
|
private ISimulationResults _simulationResults;
|
||||||
|
private HashSet<ICell> squareBombsFound = new HashSet<ICell>();
|
||||||
|
|
||||||
|
|
||||||
public SimRunner(IMapFactory mapFactory, IVehicle vehicle, IPathPlanner pathPlanner, IReactivePathPlanner reactivePathPlanner)
|
|
||||||
|
public SimRunner(IMapFactory mapFactory, IVehicle vehicle, IPathPlanner pathPlanner, IReactivePathPlanner reactivePathPlanner, ISimulationResults simulationResults)
|
||||||
{
|
{
|
||||||
|
|
||||||
_cellWidth = mapFactory.CellWidth;
|
|
||||||
_mapFactory = mapFactory;
|
_mapFactory = mapFactory;
|
||||||
_vehicle = vehicle;
|
_vehicle = vehicle;
|
||||||
_pathPlanner = pathPlanner;
|
_pathPlanner = pathPlanner;
|
||||||
_reactivePathPlanner = reactivePathPlanner;
|
_reactivePathPlanner = reactivePathPlanner;
|
||||||
|
_simulationResults = simulationResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
{
|
{
|
||||||
_mineMap = _mapFactory.GetMineMap();
|
_mineMap = _mapFactory.GetMineMap();
|
||||||
|
_simulationResults.Mines = _mineMap.PlacedMines;
|
||||||
|
_simulationResults.TotalBombs = _mineMap.TotalBombs;
|
||||||
SquareSimulation();
|
SquareSimulation();
|
||||||
HexSimulation();
|
HexSimulation();
|
||||||
// while(!squareTask.IsCompleted && !hexTask.IsCompleted){Thread.Sleep(500);}
|
// while(!squareTask.IsCompleted && !hexTask.IsCompleted){Thread.Sleep(500);}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region HexSimulation
|
||||||
|
|
||||||
private void HexSimulation()
|
private void HexSimulation()
|
||||||
{
|
{
|
||||||
var hexMap = _mapFactory.GetHexMap();
|
var hexMap = _mapFactory.GetHexMap();
|
||||||
_vehicle.CurrentHexCell = new Coordinate2D(0, 0, OffsetTypes.OddRowsRight);
|
_vehicle.CurrentHexCell = new Coordinate2D(0, 0, OffsetTypes.OddRowsRight);
|
||||||
var optimalPath = _pathPlanner.GenerateOptimalHexPath(hexMap, _vehicle);
|
var optimalPath = _pathPlanner.GenerateOptimalHexPath(hexMap, _vehicle);
|
||||||
var reactivePath = _reactivePathPlanner.ReactiveHexPath;
|
var finished = false;
|
||||||
|
var totalMoves = 0;
|
||||||
|
while (!finished)
|
||||||
|
{
|
||||||
|
totalMoves += 1;
|
||||||
|
_simulationResults.HexPath.Add(_vehicle.CurrentHexCell);
|
||||||
|
|
||||||
|
var detectionCells = DetectionHead.GetCoveredCells(hexMap.Graph, _vehicle.CurrentHexCell, _vehicle.DetectorRadius, _vehicle.TurnRadius);
|
||||||
|
//Check Cells for mine
|
||||||
|
var detection = CheckCells(detectionCells);
|
||||||
|
//mark as cleared
|
||||||
|
hexMap.Graph.SetCellsTerrainType(detectionCells, hexMap.ClearedTerrain);
|
||||||
|
//Handle any detections
|
||||||
|
if (detection)
|
||||||
|
{
|
||||||
|
_reactivePathPlanner.GenerateReactiveHexPath(hexMap, optimalPath, _vehicle.CurrentHexCell);
|
||||||
|
}
|
||||||
|
|
||||||
|
//If the reactive Planner is not empty, empty it before the optimal.
|
||||||
|
if (_reactivePathPlanner.ReactiveHexPath.TryDequeue(out var next))
|
||||||
|
_vehicle.CurrentHexCell = next;
|
||||||
|
//Else we will work off of the optimal path
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//If the optimal path is empty we are done otherwise pop.
|
||||||
|
if (!optimalPath.TryDequeue(out var nextOptimal))
|
||||||
|
{
|
||||||
|
finished = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hexMap.Graph.IsCellBlocked(nextOptimal))
|
||||||
|
{
|
||||||
|
_reactivePathPlanner.GenerateReactiveHexPath(hexMap, optimalPath, _vehicle.CurrentHexCell);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_vehicle.CurrentHexCell = nextOptimal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Debugging information
|
||||||
|
var (cleared, uncleared) = CoveredCells();
|
||||||
|
_simulationResults.HexClearedCells = cleared;
|
||||||
|
_simulationResults.HexUnClearedCells = uncleared;
|
||||||
|
_simulationResults.HexTotalMoves = totalMoves;
|
||||||
|
_simulationResults.HexBombsFound = hexBombsFound.Count;
|
||||||
|
_simulationResults.HexMappedBombs = hexBombsFound.ToList();
|
||||||
|
|
||||||
|
foreach (var cell in hexMap.Graph.GetAllCells())
|
||||||
|
{
|
||||||
|
if(cell.TerrainType.Id == hexMap.ClearedTerrain.Id)
|
||||||
|
_simulationResults.HexCoveredCells.Add(cell.Coordinate3.To2D(hexMap.OffsetType));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private (int, int) CoveredCells()
|
||||||
|
{
|
||||||
|
var cleared = 0;
|
||||||
|
var uncleared = 0;
|
||||||
|
var hexMap = _mapFactory.GetHexMap();
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private bool CheckCells(List<Coordinate2D> detectionCells)
|
||||||
|
{
|
||||||
|
var found = false;
|
||||||
|
foreach (var cell in detectionCells.Where(cell => _mineMap.GetCell(cell.X, cell.Y)))
|
||||||
|
{
|
||||||
|
if (!hexBombsFound.Add(cell)) continue;
|
||||||
|
BlockCells(cell);
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BlockCells(Coordinate2D cell)
|
||||||
|
{
|
||||||
|
var hexMap = _mapFactory.GetHexMap();
|
||||||
|
var cellsToBlock = hexMap.Graph.GetRange(cell, _vehicle.Width / 2);
|
||||||
|
hexMap.Graph.BlockCells(cellsToBlock);
|
||||||
|
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region SquareSimulation
|
||||||
private void SquareSimulation()
|
private void SquareSimulation()
|
||||||
{
|
{
|
||||||
var squareMap = _mapFactory.GetSquareMap();
|
var squareMap = _mapFactory.GetSquareMap();
|
||||||
_vehicle.CurrentSquareCell = squareMap.StartingCell;
|
_vehicle.CurrentSquareCell = squareMap.StartingCell;
|
||||||
var optimalPath = _pathPlanner.GenerateOptimalSquarePath(squareMap, _vehicle);
|
var optimalPath = _pathPlanner.GenerateOptimalSquarePath(squareMap, _vehicle);
|
||||||
|
var finished = false;
|
||||||
|
while (!finished)
|
||||||
|
{
|
||||||
|
_simulationResults.SquareTotalMoves++;
|
||||||
|
_simulationResults.SquarePath.Add(_vehicle.CurrentSquareCell);
|
||||||
|
var detector = squareMap.GetRange(_vehicle.CurrentSquareCell, _vehicle.DetectorRadius);
|
||||||
|
var detection = CheckForMines(detector);
|
||||||
|
//Mark cells as covered.
|
||||||
|
foreach (var cell in detector)
|
||||||
|
{
|
||||||
|
cell.Coverage = Coverage.Covered;
|
||||||
|
}
|
||||||
|
if (detection)
|
||||||
|
_reactivePathPlanner.GenerateReactiveSquarePath(squareMap, optimalPath, _vehicle.CurrentSquareCell);
|
||||||
|
if (_reactivePathPlanner.ReactiveSquarePath.TryDequeue(out var next))
|
||||||
|
{
|
||||||
|
_vehicle.CurrentSquareCell = (Cell) next;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!optimalPath.TryDequeue(out var current))
|
||||||
|
{
|
||||||
|
finished = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (current.Blocked)
|
||||||
|
{
|
||||||
|
_reactivePathPlanner.GenerateReactiveSquarePath(squareMap, optimalPath, current);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_vehicle.CurrentSquareCell = (Cell) current;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Debugging information
|
||||||
|
var (cleared, uncleared) = CoveredSquareCells();
|
||||||
|
_simulationResults.SquareCellsCleared = cleared;
|
||||||
|
_simulationResults.SquareCellsUncleared = uncleared;
|
||||||
|
_simulationResults.SquareBombsFound = squareBombsFound.Count;
|
||||||
|
_simulationResults.SquareMappedBombs = squareBombsFound.ToList();
|
||||||
|
|
||||||
|
foreach (var cell in squareMap.Map)
|
||||||
|
{
|
||||||
|
if (cell.Coverage == Coverage.Covered)
|
||||||
|
{
|
||||||
|
_simulationResults.SquareCoveredCells.Add(cell);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private (int, int) CoveredSquareCells()
|
||||||
|
{
|
||||||
|
var cleared = 0;
|
||||||
|
var uncleared = 0;
|
||||||
|
var map = _mapFactory.GetSquareMap();
|
||||||
|
foreach (var cellState in map.Map)
|
||||||
|
{
|
||||||
|
switch (cellState.Coverage)
|
||||||
|
{
|
||||||
|
case Coverage.Covered:
|
||||||
|
cleared++;
|
||||||
|
break;
|
||||||
|
case Coverage.Uncovered:
|
||||||
|
uncleared++;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (cleared, uncleared);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool CheckForMines(List<Cell> detector)
|
||||||
|
{
|
||||||
|
var found = false;
|
||||||
|
foreach (var cell in detector.Where(cell => _mineMap.GetCell(cell.X, cell.Y)))
|
||||||
|
{
|
||||||
|
if(!squareBombsFound.Add(cell)) continue;
|
||||||
|
found = true;
|
||||||
|
BlockSquareCells(cell);
|
||||||
|
}
|
||||||
|
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BlockSquareCells(Cell cell)
|
||||||
|
{
|
||||||
|
var map = _mapFactory.GetSquareMap();
|
||||||
|
var cellsToBlock = map.GetRange(cell, _vehicle.DetectorRadius);
|
||||||
|
foreach (var blockCell in cellsToBlock)
|
||||||
|
{
|
||||||
|
blockCell.Blocked = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
138
ConsoleApp/SimulationResults.cs
Normal file
138
ConsoleApp/SimulationResults.cs
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
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<Coordinate2D> HexPath { get; set; }
|
||||||
|
public List<Coordinate2D> HexMappedBombs { get; set; }
|
||||||
|
public List<Cell> Mines { get; set; }
|
||||||
|
public int HexClearedCells { get; set; }
|
||||||
|
public int HexUnClearedCells { get; set; }
|
||||||
|
|
||||||
|
public List<ICell> SquarePath { get; set; }
|
||||||
|
public List<ICell> SquareMappedBombs { get; set; }
|
||||||
|
public int SquareCellsUncleared { get; set; }
|
||||||
|
public int SquareCellsCleared { get; set; }
|
||||||
|
public int SquareBombsFound { get; set; }
|
||||||
|
public int SquareTotalMoves { get; set; }
|
||||||
|
public List<ICell> SquareCoveredCells { get; set; }
|
||||||
|
public List<Coordinate2D> HexCoveredCells { get; set; }
|
||||||
|
|
||||||
|
public SimulationResults()
|
||||||
|
{
|
||||||
|
HexTotalMoves = 0;
|
||||||
|
HexBombsFound = 0;
|
||||||
|
TotalBombs = 0;
|
||||||
|
HexPath = new List<Coordinate2D>();
|
||||||
|
HexMappedBombs = new List<Coordinate2D>();
|
||||||
|
Mines = new List<Cell>();
|
||||||
|
HexClearedCells = 0;
|
||||||
|
HexUnClearedCells = 0;
|
||||||
|
SquarePath = new List<ICell>();
|
||||||
|
SquareMappedBombs = new List<ICell>();
|
||||||
|
SquareCellsUncleared = 0;
|
||||||
|
SquareCellsCleared = 0;
|
||||||
|
SquareBombsFound = 0;
|
||||||
|
SquareTotalMoves = 0;
|
||||||
|
SquareCoveredCells = new List<ICell>();
|
||||||
|
HexCoveredCells = new List<Coordinate2D>();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void WriteResults()
|
||||||
|
{
|
||||||
|
WriteData();
|
||||||
|
WriteMines();
|
||||||
|
WritePaths();
|
||||||
|
WriteDetectedMines();
|
||||||
|
WriteCoveredCells();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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}");
|
||||||
|
tw.WriteLine($"\t Percentage Cleared: {(double)HexClearedCells/(HexClearedCells+HexUnClearedCells)*100}");
|
||||||
|
tw.WriteLine($"Square: ");
|
||||||
|
tw.WriteLine($"\t Total Moves: {SquareTotalMoves}");
|
||||||
|
tw.WriteLine($"\t Bombs Found: {SquareBombsFound}");
|
||||||
|
tw.WriteLine($"\t Cleared Cell Count: {SquareCellsCleared}");
|
||||||
|
tw.WriteLine($"\t Uncleared Cell Count: {SquareCellsUncleared}");
|
||||||
|
tw.WriteLine($"\t Percentage Cleared: {(double) SquareCellsCleared / (SquareCellsCleared + SquareCellsUncleared)*100}");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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 WriteCoveredCells()
|
||||||
|
{
|
||||||
|
using(TextWriter tw = new StreamWriter("/Users/brady.bodily/Documents/Repositories/CS5890_Robot_Intelligence/RobotIntelFinal/ConsoleApp/Output/HexCoveredCells.txt"))
|
||||||
|
{
|
||||||
|
foreach (var s in HexCoveredCells)
|
||||||
|
tw.WriteLine($"{s.X} {s.Y}");
|
||||||
|
}
|
||||||
|
using(TextWriter tw = new StreamWriter("/Users/brady.bodily/Documents/Repositories/CS5890_Robot_Intelligence/RobotIntelFinal/ConsoleApp/Output/SquareCoveredCells.txt"))
|
||||||
|
{
|
||||||
|
foreach (var s in SquareCoveredCells)
|
||||||
|
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 (var s in HexMappedBombs)
|
||||||
|
tw.WriteLine($"{s.X} {s.Y}");
|
||||||
|
}
|
||||||
|
using(TextWriter tw = new StreamWriter("/Users/brady.bodily/Documents/Repositories/CS5890_Robot_Intelligence/RobotIntelFinal/ConsoleApp/Output/SquareDetectedMines.txt"))
|
||||||
|
{
|
||||||
|
foreach (var s in SquareMappedBombs)
|
||||||
|
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 (var s in HexPath)
|
||||||
|
tw.WriteLine($"{s.X} {s.Y}");
|
||||||
|
}
|
||||||
|
using(TextWriter tw = new StreamWriter("/Users/brady.bodily/Documents/Repositories/CS5890_Robot_Intelligence/RobotIntelFinal/ConsoleApp/Output/SquarePath.txt"))
|
||||||
|
{
|
||||||
|
foreach (var s in SquarePath)
|
||||||
|
tw.WriteLine($"{s.X} {s.Y}");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,18 +24,18 @@ namespace ConsoleApp
|
|||||||
|
|
||||||
public (int width, int height) GetMapDimensions()
|
public (int width, int height) GetMapDimensions()
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Enter map height: ");
|
Console.WriteLine($"Enter map width (5-15) meters: ");
|
||||||
var x = GetUserInput();
|
var x = GetUserInput();
|
||||||
|
|
||||||
if (!int.TryParse(x, out var width))
|
if (!int.TryParse(x, out var width) && width >= 5 && width <= 15)
|
||||||
{
|
{
|
||||||
PrintInvalidInput();
|
PrintInvalidInput();
|
||||||
GetMapDimensions();
|
GetMapDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine($"Enter map height: ");
|
Console.WriteLine($"Enter map height (5-15) meters: ");
|
||||||
var y = GetUserInput();
|
var y = GetUserInput();
|
||||||
if (int.TryParse(y, out var height)) return (width, height);
|
if (int.TryParse(y, out var height) && height >= 5 && height <= 15) return (width, height);
|
||||||
PrintInvalidInput();
|
PrintInvalidInput();
|
||||||
GetMapDimensions();
|
GetMapDimensions();
|
||||||
return (width, height);
|
return (width, height);
|
||||||
|
|||||||
122
ConsoleApp/plotGraphs.py
Normal file
122
ConsoleApp/plotGraphs.py
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
import numpy as np
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import matplotlib
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
xc = []
|
||||||
|
yc = []
|
||||||
|
xm = []
|
||||||
|
ym = []
|
||||||
|
xf = []
|
||||||
|
yf = []
|
||||||
|
sxc = []
|
||||||
|
syc = []
|
||||||
|
sxm = []
|
||||||
|
sym = []
|
||||||
|
sxf = []
|
||||||
|
syf = []
|
||||||
|
|
||||||
|
sccx = []
|
||||||
|
sccy = []
|
||||||
|
hccx = []
|
||||||
|
hccy = []
|
||||||
|
|
||||||
|
mx = []
|
||||||
|
my = []
|
||||||
|
|
||||||
|
with open("/Users/brady.bodily/Documents/Repositories/CS5890_Robot_Intelligence/RobotIntelFinal/ConsoleApp/Output/SquareCoveredCells.txt") as c:
|
||||||
|
for line in c:
|
||||||
|
x, y = line.split()
|
||||||
|
sccx.append(int(x))
|
||||||
|
sccy.append(int(y))
|
||||||
|
|
||||||
|
with open("/Users/brady.bodily/Documents/Repositories/CS5890_Robot_Intelligence/RobotIntelFinal/ConsoleApp/Output/Mines.txt") as c:
|
||||||
|
for line in c:
|
||||||
|
x, y = line.split()
|
||||||
|
mx.append(int(x))
|
||||||
|
my.append(int(y))
|
||||||
|
|
||||||
|
with open("/Users/brady.bodily/Documents/Repositories/CS5890_Robot_Intelligence/RobotIntelFinal/ConsoleApp/Output/SquareDetectedMines.txt") as c:
|
||||||
|
for line in c:
|
||||||
|
x, y = line.split()
|
||||||
|
sxf.append(int(x))
|
||||||
|
syf.append(int(y))
|
||||||
|
|
||||||
|
|
||||||
|
with open("/Users/brady.bodily/Documents/Repositories/CS5890_Robot_Intelligence/RobotIntelFinal/ConsoleApp/Output/HexCoveredCells.txt") as c:
|
||||||
|
for line in c:
|
||||||
|
x, y = line.split()
|
||||||
|
hccx.append(int(x))
|
||||||
|
hccy.append(int(y))
|
||||||
|
|
||||||
|
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))
|
||||||
|
yc.append(int(y))
|
||||||
|
|
||||||
|
with open("/Users/brady.bodily/Documents/Repositories/CS5890_Robot_Intelligence/RobotIntelFinal/ConsoleApp/Output/SquarePath.txt") as c:
|
||||||
|
for line in c:
|
||||||
|
x, y = line.split()
|
||||||
|
sxc.append(int(x))
|
||||||
|
syc.append(int(y))
|
||||||
|
|
||||||
|
with open("/Users/brady.bodily/Documents/Repositories/CS5890_Robot_Intelligence/RobotIntelFinal/ConsoleApp/Output/Mines.txt") as m:
|
||||||
|
for line in m:
|
||||||
|
x, y = line.split()
|
||||||
|
xm.append(int(x))
|
||||||
|
ym.append(int(y))
|
||||||
|
|
||||||
|
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))
|
||||||
|
yf.append(int(y))
|
||||||
|
|
||||||
|
fig = plt.figure(1)
|
||||||
|
plt.plot(xc, yc, 'h', label='vehicle', color='blue', linestyle='None')
|
||||||
|
plt.plot(xm, ym, 'h', label='all mines', color='red', linestyle='None')
|
||||||
|
plt.plot(xf, yf, 'h', label='detected mines', color='orange', linestyle='None')
|
||||||
|
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/HexTest.png')
|
||||||
|
|
||||||
|
plt.plot()
|
||||||
|
plt.close(fig)
|
||||||
|
|
||||||
|
fig = plt.figure(2)
|
||||||
|
plt.plot(sxc, syc, 's', label='vehicle', color='blue', linestyle='None')
|
||||||
|
plt.plot(sxm, sym, 's', label='all mines', color='red', linestyle='None')
|
||||||
|
plt.plot(sxf, syf, 's', label='detected mines', color='orange', linestyle='None')
|
||||||
|
plt.title('Square Simulation')
|
||||||
|
plt.legend(loc='lower left', fontsize='xx-small')
|
||||||
|
matplotlib.pyplot.savefig('/Users/brady.bodily/Documents/Repositories/CS5890_Robot_Intelligence/RobotIntelFinal/ConsoleApp/Output/SquareTest.png')
|
||||||
|
plt.plot()
|
||||||
|
plt.close(fig)
|
||||||
|
|
||||||
|
fig = plt.figure(3)
|
||||||
|
plt.plot(hccx, hccy, 'h', label='covered cells', color='red', linestyle='None')
|
||||||
|
plt.plot(xf, yf, 'h', label='detected mines', color='blue', linestyle='None')
|
||||||
|
plt.title('Hex Coverage')
|
||||||
|
plt.legend(loc='lower left', fontsize='xx-small')
|
||||||
|
matplotlib.pyplot.savefig('/Users/brady.bodily/Documents/Repositories/CS5890_Robot_Intelligence/RobotIntelFinal/ConsoleApp/Output/HexCoverage.png')
|
||||||
|
plt.plot()
|
||||||
|
plt.close(fig)
|
||||||
|
|
||||||
|
fig = plt.figure(4)
|
||||||
|
plt.plot(sccx, sccy, 's', label='covered cells', color='red', linestyle='None')
|
||||||
|
plt.plot(sxf, syf, 's', label='detected mines', color='blue', linestyle='None')
|
||||||
|
plt.title('Square Coverage')
|
||||||
|
plt.legend(loc='lower left', fontsize='xx-small')
|
||||||
|
matplotlib.pyplot.savefig('/Users/brady.bodily/Documents/Repositories/CS5890_Robot_Intelligence/RobotIntelFinal/ConsoleApp/Output/SquareCoverage.png')
|
||||||
|
plt.plot()
|
||||||
|
plt.close(fig)
|
||||||
|
|
||||||
|
fig = plt.figure(5)
|
||||||
|
plt.plot(mx, my, 'o', label='mines', color='red', linestyle='None')
|
||||||
|
plt.title('Mine Map')
|
||||||
|
plt.legend(loc='lower left', fontsize='xx-small')
|
||||||
|
matplotlib.pyplot.savefig('/Users/brady.bodily/Documents/Repositories/CS5890_Robot_Intelligence/RobotIntelFinal/ConsoleApp/Output/Mines.png')
|
||||||
|
plt.plot()
|
||||||
|
plt.close(fig)
|
||||||
Reference in New Issue
Block a user