diff --git a/.idea/.idea.RobotIntelFinal/.idea/contentModel.xml b/.idea/.idea.RobotIntelFinal/.idea/contentModel.xml
index e2c567b..d36be7c 100644
--- a/.idea/.idea.RobotIntelFinal/.idea/contentModel.xml
+++ b/.idea/.idea.RobotIntelFinal/.idea/contentModel.xml
@@ -20,7 +20,6 @@
-
diff --git a/.idea/.idea.RobotIntelFinal/.idea/workspace.xml b/.idea/.idea.RobotIntelFinal/.idea/workspace.xml
index ba7d1e4..e89dcd6 100644
--- a/.idea/.idea.RobotIntelFinal/.idea/workspace.xml
+++ b/.idea/.idea.RobotIntelFinal/.idea/workspace.xml
@@ -18,19 +18,19 @@
-
-
-
-
-
-
+
-
-
+
+
+
+
+
-
+
+
+
@@ -70,16 +70,22 @@
-
-
-
+
+
+
+
+
+
+
+
+
@@ -157,7 +163,7 @@
-
+
@@ -189,27 +195,14 @@
34
-
+
-
+
-
- file://$PROJECT_DIR$/ConsoleApp/Maps/HexMap.cs
- 62
-
-
-
-
-
-
-
-
-
-
diff --git a/ConsoleApp/IVehicle.cs b/ConsoleApp/IVehicle.cs
index 2f55f3c..4d47053 100644
--- a/ConsoleApp/IVehicle.cs
+++ b/ConsoleApp/IVehicle.cs
@@ -8,7 +8,7 @@ namespace ConsoleApp
int Width { get; }
int DetectorOffset { get;}
int DetectorWidth { get;}
- ICell CurrentHexCell { get; set; }
+ HexCore.Coordinate2D CurrentHexCell { get; set; }
Heading HexHeading { get; set; }
Heading SquareHeading { get; set; }
ICell CurrentSquareCell { get; set; }
diff --git a/ConsoleApp/Maps/HexMap.cs b/ConsoleApp/Maps/HexMap.cs
index 625c3d9..39b2311 100644
--- a/ConsoleApp/Maps/HexMap.cs
+++ b/ConsoleApp/Maps/HexMap.cs
@@ -6,12 +6,12 @@ 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; }
+
+ public int Width { get; }
+
+ public int Height { get; }
+
+ public Graph Graph { get; }
///
/// Generate Hex map with cells of 25cm X 25cm
@@ -28,25 +28,12 @@ namespace ConsoleApp.Maps
var xCellCount = (int)Math.Ceiling((decimal) (x) / 25);
var yCellCount = (int)Math.Ceiling((decimal) (y) / 25);
- _mapHeight = yCellCount;
- _mapWidth = xCellCount;
+ Height = yCellCount;
+ Width = xCellCount;
- //Initialize Map
- Map = new Cell[xCellCount, yCellCount];
- //set Starting cell;
- StartingCell = Map[0, 0];
-
var unclearedTerrain = new TerrainType(1, "uncleared");
var clearedTerrain = new TerrainType(2, "cleared");
- //Populate Map
- var list = new List();
- 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 },
@@ -59,24 +46,8 @@ namespace ConsoleApp.Maps
}
}
);
- HexGraph = GraphFactory.CreateRectangularGraph(_mapWidth, _mapHeight, movementTypes, unclearedTerrain);
+ Graph = GraphFactory.CreateRectangularGraph(Width, Height, movementTypes, unclearedTerrain);
}
- public List PossibleMoves(ICell currentCell)
- {
- var x = currentCell.X;
- var y = currentCell.Y;
- var possibles = new List();
-
- 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;
- }
}
}
\ No newline at end of file
diff --git a/ConsoleApp/Maps/IHexMap.cs b/ConsoleApp/Maps/IHexMap.cs
index b4cd82f..f535182 100644
--- a/ConsoleApp/Maps/IHexMap.cs
+++ b/ConsoleApp/Maps/IHexMap.cs
@@ -1,7 +1,9 @@
+using HexCore;
+
namespace ConsoleApp.Maps
{
- public interface IHexMap : IMap
+ public interface IHexMap
{
-
+ Graph Graph { get; }
}
}
\ No newline at end of file
diff --git a/ConsoleApp/Maps/IMap.cs b/ConsoleApp/Maps/IMap.cs
deleted file mode 100644
index 5be44cf..0000000
--- a/ConsoleApp/Maps/IMap.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using System.Collections.Generic;
-using System.ComponentModel;
-using HexCore;
-
-namespace ConsoleApp.Maps
-{
- public interface IMap
- {
- public Cell[,] Map { get; }
- Cell StartingCell { get; }
- Cell LastCell { get; }
- public List PossibleMoves(ICell currentCell);
-
- Graph HexGraph { get; }
- }
-}
\ No newline at end of file
diff --git a/ConsoleApp/Maps/IMapFactory.cs b/ConsoleApp/Maps/IMapFactory.cs
index a4b8eae..ec72df4 100644
--- a/ConsoleApp/Maps/IMapFactory.cs
+++ b/ConsoleApp/Maps/IMapFactory.cs
@@ -8,7 +8,8 @@ namespace ConsoleApp.Maps
int Height { get; }
int Width { get; }
int CellWidth { get; }
- Dictionary Maps { get; }
void GenerateMaps(int x, int y);
+ IHexMap GetHexMap();
+ ISquareMap GetSquareMap();
}
}
\ No newline at end of file
diff --git a/ConsoleApp/Maps/ISquareMap.cs b/ConsoleApp/Maps/ISquareMap.cs
index ccdd19a..7c5bf05 100644
--- a/ConsoleApp/Maps/ISquareMap.cs
+++ b/ConsoleApp/Maps/ISquareMap.cs
@@ -1,7 +1,16 @@
+using System.Collections.Generic;
+using HexCore;
+
namespace ConsoleApp.Maps
{
- public interface ISquareMap : IMap
+ public interface ISquareMap
{
-
+ Cell[,] Map { get; }
+ Cell StartingCell { get; }
+ Cell LastCell { get; }
+ List PossibleMoves(ICell currentCell);
+ Cell GetCell(int x, int y);
+ int Height { get; }
+ int Width { get; }
}
}
\ No newline at end of file
diff --git a/ConsoleApp/Maps/MapFactory.cs b/ConsoleApp/Maps/MapFactory.cs
index 7e165b8..383e613 100644
--- a/ConsoleApp/Maps/MapFactory.cs
+++ b/ConsoleApp/Maps/MapFactory.cs
@@ -1,3 +1,4 @@
+using System;
using System.Collections.Generic;
namespace ConsoleApp.Maps
@@ -8,18 +9,23 @@ 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 int CellWidth { get; }
+
- public Dictionary Maps { get; }
+
+ private ISquareMap _squareMap;
+ private IHexMap _hexMap;
public void GenerateMaps(int x, int y)
{
Width = x;
Height = y;
- Maps.Add("SquareMap",new SquareMap(x, y));
- Maps.Add("HexMap", new HexMap(x, y));
+ _squareMap = new SquareMap(x, y);
+ _hexMap = new HexMap(x, y);
}
+ public IHexMap GetHexMap() => _hexMap ?? throw new NullReferenceException("hex map not initialized");
+ public ISquareMap GetSquareMap() => _squareMap ?? throw new NullReferenceException("square map not initialized");
public MapFactory(IVehicle vehicle)
{
@@ -28,7 +34,8 @@ namespace ConsoleApp.Maps
_defaultWidth = 0;
Height = _defaultHeight;
Width = _defaultWidth;
- Maps = new Dictionary();
+ _hexMap = default;
+ _squareMap = default;
}
}
diff --git a/ConsoleApp/Maps/SquareMap.cs b/ConsoleApp/Maps/SquareMap.cs
index 9a3174b..287a70d 100644
--- a/ConsoleApp/Maps/SquareMap.cs
+++ b/ConsoleApp/Maps/SquareMap.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using HexCore;
+using ImTools;
namespace ConsoleApp.Maps
{
@@ -12,9 +13,11 @@ namespace ConsoleApp.Maps
public int Height { get; }
public int Width { get; }
-
- private int _mapWidth;
- private int _mapHeight;
+ ///
+ /// Returns a map with square cells
+ ///
+ ///
+ ///
public SquareMap(int x, int y)
{
HexGraph = default;
@@ -25,11 +28,10 @@ namespace ConsoleApp.Maps
var xCellCount = (int)Math.Ceiling((decimal) (x) / 25);
var yCellCount = (int)Math.Ceiling((decimal) (y) / 25);
- //set Width and height fields and Properties
- _mapWidth = xCellCount-1;
- _mapHeight = yCellCount-1;
- Height = _mapHeight;
- Width = _mapWidth;
+ //set Width and height Properties
+ Width = xCellCount-1;
+ Height = yCellCount-1;
+
//Initialize Map
Map = new Cell[xCellCount, yCellCount];
@@ -52,18 +54,19 @@ namespace ConsoleApp.Maps
var possibles = new List();
if (currentCell.X != 0)
possibles.Add(GlobalDirection.West);
- if (currentCell.X != _mapWidth)
+ if (currentCell.X != Width)
possibles.Add(GlobalDirection.East);
- if (currentCell.Y != _mapHeight)
+ if (currentCell.Y != Height)
possibles.Add(GlobalDirection.North);
if (currentCell.Y != 0)
possibles.Add(GlobalDirection.South);
return possibles;
}
-
+
public Graph HexGraph { get; }
- public Cell this[in int x, in int y] => Map[x, y];
+ public Cell GetCell(int x, int y) => Map[x, y];
+
}
}
\ No newline at end of file
diff --git a/ConsoleApp/PathPlanners/IPathPlanner.cs b/ConsoleApp/PathPlanners/IPathPlanner.cs
index 16688bf..a48b27d 100644
--- a/ConsoleApp/PathPlanners/IPathPlanner.cs
+++ b/ConsoleApp/PathPlanners/IPathPlanner.cs
@@ -5,7 +5,7 @@ namespace ConsoleApp.PathPlanners
{
public interface IPathPlanner
{
- Queue GenerateOptimalSquarePath(SquareMap map, IVehicle vehicle);
+ Queue GenerateOptimalSquarePath(ISquareMap map, IVehicle vehicle);
Queue GenerateOptimalHexPath(HexMap hexMap, IVehicle vehicle);
}
diff --git a/ConsoleApp/PathPlanners/PathPlanner.cs b/ConsoleApp/PathPlanners/PathPlanner.cs
index 5be9589..52f005d 100644
--- a/ConsoleApp/PathPlanners/PathPlanner.cs
+++ b/ConsoleApp/PathPlanners/PathPlanner.cs
@@ -6,7 +6,7 @@ namespace ConsoleApp.PathPlanners
{
public class PathPlanner : IPathPlanner
{
- public Queue GenerateOptimalSquarePath(SquareMap map, IVehicle vehicle)
+ public Queue GenerateOptimalSquarePath(ISquareMap map, IVehicle vehicle)
{
var path = new Queue();
var myCell = map.StartingCell;
@@ -20,13 +20,13 @@ namespace ConsoleApp.PathPlanners
if (availableMoves.Contains(GlobalDirection.North) && currentHeading == GlobalDirection.North &&
myCell.Y != map.Height)
{
- path.Enqueue(map[myCell.X, myCell.Y + 1]);
- myCell = map[myCell.X, myCell.Y + 1];
+ path.Enqueue(map.GetCell(myCell.X, myCell.Y + 1));
+ myCell = map.GetCell(myCell.X, myCell.Y + 1);
}
else if (availableMoves.Contains(GlobalDirection.South) && currentHeading == GlobalDirection.South && myCell.Y != 0)
{
- path.Enqueue(map[myCell.X, myCell.Y - 1]);
- myCell = map[myCell.X, myCell.Y - 1];
+ path.Enqueue(map.GetCell(myCell.X, myCell.Y - 1));
+ myCell = map.GetCell(myCell.X, myCell.Y - 1);
}
else
{
@@ -38,9 +38,9 @@ namespace ConsoleApp.PathPlanners
{
for (int i = myCell.X; i < myCell.X + swathOffset; i++)
{
- path.Enqueue(map[i, myCell.Y]);
+ path.Enqueue(map.GetCell(i, myCell.Y));
}
- myCell = map[myCell.X+swathOffset, myCell.Y];
+ myCell = map.GetCell(myCell.X+swathOffset, myCell.Y);
if (currentHeading == GlobalDirection.North)
currentHeading = GlobalDirection.South;
else if (currentHeading == GlobalDirection.South)
@@ -52,7 +52,7 @@ namespace ConsoleApp.PathPlanners
return path;
}
-
+
public Queue GenerateOptimalHexPath(HexMap hexMap, IVehicle vehicle)
{
throw new NotImplementedException();
diff --git a/ConsoleApp/Program.cs b/ConsoleApp/Program.cs
index 247c69f..ca6d342 100644
--- a/ConsoleApp/Program.cs
+++ b/ConsoleApp/Program.cs
@@ -13,6 +13,7 @@ namespace ConsoleApp
_bootstrapper = BootStrapper.BootstrapSystem(new CoreModule());
_userConsole = new UserConsole();
Initialization();
+ Console.WriteLine("Program Completed");
}
private static void Initialization()
diff --git a/ConsoleApp/SimRunner.cs b/ConsoleApp/SimRunner.cs
index ac695bc..efd89da 100644
--- a/ConsoleApp/SimRunner.cs
+++ b/ConsoleApp/SimRunner.cs
@@ -4,6 +4,7 @@ using System.Threading;
using System.Threading.Tasks;
using ConsoleApp.Maps;
using ConsoleApp.PathPlanners;
+using HexCore;
namespace ConsoleApp
{
@@ -28,7 +29,7 @@ namespace ConsoleApp
public void Run()
{
- //SquareSimulation();
+ SquareSimulation();
HexSimulation();
// while(!squareTask.IsCompleted && !hexTask.IsCompleted){Thread.Sleep(500);}
@@ -36,15 +37,15 @@ namespace ConsoleApp
private void HexSimulation()
{
- var hexMap = (HexMap)_mapFactory.Maps["HexMap"];
- _vehicle.CurrentHexCell = hexMap.StartingCell;
- var optimalPath = _pathPlanner.GenerateOptimalHexPath(hexMap, _vehicle);
+ var hexMap = _mapFactory.GetHexMap();
+ _vehicle.CurrentHexCell = new Coordinate2D(0, 0, OffsetTypes.OddRowsRight);
+ //var optimalPath = _pathPlanner.GenerateOptimalHexPath(hexMap, _vehicle);
}
private void SquareSimulation()
{
- var squareMap = (SquareMap)_mapFactory.Maps["SquareMap"];
+ var squareMap = _mapFactory.GetSquareMap();
_vehicle.CurrentSquareCell = squareMap.StartingCell;
var optimalPath = _pathPlanner.GenerateOptimalSquarePath(squareMap, _vehicle);
}
diff --git a/ConsoleApp/UserConsole.cs b/ConsoleApp/UserConsole.cs
index 33f2d23..b76ee46 100644
--- a/ConsoleApp/UserConsole.cs
+++ b/ConsoleApp/UserConsole.cs
@@ -7,8 +7,6 @@ namespace ConsoleApp
{
public class UserConsole : IUserConsole
{
- private IMapFactory _mapFactory;
-
public UserConsole()
{
}
diff --git a/ConsoleApp/Vehicle.cs b/ConsoleApp/Vehicle.cs
index d3e7f42..78b6503 100644
--- a/ConsoleApp/Vehicle.cs
+++ b/ConsoleApp/Vehicle.cs
@@ -10,7 +10,7 @@ namespace ConsoleApp
public int DetectorOffset { get;}
public int DetectorWidth { get;}
- public ICell CurrentHexCell { get; set; }
+ public HexCore.Coordinate2D CurrentHexCell { get; set; }
public Heading HexHeading { get; set; }
public Heading SquareHeading { get; set; }
public ICell CurrentSquareCell { get; set; }