forked from stan-his/BlazorConnect4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
74 lines (69 loc) · 2.18 KB
/
Program.cs
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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace BlazorConnect4
{
public class Program
{
public static void Main(string[] args)
{
if (!Directory.Exists("Data"))
{
Directory.CreateDirectory("./Data");
}
CreateHostBuilder(args).Build().Run();
//InitiateNavySealTrainingProtocol();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
private static void InitiateNavySealTrainingProtocol()
{
Console.WriteLine("Started Navy Seal Training Protocol");
AIModels.QAgent red;
AIModels.QAgent yellow;
if (File.Exists("Data/Q1Red.bin"))
{
red = AIModels.QAgent.ConstructFromFile("Data/Q1Red.bin");
}
else
{
red = new AIModels.QAgent(Model.CellColor.Red);
red.ToFile("Data/Q1Red.bin");
}
if (File.Exists("Data/Q1Yellow.bin"))
{
yellow = AIModels.QAgent.ConstructFromFile("Data/Q1Yellow.bin");
}
else
{
yellow = new AIModels.QAgent(Model.CellColor.Yellow);
yellow.ToFile("Data/Q1Yellow.bin");
}
AIModels.RandomAI random = new AIModels.RandomAI();
for (int i = 0; i < 300; i++)
{
if (i % 2 == 0)
{
red.Trainer(100, yellow);
red.ToFile("Data/Q1Red.bin");
}
else
{
yellow.Trainer(100, red);
yellow.ToFile("Data/Q1Yellow.bin");
}
}
}
}
}