Done for the night
Need to change planning algo for square to go right to left.
This commit is contained in:
@@ -9,7 +9,6 @@
|
||||
<e p="CoreModule.cs" t="Include" />
|
||||
<e p="IJsonDeserializor.cs" t="Include" />
|
||||
<e p="IModule.cs" t="Include" />
|
||||
<e p="IPathPlanner.cs" t="Include" />
|
||||
<e p="ISimRunner.cs" t="Include" />
|
||||
<e p="IUserConsole.cs" t="Include" />
|
||||
<e p="IVehicle.cs" t="Include" />
|
||||
@@ -34,7 +33,10 @@
|
||||
</e>
|
||||
</e>
|
||||
</e>
|
||||
<e p="PathPlanners" t="Include">
|
||||
<e p="IPathPlanner.cs" t="Include" />
|
||||
<e p="PathPlanner.cs" t="Include" />
|
||||
</e>
|
||||
<e p="Program.cs" t="Include" />
|
||||
<e p="SimRunner.cs" t="Include" />
|
||||
<e p="UserConsole.cs" t="Include" />
|
||||
|
||||
81
.idea/.idea.RobotIntelFinal/.idea/workspace.xml
generated
81
.idea/.idea.RobotIntelFinal/.idea/workspace.xml
generated
@@ -18,17 +18,18 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="dafcaeb7-80aa-43a3-a480-786fafb78c0b" name="Default Changelist" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/ConsoleApp/IPathPlanner.cs" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/ConsoleApp/Maps/GlobalDirection.cs" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/ConsoleApp/PathPlanner.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$/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/Maps/Direction.cs" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ConsoleApp/Maps/Heading.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/Maps/Heading.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ConsoleApp/IPathPlanner.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/PathPlanners/IPathPlanner.cs" 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/Maps/GlobalDirection.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/Maps/GlobalDirection.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ConsoleApp/Maps/HexMap.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/Maps/HexMap.cs" 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/Maps/IMap.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/Maps/IMap.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ConsoleApp/Maps/SquareMap.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/Maps/SquareMap.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ConsoleApp/PathPlanner.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/PathPlanners/PathPlanner.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ConsoleApp/SimRunner.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/SimRunner.cs" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
@@ -47,29 +48,38 @@
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<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="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/f7/268fdeac/Graph.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/84/4eb9c798/GraphUtils.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="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/14/12025305/MovementTypes.cs" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///Dummy.cs" root0="SKIP_HIGHLIGHTING" />
|
||||
</component>
|
||||
<component name="IdeDocumentHistory">
|
||||
<changedPaths>
|
||||
<option value="$PROJECT_DIR$/ConsoleApp/Maps/Heading.cs" />
|
||||
<option value="$PROJECT_DIR$/ConsoleApp/Maps/Direction.cs" />
|
||||
<option value="$PROJECT_DIR$/ConsoleApp/Maps/GlobalDirection.cs" />
|
||||
<option value="$PROJECT_DIR$/ConsoleApp/Maps/IMap.cs" />
|
||||
<option value="$PROJECT_DIR$/ConsoleApp/IPathPlanner.cs" />
|
||||
<option value="$PROJECT_DIR$/ConsoleApp/CoreModule.cs" />
|
||||
<option value="$PROJECT_DIR$/ConsoleApp/Maps/HexMap.cs" />
|
||||
<option value="$PROJECT_DIR$/ConsoleApp/SimRunner.cs" />
|
||||
<option value="$PROJECT_DIR$/ConsoleApp/Maps/SquareMap.cs" />
|
||||
<option value="$PROJECT_DIR$/ConsoleApp/IPathPlanner.cs" />
|
||||
<option value="$PROJECT_DIR$/ConsoleApp/PathPlanner.cs" />
|
||||
<option value="$PROJECT_DIR$/ConsoleApp/PathPlanners/PathPlanner.cs" />
|
||||
<option value="$PROJECT_DIR$/ConsoleApp/PathPlanners/IPathPlanner.cs" />
|
||||
<option value="$PROJECT_DIR$/ConsoleApp/Maps/GlobalDirection.cs" />
|
||||
<option value="$PROJECT_DIR$/ConsoleApp/Maps/HexCoordinates.cs" />
|
||||
<option value="$PROJECT_DIR$/ConsoleApp/SimRunner.cs" />
|
||||
<option value="$PROJECT_DIR$/ConsoleApp/Maps/Cell.cs" />
|
||||
<option value="$PROJECT_DIR$/ConsoleApp/Maps/ICell.cs" />
|
||||
<option value="$PROJECT_DIR$/ConsoleApp/Maps/IMap.cs" />
|
||||
<option value="$PROJECT_DIR$/ConsoleApp/Maps/SquareMap.cs" />
|
||||
<option value="$PROJECT_DIR$/ConsoleApp/Maps/HexMap.cs" />
|
||||
</changedPaths>
|
||||
</component>
|
||||
<component name="ProjectId" id="1lIZ7IfsUjzqV2Jb1obOFvGFAfp" />
|
||||
@@ -147,7 +157,7 @@
|
||||
<workItem from="1607982179018" duration="634000" />
|
||||
<workItem from="1607983288378" duration="86000" />
|
||||
<workItem from="1607983862958" duration="7777000" />
|
||||
<workItem from="1607993290571" duration="1876000" />
|
||||
<workItem from="1607993290571" duration="14428000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
@@ -175,44 +185,31 @@
|
||||
<breakpoint-manager>
|
||||
<breakpoints>
|
||||
<line-breakpoint enabled="true" type="DotNet Breakpoints">
|
||||
<url>file://$PROJECT_DIR$/ConsoleApp/SimRunner.cs</url>
|
||||
<line>49</line>
|
||||
<properties documentPath="$PROJECT_DIR$/ConsoleApp/SimRunner.cs" initialLine="49" containingFunctionPresentation="method 'SquareSimulation'">
|
||||
<startOffsets>
|
||||
<option value="1400" />
|
||||
</startOffsets>
|
||||
<endOffsets>
|
||||
<option value="1427" />
|
||||
</endOffsets>
|
||||
</properties>
|
||||
<option name="timeStamp" value="5" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DotNet Breakpoints">
|
||||
<url>file://$PROJECT_DIR$/ConsoleApp/SimRunner.cs</url>
|
||||
<line>47</line>
|
||||
<properties documentPath="$PROJECT_DIR$/ConsoleApp/SimRunner.cs" initialLine="47" containingFunctionPresentation="method 'SquareSimulation'">
|
||||
<startOffsets>
|
||||
<option value="1340" />
|
||||
</startOffsets>
|
||||
<endOffsets>
|
||||
<option value="1369" />
|
||||
</endOffsets>
|
||||
</properties>
|
||||
<option name="timeStamp" value="19" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DotNet Breakpoints">
|
||||
<url>file://$PROJECT_DIR$/ConsoleApp/PathPlanner.cs</url>
|
||||
<url>file://$PROJECT_DIR$/ConsoleApp/PathPlanners/PathPlanner.cs</url>
|
||||
<line>34</line>
|
||||
<properties documentPath="$PROJECT_DIR$/ConsoleApp/PathPlanner.cs" initialLine="34" containingFunctionPresentation="method 'GenerateOptimalSquarePath'">
|
||||
<startOffsets>
|
||||
<option value="1420" />
|
||||
<option value="1433" />
|
||||
</startOffsets>
|
||||
<endOffsets>
|
||||
<option value="1436" />
|
||||
<option value="1449" />
|
||||
</endOffsets>
|
||||
</properties>
|
||||
<option name="timeStamp" value="24" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DotNet Breakpoints">
|
||||
<url>file://$PROJECT_DIR$/ConsoleApp/Maps/HexMap.cs</url>
|
||||
<line>62</line>
|
||||
<properties documentPath="$PROJECT_DIR$/ConsoleApp/Maps/HexMap.cs" initialLine="63" containingFunctionPresentation="constructor 'HexMap'">
|
||||
<startOffsets>
|
||||
<option value="2218" />
|
||||
</startOffsets>
|
||||
<endOffsets>
|
||||
<option value="2219" />
|
||||
</endOffsets>
|
||||
</properties>
|
||||
<option name="timeStamp" value="33" />
|
||||
</line-breakpoint>
|
||||
</breakpoints>
|
||||
</breakpoint-manager>
|
||||
</component>
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DryIoc.dll" Version="4.5.2" />
|
||||
<PackageReference Include="HexCore" Version="4.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using ConsoleApp.Maps;
|
||||
using ConsoleApp.PathPlanners;
|
||||
using DryIoc;
|
||||
|
||||
namespace ConsoleApp
|
||||
|
||||
@@ -6,18 +6,14 @@ namespace ConsoleApp.Maps
|
||||
{
|
||||
public int X { get; }
|
||||
public int Y { get; }
|
||||
public int Z { get; }
|
||||
|
||||
public Cell(int x, int y, int z = default)
|
||||
{
|
||||
if (z != default)
|
||||
{
|
||||
if (x + y + z != 0) throw new ArgumentException("x + y + z must be 0");
|
||||
}
|
||||
|
||||
public Cell(int x, int y)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
Z = z;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,10 @@ namespace ConsoleApp.Maps
|
||||
North,
|
||||
South,
|
||||
East,
|
||||
West
|
||||
West,
|
||||
NorthEast,
|
||||
SouthEast,
|
||||
NorthWest,
|
||||
SouthWest
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using HexCore;
|
||||
|
||||
namespace ConsoleApp.Maps
|
||||
{
|
||||
public class HexMap : IHexMap
|
||||
{
|
||||
private int _mapHeight;
|
||||
private int _mapWidth;
|
||||
public Cell[,] Map { get; }
|
||||
public Cell StartingCell { get; }
|
||||
public Cell LastCell { get; }
|
||||
public Graph HexGraph { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Generate Hex map with cells of 25cm X 25cm
|
||||
@@ -19,27 +23,60 @@ namespace ConsoleApp.Maps
|
||||
//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);
|
||||
|
||||
_mapHeight = yCellCount;
|
||||
_mapWidth = xCellCount;
|
||||
|
||||
//Initialize Map
|
||||
Map = new Cell[xCellCount, yCellCount];
|
||||
|
||||
//set last cell;
|
||||
//set Starting cell;
|
||||
StartingCell = Map[0, 0];
|
||||
for (int r = 0; r < yCellCount; r++) {
|
||||
int r_offset = Convert.ToInt32(Math.Floor(Convert.ToDouble(r)/2));
|
||||
for (int q = r_offset; q < xCellCount - r_offset; q++) {
|
||||
// Console.WriteLine($"r:{r}, q:{q}-----x:{x}, y:{y}");
|
||||
Map[r, q] = new Cell(q, r, -q-r);
|
||||
|
||||
var unclearedTerrain = new TerrainType(1, "uncleared");
|
||||
var clearedTerrain = new TerrainType(2, "cleared");
|
||||
//Populate Map
|
||||
var list = new List<CellState>();
|
||||
for (int i = 0; i < _mapHeight; i++)
|
||||
{
|
||||
for (int j = 0; j < _mapWidth; j++)
|
||||
{
|
||||
list.Add(new CellState(false, new Coordinate2D(i, j, OffsetTypes.OddRowsRight), unclearedTerrain));
|
||||
}
|
||||
}
|
||||
var movement = new MovementType(1, "default");
|
||||
var movementTypes = new MovementTypes(
|
||||
new ITerrainType[] { unclearedTerrain, clearedTerrain },
|
||||
new Dictionary<IMovementType, Dictionary<ITerrainType, int>>
|
||||
{
|
||||
[movement] = new Dictionary<ITerrainType, int>
|
||||
{
|
||||
[unclearedTerrain] = 1,
|
||||
[clearedTerrain] = 2
|
||||
}
|
||||
}
|
||||
);
|
||||
HexGraph = GraphFactory.CreateRectangularGraph(_mapWidth, _mapHeight, movementTypes, unclearedTerrain);
|
||||
}
|
||||
|
||||
public List<GlobalDirection> PossibleMoves(ICell currentCell)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var x = currentCell.X;
|
||||
var y = currentCell.Y;
|
||||
var possibles = new List<GlobalDirection>();
|
||||
|
||||
if(currentCell.Y != _mapHeight)
|
||||
possibles.Add(GlobalDirection.North);
|
||||
|
||||
if(currentCell.Y != 0)
|
||||
possibles.Add(GlobalDirection.South);
|
||||
|
||||
if(currentCell.X != _mapWidth && currentCell.Y != _mapHeight)
|
||||
possibles.Add(GlobalDirection.NorthEast);
|
||||
return possibles;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,5 @@ namespace ConsoleApp.Maps
|
||||
{
|
||||
int X { get; }
|
||||
int Y { get; }
|
||||
int Z { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using HexCore;
|
||||
|
||||
namespace ConsoleApp.Maps
|
||||
{
|
||||
@@ -9,5 +10,7 @@ namespace ConsoleApp.Maps
|
||||
Cell StartingCell { get; }
|
||||
Cell LastCell { get; }
|
||||
public List<GlobalDirection> PossibleMoves(ICell currentCell);
|
||||
|
||||
Graph HexGraph { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using HexCore;
|
||||
|
||||
namespace ConsoleApp.Maps
|
||||
{
|
||||
@@ -16,6 +17,7 @@ namespace ConsoleApp.Maps
|
||||
private int _mapHeight;
|
||||
public SquareMap(int x, int y)
|
||||
{
|
||||
HexGraph = default;
|
||||
//convert to cm
|
||||
x *= 100;
|
||||
y *= 100;
|
||||
@@ -23,7 +25,7 @@ namespace ConsoleApp.Maps
|
||||
var xCellCount = (int)Math.Ceiling((decimal) (x) / 25);
|
||||
var yCellCount = (int)Math.Ceiling((decimal) (y) / 25);
|
||||
|
||||
//set Width and height fields
|
||||
//set Width and height fields and Properties
|
||||
_mapWidth = xCellCount-1;
|
||||
_mapHeight = yCellCount-1;
|
||||
Height = _mapHeight;
|
||||
@@ -60,6 +62,8 @@ namespace ConsoleApp.Maps
|
||||
return possibles;
|
||||
}
|
||||
|
||||
public Graph HexGraph { get; }
|
||||
|
||||
public Cell this[in int x, in int y] => Map[x, y];
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using ConsoleApp.Maps;
|
||||
|
||||
namespace ConsoleApp
|
||||
namespace ConsoleApp.PathPlanners
|
||||
{
|
||||
public interface IPathPlanner
|
||||
{
|
||||
Queue<ICell> GenerateOptimalSquarePath(SquareMap map, IVehicle vehicle);
|
||||
Queue<ICell> GenerateOptimalHexPath(HexMap hexMap, IVehicle vehicle);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using ConsoleApp.Maps;
|
||||
|
||||
namespace ConsoleApp
|
||||
namespace ConsoleApp.PathPlanners
|
||||
{
|
||||
public class PathPlanner : IPathPlanner
|
||||
{
|
||||
@@ -52,5 +52,10 @@ namespace ConsoleApp
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
public Queue<ICell> GenerateOptimalHexPath(HexMap hexMap, IVehicle vehicle)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using ConsoleApp.Maps;
|
||||
using ConsoleApp.PathPlanners;
|
||||
|
||||
namespace ConsoleApp
|
||||
{
|
||||
@@ -27,8 +28,8 @@ namespace ConsoleApp
|
||||
public void Run()
|
||||
{
|
||||
|
||||
SquareSimulation();
|
||||
// var hexTask = Task.Run(() => HexSimulation());
|
||||
//SquareSimulation();
|
||||
HexSimulation();
|
||||
// while(!squareTask.IsCompleted && !hexTask.IsCompleted){Thread.Sleep(500);}
|
||||
|
||||
}
|
||||
@@ -37,6 +38,7 @@ namespace ConsoleApp
|
||||
{
|
||||
var hexMap = (HexMap)_mapFactory.Maps["HexMap"];
|
||||
_vehicle.CurrentHexCell = hexMap.StartingCell;
|
||||
var optimalPath = _pathPlanner.GenerateOptimalHexPath(hexMap, _vehicle);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user