finished
This commit is contained in:
BIN
BattleFieldSimulator.zip
Normal file
BIN
BattleFieldSimulator.zip
Normal file
Binary file not shown.
@@ -52,8 +52,13 @@
|
|||||||
<Compile Include="BattlefieldEnvironment\IEnvironmentSetup.cs" />
|
<Compile Include="BattlefieldEnvironment\IEnvironmentSetup.cs" />
|
||||||
<Compile Include="BattlefieldEnvironment\Map\IMap.cs" />
|
<Compile Include="BattlefieldEnvironment\Map\IMap.cs" />
|
||||||
<Compile Include="BattlefieldEnvironment\Map\IMapLoader.cs" />
|
<Compile Include="BattlefieldEnvironment\Map\IMapLoader.cs" />
|
||||||
|
<Compile Include="BattlefieldEnvironment\Map\IMapPrinter.cs" />
|
||||||
|
<Compile Include="BattlefieldEnvironment\Map\IPathGenerator.cs" />
|
||||||
<Compile Include="BattlefieldEnvironment\Map\Map.cs" />
|
<Compile Include="BattlefieldEnvironment\Map\Map.cs" />
|
||||||
<Compile Include="BattlefieldEnvironment\Map\MapLoader.cs" />
|
<Compile Include="BattlefieldEnvironment\Map\MapLoader.cs" />
|
||||||
|
<Compile Include="BattlefieldEnvironment\Map\MapPath.cs" />
|
||||||
|
<Compile Include="BattlefieldEnvironment\Map\MapPrinter.cs" />
|
||||||
|
<Compile Include="BattlefieldEnvironment\Map\PathGenerator.cs" />
|
||||||
<Compile Include="BattlefieldEnvironment\Map\Point.cs" />
|
<Compile Include="BattlefieldEnvironment\Map\Point.cs" />
|
||||||
<Compile Include="BattlefieldEnvironment\Troops\EffectivenessRatios.cs" />
|
<Compile Include="BattlefieldEnvironment\Troops\EffectivenessRatios.cs" />
|
||||||
<Compile Include="BattlefieldEnvironment\Troops\ITroop.cs" />
|
<Compile Include="BattlefieldEnvironment\Troops\ITroop.cs" />
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using BattleFieldSimulator.FileSystem;
|
||||||
|
|
||||||
namespace BattleFieldSimulator.BattlefieldEnvironment
|
namespace BattleFieldSimulator.BattlefieldEnvironment
|
||||||
{
|
{
|
||||||
@@ -7,12 +9,15 @@ namespace BattleFieldSimulator.BattlefieldEnvironment
|
|||||||
public IMap Map { get; }
|
public IMap Map { get; }
|
||||||
public List<Troop> Allies { get; }
|
public List<Troop> Allies { get; }
|
||||||
public List<Troop> Adversaries { get; }
|
public List<Troop> Adversaries { get; }
|
||||||
public Environment(IMap map, List<Troop> allies, List<Troop> adversaries)
|
public StreamWriter OutFile { get; }
|
||||||
|
|
||||||
|
public Environment(IMap map, List<Troop> allies, List<Troop> adversaries, string outFile)
|
||||||
{
|
{
|
||||||
Map = map;
|
Map = map;
|
||||||
Allies = allies;
|
Allies = allies;
|
||||||
Adversaries = adversaries;
|
Adversaries = adversaries;
|
||||||
|
OutFile = new StreamWriter(Path.Combine(FileSystemConstants.ExecutionDirectory, outFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,9 +6,9 @@ namespace BattleFieldSimulator.BattlefieldEnvironment
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
public Environment CreateEnvironment(IMap map, List<Troop> allies, List<Troop> adversaries)
|
public Environment CreateEnvironment(IMap map, List<Troop> allies, List<Troop> adversaries, string outFile)
|
||||||
{
|
{
|
||||||
return new Environment(map, allies, adversaries);
|
return new Environment(map, allies, adversaries, outFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,12 +13,12 @@ namespace BattleFieldSimulator.BattlefieldEnvironment
|
|||||||
_troopLoader = troopLoader;
|
_troopLoader = troopLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Environment Setup(string mapName, string troopFile)
|
public Environment Setup(string mapName, string troopFile, string outFile)
|
||||||
{
|
{
|
||||||
var map = _mapLoader.LoadMap(mapName);
|
var map = _mapLoader.LoadMap(mapName);
|
||||||
var allies = _troopLoader.LoadAllies(troopFile);
|
var allies = _troopLoader.LoadAllies(troopFile);
|
||||||
var adversaries = _troopLoader.LoadAdversaries(troopFile);
|
var adversaries = _troopLoader.LoadAdversaries(troopFile);
|
||||||
var env = _environmentFactory.CreateEnvironment(map, allies, adversaries);
|
var env = _environmentFactory.CreateEnvironment(map, allies, adversaries, outFile);
|
||||||
return env;
|
return env;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace BattleFieldSimulator.BattlefieldEnvironment
|
namespace BattleFieldSimulator.BattlefieldEnvironment
|
||||||
{
|
{
|
||||||
@@ -8,5 +9,7 @@ namespace BattleFieldSimulator.BattlefieldEnvironment
|
|||||||
IMap Map { get; }
|
IMap Map { get; }
|
||||||
List<Troop> Allies { get; }
|
List<Troop> Allies { get; }
|
||||||
List<Troop> Adversaries { get; }
|
List<Troop> Adversaries { get; }
|
||||||
|
StreamWriter OutFile { get; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,6 @@ namespace BattleFieldSimulator.BattlefieldEnvironment
|
|||||||
{
|
{
|
||||||
public interface IEnvironmentFactory
|
public interface IEnvironmentFactory
|
||||||
{
|
{
|
||||||
Environment CreateEnvironment(IMap map, List<Troop> allies, List<Troop> adversaries);
|
Environment CreateEnvironment(IMap map, List<Troop> allies, List<Troop> adversaries, string outFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,6 @@ namespace BattleFieldSimulator.BattlefieldEnvironment
|
|||||||
{
|
{
|
||||||
public interface IEnvironmentSetup
|
public interface IEnvironmentSetup
|
||||||
{
|
{
|
||||||
Environment Setup(string mapName, string troopFile);
|
Environment Setup(string mapName, string troopFile, string outFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace BattleFieldSimulator.BattlefieldEnvironment
|
||||||
|
{
|
||||||
|
public interface IMapPrinter
|
||||||
|
{
|
||||||
|
void PrintMap(IMap map, List<Troop> allies, List<Troop> adversaries, StreamWriter environmentOutFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace BattleFieldSimulator.BattlefieldEnvironment
|
||||||
|
{
|
||||||
|
public interface IPathGenerator
|
||||||
|
{
|
||||||
|
List<MapPath> GeneratePaths(Point position, Point destination, IMap map);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,5 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using BattleFieldSimulator.Exceptions;
|
using BattleFieldSimulator.Exceptions;
|
||||||
using BattleFieldSimulator.JsonSerialization;
|
|
||||||
|
|
||||||
namespace BattleFieldSimulator.BattlefieldEnvironment
|
namespace BattleFieldSimulator.BattlefieldEnvironment
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using BattleFieldSimulator.FileSystem;
|
|
||||||
using BattleFieldSimulator.JsonSerialization;
|
using BattleFieldSimulator.JsonSerialization;
|
||||||
using static BattleFieldSimulator.FileSystem.FileSystemConstants;
|
using static BattleFieldSimulator.FileSystem.FileSystemConstants;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace BattleFieldSimulator.BattlefieldEnvironment
|
||||||
|
{
|
||||||
|
public class MapPath
|
||||||
|
{
|
||||||
|
public List<Point> Path { get; }
|
||||||
|
public int Distance { get; }
|
||||||
|
public MapPath(List<Point> points, int distance)
|
||||||
|
{
|
||||||
|
Path = new List<Point>();
|
||||||
|
Distance = distance;
|
||||||
|
foreach (var point in points)
|
||||||
|
{
|
||||||
|
Path.Add(point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace BattleFieldSimulator.BattlefieldEnvironment
|
||||||
|
{
|
||||||
|
public class MapPrinter : IMapPrinter
|
||||||
|
{
|
||||||
|
public void PrintMap(IMap map, List<Troop> allies, List<Troop> adversaries, StreamWriter environmentOutFile)
|
||||||
|
{
|
||||||
|
for (var i = 0; i < map.X; i++)
|
||||||
|
{
|
||||||
|
for (var j = 0; j < map.Y; j++)
|
||||||
|
{
|
||||||
|
var p1 = new Point(i, j);
|
||||||
|
|
||||||
|
if (adversaries.Any(x => x.Location == p1 && allies.Any(y=>y.Location == p1)))
|
||||||
|
{
|
||||||
|
Console.Write("A/E");
|
||||||
|
environmentOutFile.Write("A/E");
|
||||||
|
}
|
||||||
|
else if (allies.Any(x => x.Location == p1))
|
||||||
|
{
|
||||||
|
Console.Write("A ");
|
||||||
|
environmentOutFile.Write("A ");
|
||||||
|
}
|
||||||
|
else if (adversaries.Any(x => x.Location == p1))
|
||||||
|
{
|
||||||
|
Console.Write("E ");
|
||||||
|
environmentOutFile.Write("E ");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.Write(". ");
|
||||||
|
environmentOutFile.Write(". ");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine();
|
||||||
|
environmentOutFile.WriteLine();
|
||||||
|
}
|
||||||
|
Console.WriteLine();
|
||||||
|
environmentOutFile.WriteLine();
|
||||||
|
for(int i =0; i < map.X*2; i++)
|
||||||
|
{
|
||||||
|
Console.Write("-");
|
||||||
|
environmentOutFile.Write("-");
|
||||||
|
}
|
||||||
|
Console.WriteLine();
|
||||||
|
environmentOutFile.WriteLine();
|
||||||
|
environmentOutFile.Flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace BattleFieldSimulator.BattlefieldEnvironment
|
||||||
|
{
|
||||||
|
public class Node
|
||||||
|
{
|
||||||
|
public int X { get; }
|
||||||
|
public int Y { get; }
|
||||||
|
public Node Parent { get; }
|
||||||
|
public Point ParentPoint { get; }
|
||||||
|
|
||||||
|
public Node(int x, int y, Node parent, Point parentPoint)
|
||||||
|
{
|
||||||
|
X = x;
|
||||||
|
Y = y;
|
||||||
|
Parent = parent;
|
||||||
|
ParentPoint = parentPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point ToPoint() => new Point(X, Y);
|
||||||
|
public string toString() => $"{X},{Y}";
|
||||||
|
|
||||||
|
}
|
||||||
|
public class PathGenerator : IPathGenerator
|
||||||
|
{
|
||||||
|
private IMap _map { get; set; }
|
||||||
|
|
||||||
|
public PathGenerator()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MapPath> GeneratePaths(Point position, Point destination, IMap map)
|
||||||
|
{
|
||||||
|
_map = map;
|
||||||
|
return FindPath(position, destination);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<MapPath> FindPath(Point position, Point destination)
|
||||||
|
{
|
||||||
|
var returnPaths = new List<MapPath>();
|
||||||
|
var foundCount = 0;
|
||||||
|
var row = new List<int>{-1, 0, 0, 1, -1, 1, 1, -1};
|
||||||
|
var column = new List<int>{0, -1, 1, 0, 1, 1, -1, -1};
|
||||||
|
var queue = new Queue<Node>();
|
||||||
|
var destNode = new Node(position.X, position.Y, null, position);
|
||||||
|
queue.Enqueue(destNode);
|
||||||
|
var visited = new HashSet<string> {destNode.toString()};
|
||||||
|
while (queue.Count!=0)
|
||||||
|
{
|
||||||
|
var curr = queue.Dequeue();
|
||||||
|
var i = curr.X;
|
||||||
|
var j = curr.Y;
|
||||||
|
if (i == destination.X && j == destination.Y)
|
||||||
|
{
|
||||||
|
var x = curr;
|
||||||
|
var returnList = new List<Point>();
|
||||||
|
while (x.Parent!=null)
|
||||||
|
{
|
||||||
|
returnList.Add(x.ParentPoint);
|
||||||
|
x = x.Parent;
|
||||||
|
}
|
||||||
|
returnPaths.Add(new MapPath(returnList, foundCount));
|
||||||
|
foundCount++;
|
||||||
|
}
|
||||||
|
for (var k = 0; k < 6; k++)
|
||||||
|
{
|
||||||
|
var x = i + row[k];
|
||||||
|
var y = j + column[k];
|
||||||
|
if (IsValidMove(curr.ToPoint(), curr.ParentPoint, _map.X, _map.Y))
|
||||||
|
{
|
||||||
|
var next = new Node(x, y, curr, new Point(x,y));
|
||||||
|
var nextKey = next.toString();
|
||||||
|
if (!visited.Contains(nextKey))
|
||||||
|
{
|
||||||
|
queue.Enqueue(next);
|
||||||
|
visited.Add(nextKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnPaths;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsValidMove(Point point, Point toPoint, int mapX, int mapY)
|
||||||
|
{
|
||||||
|
if (point.X < 0 || point.Y < 0 || toPoint.X < 0 || toPoint.Y < 0 ||
|
||||||
|
point.X >= mapX || point.Y >= mapY || toPoint.X >= mapX || toPoint.Y >= mapY)
|
||||||
|
return false;
|
||||||
|
return Math.Abs(_map.Grid[toPoint.X][toPoint.Y] - _map.Grid[point.X][point.Y]) <= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace BattleFieldSimulator.BattlefieldEnvironment
|
namespace BattleFieldSimulator.BattlefieldEnvironment
|
||||||
{
|
{
|
||||||
public struct Point
|
public struct Point
|
||||||
@@ -12,6 +10,12 @@ namespace BattleFieldSimulator.BattlefieldEnvironment
|
|||||||
X = x;
|
X = x;
|
||||||
Y = y;
|
Y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool operator ==(Point p1, Point p2) => p1.X == p2.X && p1.Y == p2.Y;
|
||||||
|
|
||||||
|
public static bool operator !=(Point p1, Point p2)
|
||||||
|
{
|
||||||
|
return !(p1 == p2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace BattleFieldSimulator.BattlefieldEnvironment
|
namespace BattleFieldSimulator.BattlefieldEnvironment
|
||||||
{
|
{
|
||||||
public struct EffectivenessRatios
|
public struct EffectivenessRatios
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
|
||||||
using BattleFieldSimulator.Exceptions;
|
using BattleFieldSimulator.Exceptions;
|
||||||
|
|
||||||
namespace BattleFieldSimulator.BattlefieldEnvironment
|
namespace BattleFieldSimulator.BattlefieldEnvironment
|
||||||
@@ -10,7 +9,7 @@ namespace BattleFieldSimulator.BattlefieldEnvironment
|
|||||||
public int EngagementDistance { get; }
|
public int EngagementDistance { get; }
|
||||||
public int TroopCount { get; }
|
public int TroopCount { get; }
|
||||||
public Mission Mission { get; }
|
public Mission Mission { get; }
|
||||||
public Point Location { get; }
|
public Point Location { get; set; }
|
||||||
public double MovementSpeed { get; }
|
public double MovementSpeed { get; }
|
||||||
public double WeaponDamage { get; }
|
public double WeaponDamage { get; }
|
||||||
public double Marksmanship { get; }
|
public double Marksmanship { get; }
|
||||||
@@ -21,6 +20,7 @@ namespace BattleFieldSimulator.BattlefieldEnvironment
|
|||||||
public double CurrentSpeed { get; set; }
|
public double CurrentSpeed { get; set; }
|
||||||
public List<Troop> IdentifiedEnemy { get; }
|
public List<Troop> IdentifiedEnemy { get; }
|
||||||
public int Fatalities { get; set; }
|
public int Fatalities { get; set; }
|
||||||
|
public Point Destination { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -56,9 +56,11 @@ namespace BattleFieldSimulator.BattlefieldEnvironment
|
|||||||
Objective = objective;
|
Objective = objective;
|
||||||
IdentifiedEnemy = new List<Troop>();
|
IdentifiedEnemy = new List<Troop>();
|
||||||
Fatalities = 0;
|
Fatalities = 0;
|
||||||
|
Destination = objective;
|
||||||
ValidateTroop();
|
ValidateTroop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void ValidateTroop()
|
private void ValidateTroop()
|
||||||
{
|
{
|
||||||
if(SightDistance > 10 || SightDistance < 0)
|
if(SightDistance > 10 || SightDistance < 0)
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using BattleFieldSimulator.SimRunner;
|
using BattleFieldSimulator.SimRunner;
|
||||||
|
|
||||||
namespace BattleFieldSimulator.ConsoleClient
|
namespace BattleFieldSimulator.ConsoleClient
|
||||||
@@ -22,16 +24,17 @@ namespace BattleFieldSimulator.ConsoleClient
|
|||||||
{
|
{
|
||||||
DisplayWelcome();
|
DisplayWelcome();
|
||||||
input = Console.ReadLine();
|
input = Console.ReadLine();
|
||||||
inputValid = ValidInput(input);
|
inputValid = ValidInput(input.Split(' ').ToList()[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (input)
|
var inString = input.Split(' ').ToList();
|
||||||
|
switch (inString[0])
|
||||||
{
|
{
|
||||||
case "-h":
|
case "-h":
|
||||||
PrintHelpMenu();
|
PrintHelpMenu();
|
||||||
break;
|
break;
|
||||||
case "-r":
|
case "-r":
|
||||||
_simRunner.RunSimulation("SimpleMap.json", "SimpleTroopFile.json");
|
_simRunner.RunSimulation(inString[1], inString[2], inString[3]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
@@ -41,7 +44,11 @@ namespace BattleFieldSimulator.ConsoleClient
|
|||||||
|
|
||||||
private void PrintHelpMenu()
|
private void PrintHelpMenu()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
Console.WriteLine($"<-r mapFileName.json TroopFileName.json> Will execute the program on the given files. \n" +
|
||||||
|
$"A properly formatted man and troop json file are required. The files must be placed \n" +
|
||||||
|
$"in their respective folder locations. There are examples of what the files should \n" +
|
||||||
|
$"look like in there. \n \n" +
|
||||||
|
$"<-q> Will exit the program");
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ValidInput(string input) => input == "-h" || input == "-r" || input == "-q";
|
private bool ValidInput(string input) => input == "-h" || input == "-r" || input == "-q";
|
||||||
@@ -51,7 +58,7 @@ namespace BattleFieldSimulator.ConsoleClient
|
|||||||
Console.WriteLine("Welcome to the battlefield simulator! \n \n " +
|
Console.WriteLine("Welcome to the battlefield simulator! \n \n " +
|
||||||
"Please make a selection: \n" +
|
"Please make a selection: \n" +
|
||||||
"\t <-h> help menu \n" +
|
"\t <-h> help menu \n" +
|
||||||
"\t <-r> run program \n" +
|
"\t <-r mapFileName.json TroopFileName.json outFile.txt> run program \n" +
|
||||||
"\t <-q> exit program \n");
|
"\t <-q> exit program \n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ namespace BattleFieldSimulator
|
|||||||
container.Register<IJsonSerializer, JsonSerializer>(Reuse.Singleton);
|
container.Register<IJsonSerializer, JsonSerializer>(Reuse.Singleton);
|
||||||
container.Register<ITroopLoader, TroopLoader>(Reuse.Singleton);
|
container.Register<ITroopLoader, TroopLoader>(Reuse.Singleton);
|
||||||
container.Register<ISimulation, Simulation>(Reuse.Singleton);
|
container.Register<ISimulation, Simulation>(Reuse.Singleton);
|
||||||
|
container.Register<IPathGenerator, PathGenerator>(Reuse.Singleton);
|
||||||
|
container.Register<IMapPrinter, MapPrinter>(Reuse.Singleton);
|
||||||
// container.Register<>(Reuse.Singleton);
|
// container.Register<>(Reuse.Singleton);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,6 @@ namespace BattleFieldSimulator.SimRunner
|
|||||||
{
|
{
|
||||||
public interface ISimRunner
|
public interface ISimRunner
|
||||||
{
|
{
|
||||||
void RunSimulation(string mapName, string troopFile);
|
void RunSimulation(string mapName, string troopFile, string outFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
using System;
|
|
||||||
using BattleFieldSimulator.BattlefieldEnvironment;
|
using BattleFieldSimulator.BattlefieldEnvironment;
|
||||||
using DryIoc;
|
|
||||||
using Environment = BattleFieldSimulator.BattlefieldEnvironment.Environment;
|
using Environment = BattleFieldSimulator.BattlefieldEnvironment.Environment;
|
||||||
|
|
||||||
namespace BattleFieldSimulator.SimRunner
|
namespace BattleFieldSimulator.SimRunner
|
||||||
@@ -16,15 +14,15 @@ namespace BattleFieldSimulator.SimRunner
|
|||||||
_simulation = simulation;
|
_simulation = simulation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RunSimulation(string mapName, string troopFile)
|
public void RunSimulation(string mapName, string troopFile, string outFile)
|
||||||
{
|
{
|
||||||
var environment = Setup(mapName, troopFile);
|
var environment = Setup(mapName, troopFile, outFile);
|
||||||
_simulation.Run(environment);
|
_simulation.Run(environment);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Environment Setup(string mapName, string troopFile)
|
private Environment Setup(string mapName, string troopFile, string outFile)
|
||||||
{
|
{
|
||||||
return _environmentSetup.Setup(mapName, troopFile);
|
return _environmentSetup.Setup(mapName, troopFile, outFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,19 +1,19 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.Serialization;
|
|
||||||
using System.Text;
|
|
||||||
using System.Xml.Schema;
|
|
||||||
using BattleFieldSimulator.BattlefieldEnvironment;
|
using BattleFieldSimulator.BattlefieldEnvironment;
|
||||||
using BattleFieldSimulator.FileSystem;
|
|
||||||
|
|
||||||
namespace BattleFieldSimulator.SimRunner
|
namespace BattleFieldSimulator.SimRunner
|
||||||
{
|
{
|
||||||
public class Simulation : ISimulation
|
public class Simulation : ISimulation
|
||||||
{
|
{
|
||||||
public Simulation()
|
private IPathGenerator _pathGenerator;
|
||||||
|
private IMapPrinter _mapPritner;
|
||||||
|
|
||||||
|
public Simulation(IPathGenerator pathGenerator, IMapPrinter mapPrinter)
|
||||||
{
|
{
|
||||||
|
_pathGenerator = pathGenerator;
|
||||||
|
_mapPritner = mapPrinter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Run(IEnvironment environment)
|
public void Run(IEnvironment environment)
|
||||||
@@ -21,49 +21,205 @@ namespace BattleFieldSimulator.SimRunner
|
|||||||
var finished = false;
|
var finished = false;
|
||||||
while (!finished)
|
while (!finished)
|
||||||
{
|
{
|
||||||
|
PrintRoundInfo(environment);
|
||||||
RunRound(environment);
|
RunRound(environment);
|
||||||
finished = CheckIfFinished(environment.Allies, environment.Adversaries);
|
finished = CheckIfFinished(environment.Allies, environment.Adversaries);
|
||||||
}
|
}
|
||||||
|
if(environment.Adversaries.Count != 0)
|
||||||
|
Console.WriteLine($"The Enemy Won!!\n\n");
|
||||||
|
if(environment.Allies.Count != 0)
|
||||||
|
Console.WriteLine($"We Were Victorious!!\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PrintRoundInfo(IEnvironment environment)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Allies: {environment.Allies.Count} " +
|
||||||
|
$"\nAdversaries: {environment.Adversaries.Count}");
|
||||||
|
environment.OutFile.WriteLine($"Allies: {environment.Allies.Count} " +
|
||||||
|
$"\nAdversaries: {environment.Adversaries.Count}");
|
||||||
|
foreach(var ally in environment.Allies)
|
||||||
|
{
|
||||||
|
Console.WriteLine(
|
||||||
|
$"Ally {environment.Allies.IndexOf(ally)} Casualties: {ally.Fatalities} Initial Troop Count: {ally.TroopCount}");
|
||||||
|
environment.OutFile.WriteLine($"Ally {environment.Allies.IndexOf(ally)} Casualties: {ally.Fatalities} Initial Troop Count: {ally.TroopCount}");
|
||||||
|
|
||||||
|
}
|
||||||
|
foreach(var adversary in environment.Adversaries)
|
||||||
|
{
|
||||||
|
Console.WriteLine(
|
||||||
|
$"Adversary {environment.Adversaries.IndexOf(adversary)} Casualties: {adversary.Fatalities} Initial Troop Count: {adversary.TroopCount}");
|
||||||
|
environment.OutFile.WriteLine($"Adversary {environment.Adversaries.IndexOf(adversary)} Casualties: {adversary.Fatalities} Initial Troop Count: {adversary.TroopCount}");
|
||||||
|
}
|
||||||
|
|
||||||
|
_mapPritner.PrintMap(environment.Map, environment.Allies, environment.Adversaries, environment.OutFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RunRound(IEnvironment environment)
|
private void RunRound(IEnvironment environment)
|
||||||
{
|
{
|
||||||
var map = environment.Map;
|
var map = environment.Map;
|
||||||
var allies = environment.Allies;
|
var allys = environment.Allies;
|
||||||
var adversaries = environment.Adversaries;
|
var adversaries = environment.Adversaries;
|
||||||
foreach (var troop in allies)
|
foreach (var troop in allys)
|
||||||
LookAround(troop, map, adversaries);
|
LookAround(troop, map, adversaries);
|
||||||
|
|
||||||
foreach (var troop in adversaries)
|
foreach (var troop in adversaries)
|
||||||
LookAround(troop, map, allies);
|
LookAround(troop, map, allys);
|
||||||
CheckCallForHelp(allies, adversaries);
|
CheckCallForHelp(allys, adversaries);
|
||||||
var nextTurn = false;
|
var nextTurn = false;
|
||||||
var current = 0;
|
var current = 0;
|
||||||
|
foreach (var ally in allys.Where(ally => ally.IdentifiedEnemy.Count == 0))
|
||||||
|
{
|
||||||
|
if (ally.AssistanceQueue.Count == 0)
|
||||||
|
{
|
||||||
|
Move(ally, map, ally.Objective);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var smallest = double.MaxValue;
|
||||||
|
var destPoint = new Point(0,0);
|
||||||
|
foreach (var request in ally.AssistanceQueue)
|
||||||
|
{
|
||||||
|
var dist = Distance(request, ally.Location);
|
||||||
|
if (dist < smallest)
|
||||||
|
{
|
||||||
|
smallest = dist;
|
||||||
|
destPoint = request;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Move(ally, map, destPoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var adversary in adversaries.Where(adversary => adversary.IdentifiedEnemy.Count == 0))
|
||||||
|
{
|
||||||
|
if (adversary.AssistanceQueue.Count == 0 )
|
||||||
|
{
|
||||||
|
Move(adversary, map, adversary.Objective);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var smallest = double.MaxValue;
|
||||||
|
var destPoint = new Point(0,0);
|
||||||
|
foreach (var request in adversary.AssistanceQueue)
|
||||||
|
{
|
||||||
|
var dist = Distance(request, adversary.Location);
|
||||||
|
if (dist < smallest)
|
||||||
|
{
|
||||||
|
smallest = dist;
|
||||||
|
destPoint = request;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Move(adversary, map, destPoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
while (!nextTurn)
|
while (!nextTurn)
|
||||||
{
|
{
|
||||||
if (current >= allies.Count && current >= adversaries.Count)
|
if (current >= allys.Count && current >= adversaries.Count)
|
||||||
nextTurn = true;
|
nextTurn = true;
|
||||||
if (current < allies.Count)
|
if (current < allys.Count)
|
||||||
Attack(allies[current], allies[current].IdentifiedEnemy);
|
Attack(allys[current], allys[current].IdentifiedEnemy);
|
||||||
if (current < adversaries.Count)
|
if (current < adversaries.Count)
|
||||||
Attack(adversaries[current], adversaries[current].IdentifiedEnemy);
|
Attack(adversaries[current], adversaries[current].IdentifiedEnemy);
|
||||||
if (current < allies.Count)
|
|
||||||
if (allies[current].TroopCount == allies[current].Fatalities)
|
//Clean up the Dead.
|
||||||
allies.Remove(allies[current]);
|
if (current < allys.Count)
|
||||||
|
if (allys[current].TroopCount == allys[current].Fatalities)
|
||||||
|
{
|
||||||
|
allys.Remove(allys[current]);
|
||||||
|
foreach (var adversary in adversaries)
|
||||||
|
{
|
||||||
|
adversary.IdentifiedEnemy.RemoveAll(n => n.TroopCount == n.Fatalities);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (current < adversaries.Count)
|
if (current < adversaries.Count)
|
||||||
if (adversaries[current].TroopCount == adversaries[current].Fatalities)
|
if (adversaries[current].TroopCount == adversaries[current].Fatalities)
|
||||||
|
{
|
||||||
adversaries.Remove(adversaries[current]);
|
adversaries.Remove(adversaries[current]);
|
||||||
|
foreach (var ally in allys)
|
||||||
|
{
|
||||||
|
ally.IdentifiedEnemy.RemoveAll(n => n.Fatalities == n.TroopCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
current++;
|
current++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckCallForHelp(List<Troop> allies, List<Troop> adversaries)
|
private void Move(Troop troop, IMap map, Point destPoint)
|
||||||
{
|
{
|
||||||
foreach (var eTroop in from ally in allies from eTroop in ally.IdentifiedEnemy where CalculateAttackValues(eTroop, ally)>CalculateAttackValues(ally, eTroop) select eTroop)
|
var x = _pathGenerator.GeneratePaths(troop.Location, destPoint, map);
|
||||||
|
CalculateMove(x, map, troop);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CalculateMove(List<MapPath> mapPaths, IMap map, Troop troop)
|
||||||
|
{
|
||||||
|
mapPaths.OrderBy(p => p.Distance);
|
||||||
|
var path = mapPaths[0].Path;
|
||||||
|
path.Reverse();
|
||||||
|
var movement = GetMovementSpeed(troop);
|
||||||
|
var index = 0;
|
||||||
|
while (movement > 0)
|
||||||
{
|
{
|
||||||
CallForHelp(eTroop.Location, allies);
|
var current = path[index];
|
||||||
|
var next = path[index + 1];
|
||||||
|
if (Math.Abs(map.Grid[next.X][next.Y] - map.Grid[current.X][current.Y]) > 1)
|
||||||
|
movement -= 2;
|
||||||
|
else
|
||||||
|
movement--;
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
troop.Location = path[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
private double GetMovementSpeed(Troop troop)
|
||||||
|
{
|
||||||
|
var r = new Random();
|
||||||
|
double speed;
|
||||||
|
if (troop.Mission == Mission.Attack)
|
||||||
|
{
|
||||||
|
if (troop.AssistanceQueue.Count > 0)
|
||||||
|
speed = troop.MovementSpeed;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (NextBool(r, 65))
|
||||||
|
speed = troop.MovementSpeed;
|
||||||
|
else if (NextBool(r, 55))
|
||||||
|
speed = troop.MovementSpeed * .75;
|
||||||
|
else if (NextBool(r, 45))
|
||||||
|
speed = troop.MovementSpeed * .5;
|
||||||
|
else
|
||||||
|
speed = troop.MovementSpeed * .25;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (troop.AssistanceQueue.Count > 0)
|
||||||
|
speed = troop.MovementSpeed * .75;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (NextBool(r, 45))
|
||||||
|
speed = troop.MovementSpeed;
|
||||||
|
else if (NextBool(r, 35))
|
||||||
|
speed = troop.MovementSpeed * .75;
|
||||||
|
else if (NextBool(r, 25))
|
||||||
|
speed = troop.MovementSpeed * .5;
|
||||||
|
else
|
||||||
|
speed = troop.MovementSpeed * .15;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
speed = (int) speed;
|
||||||
|
if (speed < 1)
|
||||||
|
speed = 1;
|
||||||
|
return speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckCallForHelp(List<Troop> allys, List<Troop> adversaries)
|
||||||
|
{
|
||||||
|
foreach (var eTroop in from ally in allys from eTroop in ally.IdentifiedEnemy where CalculateAttackValues(eTroop, ally)>CalculateAttackValues(ally, eTroop) select eTroop)
|
||||||
|
{
|
||||||
|
CallForHelp(eTroop.Location, allys);
|
||||||
}
|
}
|
||||||
foreach (var eTroop in from adversary in adversaries from eTroop in adversary.IdentifiedEnemy where CalculateAttackValues(eTroop, adversary)>CalculateAttackValues(adversary, eTroop) select eTroop)
|
foreach (var eTroop in from adversary in adversaries from eTroop in adversary.IdentifiedEnemy where CalculateAttackValues(eTroop, adversary)>CalculateAttackValues(adversary, eTroop) select eTroop)
|
||||||
{
|
{
|
||||||
@@ -113,11 +269,12 @@ namespace BattleFieldSimulator.SimRunner
|
|||||||
var currentCell = new Point(x, y);
|
var currentCell = new Point(x, y);
|
||||||
if (Distance(troop.Location, currentCell) < adjustedTroopSight)
|
if (Distance(troop.Location, currentCell) < adjustedTroopSight)
|
||||||
nearbyTroops.AddRange(enemy.Where(q =>
|
nearbyTroops.AddRange(enemy.Where(q =>
|
||||||
q.Location.X == currentCell.X && q.Location.Y == currentCell.Y).ToList());
|
q.Location == currentCell && !troop.IdentifiedEnemy.Contains(q)).ToList());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
troop.IdentifiedEnemy.AddRange(VerifyTroopSighting(nearbyTroops, troop, map));
|
troop.IdentifiedEnemy.AddRange(VerifyTroopSighting(nearbyTroops, troop, map));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private double CalculateTrueSightDistance(Troop troop)
|
private double CalculateTrueSightDistance(Troop troop)
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
174
BattleFieldSimulator/BattleFieldSimulator/bin/Debug/Redirect.txt
Normal file
174
BattleFieldSimulator/BattleFieldSimulator/bin/Debug/Redirect.txt
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
Allies: 2
|
||||||
|
Adversaries: 2
|
||||||
|
Ally 0 Casualties: 0 Initial Troop Count: 30
|
||||||
|
Ally 1 Casualties: 0 Initial Troop Count: 10
|
||||||
|
Adversary 0 Casualties: 0 Initial Troop Count: 10
|
||||||
|
Adversary 1 Casualties: 0 Initial Troop Count: 15
|
||||||
|
A . A . . . . . . .
|
||||||
|
. E . . . . . . . .
|
||||||
|
. . . . . . . E . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
|
||||||
|
--------------------
|
||||||
|
Allies: 2
|
||||||
|
Adversaries: 2
|
||||||
|
Ally 0 Casualties: 20 Initial Troop Count: 30
|
||||||
|
Ally 1 Casualties: 5 Initial Troop Count: 10
|
||||||
|
Adversary 0 Casualties: 6 Initial Troop Count: 10
|
||||||
|
Adversary 1 Casualties: 0 Initial Troop Count: 15
|
||||||
|
A . A . . . E . . .
|
||||||
|
. E . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
|
||||||
|
--------------------
|
||||||
|
Allies: 2
|
||||||
|
Adversaries: 2
|
||||||
|
Ally 0 Casualties: 22 Initial Troop Count: 30
|
||||||
|
Ally 1 Casualties: 6 Initial Troop Count: 10
|
||||||
|
Adversary 0 Casualties: 7 Initial Troop Count: 10
|
||||||
|
Adversary 1 Casualties: 0 Initial Troop Count: 15
|
||||||
|
A . A E . . . . . .
|
||||||
|
. E . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
|
||||||
|
--------------------
|
||||||
|
Allies: 1
|
||||||
|
Adversaries: 2
|
||||||
|
Ally 0 Casualties: 26 Initial Troop Count: 30
|
||||||
|
Adversary 0 Casualties: 8 Initial Troop Count: 10
|
||||||
|
Adversary 1 Casualties: 4 Initial Troop Count: 15
|
||||||
|
A . . E . . . . . .
|
||||||
|
. E . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
|
||||||
|
--------------------
|
||||||
|
Allies: 1
|
||||||
|
Adversaries: 2
|
||||||
|
Ally 0 Casualties: 27 Initial Troop Count: 30
|
||||||
|
Adversary 0 Casualties: 9 Initial Troop Count: 10
|
||||||
|
Adversary 1 Casualties: 5 Initial Troop Count: 15
|
||||||
|
A/E. . . . . . . . .
|
||||||
|
. E . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
|
||||||
|
--------------------
|
||||||
|
Allies: 1
|
||||||
|
Adversaries: 1
|
||||||
|
Ally 0 Casualties: 27 Initial Troop Count: 30
|
||||||
|
Adversary 0 Casualties: 6 Initial Troop Count: 15
|
||||||
|
A/E. . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
|
||||||
|
--------------------
|
||||||
|
Allies: 1
|
||||||
|
Adversaries: 1
|
||||||
|
Ally 0 Casualties: 27 Initial Troop Count: 30
|
||||||
|
Adversary 0 Casualties: 7 Initial Troop Count: 15
|
||||||
|
A/E. . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
|
||||||
|
--------------------
|
||||||
|
Allies: 1
|
||||||
|
Adversaries: 1
|
||||||
|
Ally 0 Casualties: 27 Initial Troop Count: 30
|
||||||
|
Adversary 0 Casualties: 9 Initial Troop Count: 15
|
||||||
|
A/E. . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
|
||||||
|
--------------------
|
||||||
|
Allies: 1
|
||||||
|
Adversaries: 1
|
||||||
|
Ally 0 Casualties: 28 Initial Troop Count: 30
|
||||||
|
Adversary 0 Casualties: 9 Initial Troop Count: 15
|
||||||
|
A/E. . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
|
||||||
|
--------------------
|
||||||
|
Allies: 1
|
||||||
|
Adversaries: 1
|
||||||
|
Ally 0 Casualties: 29 Initial Troop Count: 30
|
||||||
|
Adversary 0 Casualties: 10 Initial Troop Count: 15
|
||||||
|
A/E. . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
|
||||||
|
--------------------
|
||||||
|
Allies: 1
|
||||||
|
Adversaries: 1
|
||||||
|
Ally 0 Casualties: 29 Initial Troop Count: 30
|
||||||
|
Adversary 0 Casualties: 11 Initial Troop Count: 15
|
||||||
|
A/E. . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
122
BattleFieldSimulator/BattleFieldSimulator/bin/Debug/test.txt
Normal file
122
BattleFieldSimulator/BattleFieldSimulator/bin/Debug/test.txt
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
Allies: 2
|
||||||
|
Adversaries: 2
|
||||||
|
Ally 0 Casualties: 0 Initial Troop Count: 30
|
||||||
|
Ally 1 Casualties: 0 Initial Troop Count: 10
|
||||||
|
Adversary 0 Casualties: 0 Initial Troop Count: 10
|
||||||
|
Adversary 1 Casualties: 0 Initial Troop Count: 15
|
||||||
|
A . A . . . . . . .
|
||||||
|
. E . . . . . . . .
|
||||||
|
. . . . . . . E . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
|
||||||
|
--------------------
|
||||||
|
Allies: 2
|
||||||
|
Adversaries: 2
|
||||||
|
Ally 0 Casualties: 18 Initial Troop Count: 30
|
||||||
|
Ally 1 Casualties: 6 Initial Troop Count: 10
|
||||||
|
Adversary 0 Casualties: 6 Initial Troop Count: 10
|
||||||
|
Adversary 1 Casualties: 0 Initial Troop Count: 15
|
||||||
|
A . A . . . E . . .
|
||||||
|
. E . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
|
||||||
|
--------------------
|
||||||
|
Allies: 2
|
||||||
|
Adversaries: 2
|
||||||
|
Ally 0 Casualties: 25 Initial Troop Count: 30
|
||||||
|
Ally 1 Casualties: 6 Initial Troop Count: 10
|
||||||
|
Adversary 0 Casualties: 9 Initial Troop Count: 10
|
||||||
|
Adversary 1 Casualties: 0 Initial Troop Count: 15
|
||||||
|
A . A E . . . . . .
|
||||||
|
. E . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
|
||||||
|
--------------------
|
||||||
|
Allies: 2
|
||||||
|
Adversaries: 1
|
||||||
|
Ally 0 Casualties: 25 Initial Troop Count: 30
|
||||||
|
Ally 1 Casualties: 6 Initial Troop Count: 10
|
||||||
|
Adversary 0 Casualties: 5 Initial Troop Count: 15
|
||||||
|
A . A E . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
|
||||||
|
--------------------
|
||||||
|
Allies: 2
|
||||||
|
Adversaries: 1
|
||||||
|
Ally 0 Casualties: 25 Initial Troop Count: 30
|
||||||
|
Ally 1 Casualties: 7 Initial Troop Count: 10
|
||||||
|
Adversary 0 Casualties: 10 Initial Troop Count: 15
|
||||||
|
A . A E . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
|
||||||
|
--------------------
|
||||||
|
Allies: 2
|
||||||
|
Adversaries: 1
|
||||||
|
Ally 0 Casualties: 25 Initial Troop Count: 30
|
||||||
|
Ally 1 Casualties: 8 Initial Troop Count: 10
|
||||||
|
Adversary 0 Casualties: 12 Initial Troop Count: 15
|
||||||
|
A . A E . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
|
||||||
|
--------------------
|
||||||
|
Allies: 2
|
||||||
|
Adversaries: 1
|
||||||
|
Ally 0 Casualties: 25 Initial Troop Count: 30
|
||||||
|
Ally 1 Casualties: 8 Initial Troop Count: 10
|
||||||
|
Adversary 0 Casualties: 13 Initial Troop Count: 15
|
||||||
|
A . A E . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
. . . . . . . . . .
|
||||||
|
|
||||||
|
--------------------
|
||||||
Binary file not shown.
Binary file not shown.
BIN
BattleFieldSimulator/BattleFieldSimulator/bin/Release/Newtonsoft.Json.dll
Executable file
BIN
BattleFieldSimulator/BattleFieldSimulator/bin/Release/Newtonsoft.Json.dll
Executable file
Binary file not shown.
11262
BattleFieldSimulator/BattleFieldSimulator/bin/Release/Newtonsoft.Json.xml
Executable file
11262
BattleFieldSimulator/BattleFieldSimulator/bin/Release/Newtonsoft.Json.xml
Executable file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"Map": {
|
||||||
|
"X": "10",
|
||||||
|
"Y" : "10",
|
||||||
|
"Grid": [
|
||||||
|
[0, 0, 0, 0, 0, 0, 0, 5, 5, 0],
|
||||||
|
[0, 1, 1, 1, 0, 0, 0, 5, 5, 0],
|
||||||
|
[0, 2, 2, 2, 0, 0, 0, 5, 4, 0],
|
||||||
|
[0, 2, 3, 2, 0, 0, 0, 4, 3, 0],
|
||||||
|
[0, 2, 2, 1, 0, 0, 0, 3, 2, 0],
|
||||||
|
[0, 0, 0, 0, 0, 0, 0, 2, 2, 0],
|
||||||
|
[0, 0, 0, 0, 0, 0, 0, 1, 1, 0],
|
||||||
|
[0, 0, 0, 1, 0, 0, 0, 1, 0, 0],
|
||||||
|
[0, 0, 0, 0, 0, 0, 0, 1, 0, 0],
|
||||||
|
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
{
|
||||||
|
"Allies": [
|
||||||
|
{
|
||||||
|
"Troop":
|
||||||
|
{
|
||||||
|
"MovementSpeed": 1.5,
|
||||||
|
"SightDistance": 4,
|
||||||
|
"EngagementDistance": 3,
|
||||||
|
"WeaponDamage": 8.5,
|
||||||
|
"Marksmanship": 7,
|
||||||
|
"TroopCount": 30,
|
||||||
|
"Aggressiveness": 7,
|
||||||
|
"Defense": 6,
|
||||||
|
"Mission": "Defend",
|
||||||
|
"EntryPointX": 0,
|
||||||
|
"EntryPointY": 0,
|
||||||
|
"ObjectiveX": 0,
|
||||||
|
"ObjectiveY": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Troop":
|
||||||
|
{
|
||||||
|
"MovementSpeed": 2.5,
|
||||||
|
"SightDistance": 2,
|
||||||
|
"EngagementDistance": 1,
|
||||||
|
"WeaponDamage": 5,
|
||||||
|
"Marksmanship": 4,
|
||||||
|
"TroopCount": 10,
|
||||||
|
"Aggressiveness": 10,
|
||||||
|
"Defense": 3,
|
||||||
|
"Mission": "Defend",
|
||||||
|
"EntryPointX": 0,
|
||||||
|
"EntryPointY": 2,
|
||||||
|
"ObjectiveX": 0,
|
||||||
|
"ObjectiveY": 0
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Adversaries": [
|
||||||
|
{
|
||||||
|
"Troop":
|
||||||
|
{
|
||||||
|
"MovementSpeed": 2.5,
|
||||||
|
"SightDistance": 3,
|
||||||
|
"EngagementDistance": 1,
|
||||||
|
"WeaponDamage": 7,
|
||||||
|
"Marksmanship": 4,
|
||||||
|
"TroopCount": 10,
|
||||||
|
"Aggressiveness": 10,
|
||||||
|
"Defense": 3,
|
||||||
|
"Mission": "Attack",
|
||||||
|
"EntryPointX": 1,
|
||||||
|
"EntryPointY": 1,
|
||||||
|
"ObjectiveX": 0,
|
||||||
|
"ObjectiveY": 0
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Troop":
|
||||||
|
{
|
||||||
|
"MovementSpeed": 2.5,
|
||||||
|
"SightDistance": 2,
|
||||||
|
"EngagementDistance": 1,
|
||||||
|
"WeaponDamage": 1,
|
||||||
|
"Marksmanship": 4,
|
||||||
|
"TroopCount": 15,
|
||||||
|
"Aggressiveness": 10,
|
||||||
|
"Defense": 3,
|
||||||
|
"Mission": "Attack",
|
||||||
|
"EntryPointX": 2,
|
||||||
|
"EntryPointY": 7,
|
||||||
|
"ObjectiveX": 0,
|
||||||
|
"ObjectiveY": 0
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,10 @@
|
|||||||
|
/Users/bradybodily/Repositories/CS5110_Multi_Agent/BattleFieldSimulator/BattleFieldSimulator/bin/Release/maps/SimpleMap.json
|
||||||
|
/Users/bradybodily/Repositories/CS5110_Multi_Agent/BattleFieldSimulator/BattleFieldSimulator/bin/Release/troops/SimpleTroopFile.json
|
||||||
|
/Users/bradybodily/Repositories/CS5110_Multi_Agent/BattleFieldSimulator/BattleFieldSimulator/bin/Release/BattleFieldSimulator.exe
|
||||||
|
/Users/bradybodily/Repositories/CS5110_Multi_Agent/BattleFieldSimulator/BattleFieldSimulator/bin/Release/BattleFieldSimulator.pdb
|
||||||
|
/Users/bradybodily/Repositories/CS5110_Multi_Agent/BattleFieldSimulator/BattleFieldSimulator/bin/Release/Newtonsoft.Json.dll
|
||||||
|
/Users/bradybodily/Repositories/CS5110_Multi_Agent/BattleFieldSimulator/BattleFieldSimulator/bin/Release/Newtonsoft.Json.xml
|
||||||
|
/Users/bradybodily/Repositories/CS5110_Multi_Agent/BattleFieldSimulator/BattleFieldSimulator/obj/Release/BattleFieldSimulator.csprojAssemblyReference.cache
|
||||||
|
/Users/bradybodily/Repositories/CS5110_Multi_Agent/BattleFieldSimulator/BattleFieldSimulator/obj/Release/BattleFieldSimulator.csproj.CopyComplete
|
||||||
|
/Users/bradybodily/Repositories/CS5110_Multi_Agent/BattleFieldSimulator/BattleFieldSimulator/obj/Release/BattleFieldSimulator.exe
|
||||||
|
/Users/bradybodily/Repositories/CS5110_Multi_Agent/BattleFieldSimulator/BattleFieldSimulator/obj/Release/BattleFieldSimulator.pdb
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,10 @@
|
|||||||
|
/Users/bradybodily/Repositories/CS5110_Multi_Agent/BattleFieldSimulator/BattleFieldSimulator/bin/Release/maps/SimpleMap.json
|
||||||
|
/Users/bradybodily/Repositories/CS5110_Multi_Agent/BattleFieldSimulator/BattleFieldSimulator/bin/Release/troops/SimpleTroopFile.json
|
||||||
|
/Users/bradybodily/Repositories/CS5110_Multi_Agent/BattleFieldSimulator/BattleFieldSimulator/bin/Release/BattleFieldSimulator.exe
|
||||||
|
/Users/bradybodily/Repositories/CS5110_Multi_Agent/BattleFieldSimulator/BattleFieldSimulator/bin/Release/BattleFieldSimulator.pdb
|
||||||
|
/Users/bradybodily/Repositories/CS5110_Multi_Agent/BattleFieldSimulator/BattleFieldSimulator/bin/Release/Newtonsoft.Json.dll
|
||||||
|
/Users/bradybodily/Repositories/CS5110_Multi_Agent/BattleFieldSimulator/BattleFieldSimulator/bin/Release/Newtonsoft.Json.xml
|
||||||
|
/Users/bradybodily/Repositories/CS5110_Multi_Agent/BattleFieldSimulator/BattleFieldSimulator/obj/Release/BattleFieldSimulator.csprojAssemblyReference.cache
|
||||||
|
/Users/bradybodily/Repositories/CS5110_Multi_Agent/BattleFieldSimulator/BattleFieldSimulator/obj/Release/BattleFieldSimulator.csproj.CopyComplete
|
||||||
|
/Users/bradybodily/Repositories/CS5110_Multi_Agent/BattleFieldSimulator/BattleFieldSimulator/obj/Release/BattleFieldSimulator.exe
|
||||||
|
/Users/bradybodily/Repositories/CS5110_Multi_Agent/BattleFieldSimulator/BattleFieldSimulator/obj/Release/BattleFieldSimulator.pdb
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user