void Start() { diskCtrl = disk.GetComponent <diskController>(); ballCtrl = ball.GetComponent <ballController>(); manualDiskCtrl = disk.GetComponent <manualDiskControl>(); manualBallCtrl = ball.GetComponent <manualBallControl>(); diskStartPosition = diskCtrl.GetPosition(); ballStartPosition = ballCtrl.GetPosition(); CreateLineMaterial(); // Neural.learnRate = learnRate; List <float[, ]> weights = new List <float[, ]>(); weights.Add(new float[, ] { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0f }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0f }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }); weights.Add(new float[, ] { { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 } }); NewNet("Empty", new int[] { 3 * 4, 4, 3 }, weights); weights = new List <float[, ]>(); weights.Add(new float[, ] { { 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0.0f }, { 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0 }, { 0, 0, -0.3f, -0.0f, 0, 0, 0, 0, 0, 1, 0, 0, 0.0f }, { -0.3f, 0, 0, 0, 0, 0.0f, 0, 0, 0, 0, 0, -1, 0 } }); weights.Add(new float[, ] { { 0, 0.6f, 0, 1f, 0 }, { 0, 0, 0, 0, 0 }, { 0.6f, 0, 1f, 0, 0 } }); NewNet("Centering", new int[] { 3 * 4, 4, 3 }, weights); weights = new List <float[, ]>(); weights.Add(new float[, ] { { 0, 0, 0, 0, 0, 0, 0.8f, 0, 0, 0, 0, 0.4f, 0.0f }, { 0, 0, 0, 0, 0, 0, 0, 0, -0.8f, 0.4f, 0, 0, 0 }, { 0, 0, -0.3f, -0.0f, 0, 0, 0, 0, 0, 0, 0, 0, 0.0f }, { -0.3f, 0, 0, 0, 0, 0.0f, 0, 0, 0, 0, 0, 0, 0 } }); weights.Add(new float[, ] { { 0, .5f, 0, 1f, 0 }, { 0, 0, 0, 0, 0 }, { .5f, 0, 1f, 0, 0 } }); NewNet("Looping", new int[] { 3 * 4, 4, 3 }, weights); weights = new List <float[, ]>(); weights.Add(new float[, ] { { 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1.0f }, { 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 1.0f }, { 0, 0, -0.3f, -0.0f, 0, 0, 0, 0, 0, 1, 0, 0, 0.5f }, { -0.3f, 0, 0, 0, 0, 0.0f, 0, 0, 0, 0, 0, -1, 0.5f } }); weights.Add(new float[, ] { { 0, 0.6f, 0, 1f, 0 }, { 0, 0, 0, 0, 0 }, { 0.6f, 0, 1f, 0, 0 } }); NewNet("OnEdge", new int[] { 3 * 4, 4, 3 }, weights); ChangeNet(true); FuzzyLogic.AddRule(new Rule { usedFunctions = new int[] { 0, 0, 1, 0, 0, 0, 10, 0, 0, 18, 0, 0 }, weight = 0.2f }, true); FuzzyLogic.AddRule(new Rule { usedFunctions = new int[] { 0, 0, 3, 0, 0, 0, 10, 0, 0, 16, 0, 0 }, weight = -0.2f }, true); FuzzyLogic.AddRule(new Rule { usedFunctions = new int[] { 3, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 18 }, weight = -0.2f }, false); FuzzyLogic.AddRule(new Rule { usedFunctions = new int[] { 1, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 16 }, weight = 0.2f }, false); FuzzyLogic.AddRule(new Rule { usedFunctions = new int[] { 0, 0, 1, 0, 0, 0, 13, 0, 0, 18, 0, 0 }, weight = 0.2f }, true); FuzzyLogic.AddRule(new Rule { usedFunctions = new int[] { 0, 0, 3, 0, 0, 0, 11, 0, 0, 16, 0, 0 }, weight = -0.2f }, true); FuzzyLogic.AddRule(new Rule { usedFunctions = new int[] { 3, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 18 }, weight = -0.2f }, false); FuzzyLogic.AddRule(new Rule { usedFunctions = new int[] { 1, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 16 }, weight = 0.2f }, false); FuzzyLogic.AddRule(new Rule { usedFunctions = new int[] { 0, 0, 1, 0, 0, 0, 14, 0, 0, 18, 0, 0 }, weight = 2.9f }, true); FuzzyLogic.AddRule(new Rule { usedFunctions = new int[] { 0, 0, 3, 0, 0, 0, 10, 0, 0, 16, 0, 0 }, weight = -2.9f }, true); FuzzyLogic.AddRule(new Rule { usedFunctions = new int[] { 3, 0, 0, 0, 0, 0, 0, 0, 14, 0, 0, 18 }, weight = -2.9f }, false); FuzzyLogic.AddRule(new Rule { usedFunctions = new int[] { 1, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 16 }, weight = 2.9f }, false); return; Color[] colors = new Color[] { Color.red, Color.yellow, Color.gray, Color.blue, Color.green }; for (int z = 0; z < 4; z++) { for (int i = -50; i < 50; i++) { for (int j = 0; j < 5; j++) { //if (j % 2 == 0) continue; float i2 = i / 4f; float x = MembershipFunctions.functionCollection[j + 5 * z](i2), x2 = MembershipFunctions.functionCollection[j + 5 * z](i2 - 1 / 4f); Debug.DrawLine(Vector3.up * (1.5f * z + 3 + x) + Vector3.right * i2 / 10f, Vector3.up * (1.5f * z + 3 + x2) + Vector3.right * (i2 / 10f - 1 / 40f), colors[j], 100); } } } }
void Start() { diskCtrl = GetComponent <diskController>(); lastMousePosition = Input.mousePosition; }