public static float LaunchFirst(NN net, int[] layers, float[] chosen) { StreamReader sk = new StreamReader(@"weightValues1.txt", System.Text.Encoding.GetEncoding(1257)); net.ReadWeights(sk); sk.Close(); float output = ((net.FeedForward(chosen)[0]) + 1f) * 2.5f; //gaunamas outputas is neural network Console.WriteLine("First AI result: {0}", output); List <float> possibilities = new List <float>(); //galimos vietos ikelti pamoka for (int i = 0; i < 5; i++) { if (chosen[i * 3 + 2] == 0f || chosen[i * 3] + chosen[i * 3 + 1] == 8f) { possibilities.Add(i); } if (chosen[i * 3 + 2] == 0f && chosen[i * 3] + chosen[i * 3 + 1] == 8f) { possibilities.Add(i); } } float nearest = ClosestTo(possibilities, output); return(nearest); }
public static int LaunchSecond(NN net, int[] layers, ref string[] chosen, string reference) { StreamReader sk = new StreamReader(@"weightValues2.txt", System.Text.Encoding.GetEncoding(1257)); net.ReadWeights(sk); sk.Close(); const int dataCount = 8; //kiek pradiniu duomenu float[] primalData = new float[dataCount]; //naujas duomenu masyvas NN'ui for (int i = 0; i < dataCount; i++) { primalData[i] = 1f; } primalData = TurnSecond(chosen, reference); //jau suzymetos klases ir langai paverciami i duomenis NN'ui float output = ((net.FeedForward(primalData)[0]) + 1f) * 4f; //gaunamas outputas is neural network Console.WriteLine("Second AI result: {0}", output); List <float> possibilities = new List <float>(); //galimos vietos ikelti pamoka for (int j = 0; j < dataCount; j++) { if (chosen[j] == "-") { possibilities.Add(j); //surenkamos visos tuscios vietos } } float nearest = ClosestTo(possibilities, output); //surandama artimiausia tuscia vieta pamokai return((int)nearest); }