-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
84 lines (69 loc) · 2.38 KB
/
Program.cs
File metadata and controls
84 lines (69 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using ChainmailSim;
using McMaster.Extensions.CommandLineUtils;
using System.ComponentModel.DataAnnotations;
internal class Program
{
[Argument(0)]
[Required]
private int NoBlues { get; set; }
[Argument(1)]
[Required]
private string BlueString { get; set; }
public UnitTypes BlueType => Enum.Parse<UnitTypes>(BlueString);
[Argument(2)]
[Required]
private int NoReds { get; set; }
[Argument(3)]
[Required]
private string RedString { get; set; }
public UnitTypes RedType => Enum.Parse<UnitTypes>(RedString);
[Argument(4)]
private int Frontage { get; set; }
[Option("-c", CommandOptionType.SingleValue, Description = "Charge distance left")]
public int ChargeDistanceLeft { get; set; }
[Option("-m", CommandOptionType.SingleValue, Description = "Monte Carlo simulation count. If larger than 1 no verbose logging will be generated.")]
public int Sims { get; set; } = 1;
private static void Main(string[] args) => CommandLineApplication.Execute<Program>(args);
private void OnExecute()
{
if (Sims <= 1)
{
var attacker = new Force
{
FigsLeft = NoBlues,
Type = BlueType,
ChargeLeft = ChargeDistanceLeft,
};
var defender = new Force
{
FigsLeft = NoReds,
Type = RedType,
};
var res = new Battle(attacker, defender, Frontage, Console.WriteLine).Run(1);
Console.WriteLine(res.ToString());
}
else
{
var range = Enumerable.Range(0, Sims).Select(t =>
new Battle(new Force
{
FigsLeft = NoBlues,
Type = BlueType,
ChargeLeft = ChargeDistanceLeft,
},
new Force
{
FigsLeft = NoReds,
Type = RedType,
}, Frontage, null).Run(1));
using (var f = new StreamWriter($"{NoBlues}{BlueString}_vs_{NoReds}{RedString}_{Frontage}Wide.csv"))
{
f.WriteLine($"Rounds,AttackerWon, AttackersLeft, DefendersLeft");
foreach (var s in range)
{
f.WriteLine(s.ToString());
}
}
}
}
}