diff --git a/.idea/.idea.RobotIntelFinal/.idea/contentModel.xml b/.idea/.idea.RobotIntelFinal/.idea/contentModel.xml
index 64afb13..5a947e0 100644
--- a/.idea/.idea.RobotIntelFinal/.idea/contentModel.xml
+++ b/.idea/.idea.RobotIntelFinal/.idea/contentModel.xml
@@ -14,23 +14,20 @@
+
-
-
-
-
-
+
@@ -46,7 +43,7 @@
-
-
+
+
\ No newline at end of file
diff --git a/.idea/.idea.RobotIntelFinal/.idea/modules.xml b/.idea/.idea.RobotIntelFinal/.idea/modules.xml
index d3cdc38..3bdf19a 100644
--- a/.idea/.idea.RobotIntelFinal/.idea/modules.xml
+++ b/.idea/.idea.RobotIntelFinal/.idea/modules.xml
@@ -2,7 +2,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/.idea.RobotIntelFinal/.idea/workspace.xml b/.idea/.idea.RobotIntelFinal/.idea/workspace.xml
index 976b0fd..054c27e 100644
--- a/.idea/.idea.RobotIntelFinal/.idea/workspace.xml
+++ b/.idea/.idea.RobotIntelFinal/.idea/workspace.xml
@@ -4,6 +4,9 @@
Simulator/Simulator.csproj
ConsoleApp/ConsoleApp.csproj
+
+
+
@@ -15,17 +18,24 @@
-
-
-
-
-
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -42,54 +52,13 @@
+
+
+
-
+
+
+
@@ -101,7 +70,7 @@
-
+
@@ -157,7 +126,10 @@
-
+
+
+
+
@@ -181,125 +153,4 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ConsoleApp/ConsoleApp.csproj b/ConsoleApp/ConsoleApp.csproj
index 46562ba..cb79c52 100644
--- a/ConsoleApp/ConsoleApp.csproj
+++ b/ConsoleApp/ConsoleApp.csproj
@@ -5,6 +5,14 @@
netcoreapp3.1
+
+ full
+
+
+
+ full
+
+
diff --git a/ConsoleApp/IVehicle.cs b/ConsoleApp/IVehicle.cs
index 0e26262..2f55f3c 100644
--- a/ConsoleApp/IVehicle.cs
+++ b/ConsoleApp/IVehicle.cs
@@ -1,9 +1,16 @@
+using ConsoleApp.Maps;
+
namespace ConsoleApp
{
public interface IVehicle
{
int Length { get; }
int Width { get; }
- int DetectorWidth { get; }
+ int DetectorOffset { get;}
+ int DetectorWidth { get;}
+ ICell CurrentHexCell { get; set; }
+ Heading HexHeading { get; set; }
+ Heading SquareHeading { get; set; }
+ ICell CurrentSquareCell { get; set; }
}
}
\ No newline at end of file
diff --git a/ConsoleApp/Maps/Cell.cs b/ConsoleApp/Maps/Cell.cs
new file mode 100644
index 0000000..1665631
--- /dev/null
+++ b/ConsoleApp/Maps/Cell.cs
@@ -0,0 +1,23 @@
+using System;
+
+namespace ConsoleApp.Maps
+{
+ public struct Cell : ICell
+ {
+ 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");
+ }
+
+ X = x;
+ Y = y;
+ Z = z;
+ }
+ }
+}
\ No newline at end of file
diff --git a/ConsoleApp/Maps/Heading.cs b/ConsoleApp/Maps/Heading.cs
index c46b5c5..df70d1c 100644
--- a/ConsoleApp/Maps/Heading.cs
+++ b/ConsoleApp/Maps/Heading.cs
@@ -1,35 +1,49 @@
+using System.Net.NetworkInformation;
+
namespace ConsoleApp.Maps
{
+ public class Oreientation
+ {
+ public static (int, int) Forward = (0, 1);
+ public static (int, int) Backward = (0, -1);
+ public static (int, int) Left = (-1, 0);
+ public static (int, int) Right = (1, 0);
+ public static (int, int) LeftBack = (-1, -1);
+ public static (int, int) LeftForward = (-1, 1);
+ public static (int, int) RightBack = (1, -1);
+ public static (int, int) RightForward = (1, 1);
+ }
public class Heading
{
private (int, int) _currentHeading;
public (int, int) CurrentHeading { get; }
+
public void SetHeading((int,int)frontAxel, (int,int)backAxel)
{
var x = frontAxel.Item1 - backAxel.Item1;
var y = frontAxel.Item2 - backAxel.Item2;
//forward
- if (x == 0 && y >= 1) _currentHeading = (0, 1);
+ if (x == 0 && y >= 1) _currentHeading = Oreientation.Forward;
//backward
- if (x == 0 && y <= -1) _currentHeading = (0, -1);
+ if (x == 0 && y <= -1) _currentHeading = Oreientation.Backward;
//right
- if (x >= 1 && y == 0) _currentHeading = (1, 0);
+ if (x >= 1 && y == 0) _currentHeading = Oreientation.Right;
//left
- if (x <= -1 && y == 0) _currentHeading = (-1, 0);
+ if (x <= -1 && y == 0) _currentHeading = Oreientation.Left;
//left, back
- if (x <= -1 && y <= -1) _currentHeading = (-1, -1);
+ if (x <= -1 && y <= -1) _currentHeading = Oreientation.LeftBack;
//right, forward
- if (x >= 1 && y >= 1) _currentHeading = (1, 1);
+ if (x >= 1 && y >= 1) _currentHeading = Oreientation.RightForward;
//left, forward
- if (x <= -1 && y >= 1) _currentHeading = (-1, 1);
+ if (x <= -1 && y >= 1) _currentHeading = Oreientation.LeftForward;
//right, back
- if (x >= 1 && y <= -1) _currentHeading = (1, -1);
+ if (x >= 1 && y <= -1) _currentHeading = Oreientation.RightBack;
}
public Heading()
{
- _currentHeading = (1,0);
+ _currentHeading = Oreientation.Forward;
CurrentHeading = _currentHeading;
}
diff --git a/ConsoleApp/Maps/HexCell.cs b/ConsoleApp/Maps/HexCell.cs
deleted file mode 100644
index d396ff0..0000000
--- a/ConsoleApp/Maps/HexCell.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-namespace ConsoleApp.Maps
-{
- public struct HexCell : IHexCell
- {
- public int X { get; }
- public int Y { get; }
- public int Z { get; }
- public HexCell(int q, int r, int s)
- {
- if (q + r + s != 0) throw new ArgumentException("q + r + s must be 0");
- X = q;
- Y = r;
- Z = s;
- }
-
- }
-}
\ No newline at end of file
diff --git a/ConsoleApp/Maps/HexMap.cs b/ConsoleApp/Maps/HexMap.cs
index 241f32c..a98f900 100644
--- a/ConsoleApp/Maps/HexMap.cs
+++ b/ConsoleApp/Maps/HexMap.cs
@@ -5,16 +5,32 @@ namespace ConsoleApp.Maps
{
public class HexMap : IHexMap
{
- private HexCell[,] Map { get; }
+ public Cell[,] Map { get; }
+ public ICell StartingCell { get; }
+ public ICell LastCell { get; }
+ ///
+ /// Generate Hex map with cells of 25cm X 25cm
+ ///
+ ///
+ ///
public HexMap(int x, int y)
{
- Map = new HexCell[x+1,y+1];
- for (int r = 0; r < y; r++) {
+ //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 last cell;
+ StartingCell = Map[0, 0];
+ Map = new Cell[xCellCount, yCellCount];
+ for (int r = 0; r < yCellCount; r++) {
int r_offset = Convert.ToInt32(Math.Floor(Convert.ToDouble(r)/2));
- for (int q = r_offset; q < x - r_offset; q++) {
+ for (int q = r_offset; q < xCellCount - r_offset; q++) {
// Console.WriteLine($"r:{r}, q:{q}-----x:{x}, y:{y}");
- Map[r, q] = new HexCell(q, r, -q-r);
+ Map[r, q] = new Cell(q, r, -q-r);
}
}
}
diff --git a/ConsoleApp/Maps/IHexCell.cs b/ConsoleApp/Maps/IHexCell.cs
deleted file mode 100644
index 29fd15e..0000000
--- a/ConsoleApp/Maps/IHexCell.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace ConsoleApp.Maps
-{
- public interface IHexCell : ICell
- {
-
- }
-}
\ No newline at end of file
diff --git a/ConsoleApp/Maps/IMap.cs b/ConsoleApp/Maps/IMap.cs
index e2010ed..d622bd4 100644
--- a/ConsoleApp/Maps/IMap.cs
+++ b/ConsoleApp/Maps/IMap.cs
@@ -1,9 +1,13 @@
using System.Collections.Generic;
+using System.ComponentModel;
namespace ConsoleApp.Maps
{
public interface IMap
{
+ public Cell[,] Map { get; }
+ ICell StartingCell { get; }
+ ICell LastCell { get; }
public List PossibleMoves(ICell currentCell);
}
}
\ No newline at end of file
diff --git a/ConsoleApp/Maps/IMapFactory.cs b/ConsoleApp/Maps/IMapFactory.cs
index 079298d..a4b8eae 100644
--- a/ConsoleApp/Maps/IMapFactory.cs
+++ b/ConsoleApp/Maps/IMapFactory.cs
@@ -7,6 +7,7 @@ namespace ConsoleApp.Maps
{
int Height { get; }
int Width { get; }
+ int CellWidth { get; }
Dictionary Maps { get; }
void GenerateMaps(int x, int y);
}
diff --git a/ConsoleApp/Maps/ISquareCell.cs b/ConsoleApp/Maps/ISquareCell.cs
deleted file mode 100644
index ae83d9e..0000000
--- a/ConsoleApp/Maps/ISquareCell.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace ConsoleApp.Maps
-{
- public interface ISquareCell : ICell
- {
- new int X { get; }
- new int Y { get; }
- }
-}
\ No newline at end of file
diff --git a/ConsoleApp/Maps/MapFactory.cs b/ConsoleApp/Maps/MapFactory.cs
index 0d55898..7e165b8 100644
--- a/ConsoleApp/Maps/MapFactory.cs
+++ b/ConsoleApp/Maps/MapFactory.cs
@@ -8,6 +8,7 @@ namespace ConsoleApp.Maps
private int _defaultWidth;
public int Height { get; protected set; }
public int Width { get; protected set; }
+ public int CellWidth { get; protected set; }
public Dictionary Maps { get; }
@@ -20,8 +21,9 @@ namespace ConsoleApp.Maps
Maps.Add("HexMap", new HexMap(x, y));
}
- public MapFactory()
+ public MapFactory(IVehicle vehicle)
{
+ CellWidth = vehicle.Width/2;
_defaultHeight = 0;
_defaultWidth = 0;
Height = _defaultHeight;
diff --git a/ConsoleApp/Maps/SquareCell.cs b/ConsoleApp/Maps/SquareCell.cs
deleted file mode 100644
index ae6fc38..0000000
--- a/ConsoleApp/Maps/SquareCell.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-namespace ConsoleApp.Maps
-{
- public struct SquareCell : ISquareCell
- {
- public int X { get; }
- public int Y { get; }
- public int Z { get; }
-
- public SquareCell(int x, int y)
- {
- X = x;
- Y = y;
- Z = default;
- }
- }
-}
\ No newline at end of file
diff --git a/ConsoleApp/Maps/SquareMap.cs b/ConsoleApp/Maps/SquareMap.cs
index 635a3ff..b408aba 100644
--- a/ConsoleApp/Maps/SquareMap.cs
+++ b/ConsoleApp/Maps/SquareMap.cs
@@ -5,16 +5,27 @@ namespace ConsoleApp.Maps
{
public class SquareMap : ISquareMap
{
- public SquareCell[,] Map { get;}
+ public Cell[,] Map { get;}
+ public ICell StartingCell { get; }
+ public ICell LastCell { get; }
public SquareMap(int x, int y)
{
- Map = new SquareCell[x,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 last cell;
+ StartingCell = Map[0, 0];
+ Map = new Cell[xCellCount, yCellCount];
for (int i = 0; i < x; i++)
{
for (int j = 0; j < y; j++)
{
- Map[i,j] = new SquareCell(i, j);
+ Map[i,j] = new Cell(i, j);
}
}
}
diff --git a/ConsoleApp/SimRunner.cs b/ConsoleApp/SimRunner.cs
index 04a2849..5dbb361 100644
--- a/ConsoleApp/SimRunner.cs
+++ b/ConsoleApp/SimRunner.cs
@@ -1,3 +1,7 @@
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
using ConsoleApp.Maps;
namespace ConsoleApp
@@ -5,15 +9,59 @@ namespace ConsoleApp
public class SimRunner : ISimRunner
{
private IMapFactory _mapFactory;
+ private IVehicle _vehicle;
+ private IMap _squareMap;
+ private IMap _hexMap;
+ private int _cellWidth;
+
public SimRunner(IMapFactory mapFactory, IVehicle vehicle)
{
+ _squareMap = mapFactory.Maps["SquareMap"];
+ _hexMap = mapFactory.Maps["HexMap"];
+ _cellWidth = mapFactory.CellWidth;
_mapFactory = mapFactory;
+ _vehicle = vehicle;
}
public void Run()
+ {
+ _vehicle.CurrentHexCell = _hexMap.StartingCell;
+ _vehicle.CurrentSquareCell = _squareMap.StartingCell;
+ var squareTask = Task.Run(() => SquareSimulation());
+ var hexTask = Task.Run(() => HexSimulation());
+ while(!squareTask.IsCompleted && !hexTask.IsCompleted){Thread.Sleep(500);}
+
+ }
+
+ private void HexSimulation()
{
+ var optimalPath = GenerateHexPath();
+ }
+
+
+ private void SquareSimulation()
+ {
+ var optimalPath = GenerateSquarePath();
+ }
+
+ private object GenerateSquarePath()
+ {
+ throw new NotImplementedException();
+ }
+
+ private Queue GenerateHexPath()
+ {
+ var path = new Queue();
+ var currentCell = _vehicle.CurrentHexCell;
+ var possibles = _hexMap.PossibleMoves(currentCell);
+ while (currentCell != _hexMap.LastCell)
+ {
+
+ }
+
+ return path;
}
}
}
\ No newline at end of file
diff --git a/ConsoleApp/Vehicle.cs b/ConsoleApp/Vehicle.cs
index b8c254a..d3e7f42 100644
--- a/ConsoleApp/Vehicle.cs
+++ b/ConsoleApp/Vehicle.cs
@@ -1,4 +1,5 @@
using System;
+using ConsoleApp.Maps;
namespace ConsoleApp
{
@@ -9,6 +10,12 @@ namespace ConsoleApp
public int DetectorOffset { get;}
public int DetectorWidth { get;}
+ public ICell CurrentHexCell { get; set; }
+ public Heading HexHeading { get; set; }
+ public Heading SquareHeading { get; set; }
+ public ICell CurrentSquareCell { get; set; }
+
+
public Vehicle(IJsonDeserializor jsonDeserializor)
{
@@ -17,8 +24,10 @@ namespace ConsoleApp
Width = config.Width;
DetectorWidth = config.DetectorWidth;
DetectorOffset = config.DetectorOffset;
+ CurrentHexCell = default;
+ CurrentSquareCell = default;
+ HexHeading = default;
+ SquareHeading = default;
}
-
-
}
}
\ No newline at end of file
diff --git a/RobotIntelFinal.sln.DotSettings.user b/RobotIntelFinal.sln.DotSettings.user
index fb23c2a..1123785 100644
--- a/RobotIntelFinal.sln.DotSettings.user
+++ b/RobotIntelFinal.sln.DotSettings.user
@@ -1,3 +1,4 @@
- 1048576
+ /Users/brady.bodily/.dotnet/dotnet
+
/Users/brady.bodily/.dotnet/sdk/3.1.402/MSBuild.dll
\ No newline at end of file