Skip to content

Commit 3f93b82

Browse files
committed
Made Bit-Creation more variable
1 parent 7b8acbe commit 3f93b82

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

NeuralBotMasterFramework/TestConsole/Program.cs

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@ class Program
1212
private static double[][] inputData;
1313
private static double[][] expectedData;
1414

15+
const int TOTAL_BITS = 3;
16+
private static int totalNumberLength = Math.Pow(2, TOTAL_BITS).ToString().Length;
17+
1518
static void Main(string[] args)
1619
{
17-
int totalNetworks = 100;
18-
int inputNodes = 8;
20+
int totalNetworks = 1000;
21+
int inputNodes = TOTAL_BITS;
1922
int hiddenNodes = 10;
20-
int hiddenLayers = 4;
21-
int outputNodes = 3;
23+
int hiddenLayers = 3;
24+
int outputNodes = totalNumberLength;
2225

2326
int networksToKeep = 10;
2427
double mutationRate = 0.2;
@@ -34,26 +37,43 @@ static void Main(string[] args)
3437
algorithm.MutationRate = mutationRate;
3538
algorithm.MutationChance = mutationChance;
3639

40+
Console.WriteLine("Initialization complete");
41+
3742
while (true)
3843
{
44+
Console.WriteLine("Propagating");
3945
algorithm.PropagateAllNetworks();
46+
Console.WriteLine("Breeding");
4047
algorithm.BreedBestNetworks();
48+
PrintData(algorithm);
49+
Console.ReadLine();
50+
}
51+
}
52+
53+
private static void PrintData(GeneticAlgorithm algorithm)
54+
{
55+
for (int i = 0; i < 10; ++i)
56+
{
57+
Console.WriteLine($"Fitness {algorithm.NetworksAndFitness.Values.ElementAt(i)}");
4158
}
59+
Console.WriteLine();
4260
}
4361

4462
private static void SetupBinaryData()
4563
{
46-
inputData = new double[256][];
47-
expectedData = new double[256][];
48-
for (int i = 0; i <= 255; ++i)
64+
int TotalBinaryNumbers = (int)Math.Pow(2, TOTAL_BITS);
65+
66+
inputData = new double[TotalBinaryNumbers][];
67+
expectedData = new double[TotalBinaryNumbers][];
68+
for (int i = 0; i < TotalBinaryNumbers; ++i)
4969
{
50-
string binaryString = Convert.ToString(i, 2).PadLeft(8, '0');
70+
string binaryString = Convert.ToString(i, 2).PadLeft(TOTAL_BITS, '0');
5171
inputData[i] = new double[binaryString.Length];
5272
for (int j = 0; j < binaryString.Length; ++j)
5373
{
5474
inputData[i][j] = binaryString[j] == '1' ? 1 : 0;
5575
}
56-
string numberAsString = Convert.ToString(i).PadLeft(3, '0');
76+
string numberAsString = Convert.ToString(i).PadLeft(totalNumberLength, '0');
5777
expectedData[i] = new double[numberAsString.Length];
5878
for (int j = 0; j < numberAsString.Length; ++j)
5979
{

0 commit comments

Comments
 (0)