Inheritance: MonoBehaviour
    private static float SetTimeOfImpactPositionPlane(BallBounce bounce, Plane plane)
    {
        float t = Time.deltaTime - GetTimeOfImpactPlane(bounce, plane);

        bounce.transform.position -= (bounce.velocity * t);
        return(t);
    }
    private static float SetTimeOfImpactPositionSphere(BallBounce bounce1, BallBounce bounce2)
    {
        float t = Time.deltaTime - GetTimeOfImpactSphere(bounce1, bounce2);

        bounce1.transform.position -= (bounce1.velocity * t);
        bounce2.transform.position -= (bounce2.velocity * t);
        return(t);
    }
    private static float GetTimeOfImpactPlane(BallBounce bounce, Plane plane)
    {
        Vector3 center         = bounce.transform.position;
        float   distanceBefore = plane.DistanceTo(center - bounce.velocity) - bounce.GetRadius();
        float   distanceAfter  = plane.DistanceTo(center) - bounce.GetRadius();
        float   t = -(distanceBefore * Time.deltaTime) / (distanceAfter - distanceBefore);

        return(t);
    }
    private static float GetTimeOfImpactSphere(BallBounce bounce1, BallBounce bounce2)
    {
        Vector3 center1        = bounce1.transform.position;
        Vector3 center2        = bounce2.transform.position;
        float   distanceBefore = ((center2 - (bounce2.velocity)) - (center1 - (bounce1.velocity))).magnitude;
        float   distanceAfter  = ((center2) - (center1)).magnitude;

        return(-(distanceBefore * Time.deltaTime) / (distanceAfter - distanceBefore));
    }
    private static void ResolveCollisionPlane(BallBounce bounce, Plane plane)
    {
        Vector3 velocity      = bounce.velocity;
        Vector3 perpendicular = plane.PerpToSurface(velocity);
        Vector3 parallel      = plane.ParallelToSurface(velocity);
        float   timeOfImpact  = SetTimeOfImpactPositionPlane(bounce, plane);
        Vector3 center        = bounce.transform.position;
        float   distance      = plane.DistanceTo(center) - bounce.GetRadius();

        bounce.velocity           = ((parallel * bounce.coefficientOfRestitution) - perpendicular);
        bounce.transform.position = (center + (bounce.velocity * timeOfImpact)) + (distance * perpendicular.normalized);
    }
Example #6
0
    private void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }

        //canDie = true;

        _startPos = transform.position;
        _animator = gameObject.GetComponent <Animator>();
    }
Example #7
0
    public void AddToScore(int playerNum)
    {
        // add to the player's score and restart the field of play for a new round

        Score [playerNum] += 1;

        UpdateScoreText(playerNum);

        ballBounce = Ball.GetComponent <BallBounce> ();
        ballBounce.GoToSpawn(playerNum == 1 ? 2 : 1);
        ballBounce.speed = ballBounce.StartSpeed;

        GetComponent <AudioSource>().Play();
    }
    private static void CollisionCheckPlane(int currentIndex)
    {
        BallBounce currentBounce = _ballBounces[currentIndex];

        for (int i = 0; i < _planes.Length; i++)
        {
            Plane currentPlane = _planes[i];
            float distance     = currentPlane.DistanceTo(currentBounce.transform.position) - currentBounce.GetRadius();
            if (distance < CollisionDistance)
            {
                ResolveCollisionPlane(currentBounce, currentPlane);
            }
        }
    }
Example #9
0
	public void AddToScore (int playerNum)
	{
		// add to the player's score and restart the field of play for a new round

		Score [playerNum] += 1;

		UpdateScoreText (playerNum);

		ballBounce = Ball.GetComponent<BallBounce> ();
		ballBounce.GoToSpawn (playerNum == 1 ? 2 : 1);
		ballBounce.speed = ballBounce.StartSpeed;

		GetComponent<AudioSource>().Play ();

	}
    private static void CollisionCheckSphere(int currentIndex)
    {
        BallBounce bounce1 = _ballBounces[currentIndex];
        float      radius1 = bounce1.GetRadius();
        Vector3    center1 = bounce1.transform.position;

        for (int i = currentIndex + 1; i < _ballBounces.Length; i++)
        {
            BallBounce bounce2  = _ballBounces[i];
            float      radius2  = bounce2.GetRadius();
            Vector3    center2  = bounce2.transform.position;
            float      distance = (center2 - center1).magnitude - (radius1 + radius2);

            if (distance < CollisionDistance)
            {
                ResolveCollisionSphere(bounce1, bounce2);
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.W))
        {
            transform.position += Vector3.forward;
        }
        if (Input.GetKey(KeyCode.S))
        {
            transform.position += Vector3.back;
        }
        if (Input.GetKey(KeyCode.A))
        {
            transform.position += Vector3.left;
        }
        if (Input.GetKey(KeyCode.D))
        {
            transform.position += Vector3.right;
        }
        if (Input.GetKey(KeyCode.Q))
        {
            transform.position += Vector3.up;
        }
        if (Input.GetKey(KeyCode.E))
        {
            transform.position += Vector3.down;
        }
        if (Input.GetKeyDown(KeyCode.Tab))
        {
            CollisionManager.SetCurrentSelectedBallBounce();
            if (!CollisionManager.isNoBallBounceSelected())
            {
                transform.LookAt(CollisionManager.GetCurrentSelectedBallBounce().transform);
            }
        }

        if (Input.GetKeyDown(KeyCode.Space) && !CollisionManager.isNoBallBounceSelected())
        {
            BallBounce current = CollisionManager.GetCurrentSelectedBallBounce();
            current.velocity += ((transform.forward).normalized) * 50;
        }
    }
    private static void ResolveCollisionSphere(BallBounce bounce1, BallBounce bounce2)
    {
        Vector3 velocity1      = bounce1.velocity;
        Vector3 velocity2      = bounce2.velocity;
        float   mass1          = bounce1.mass;
        float   mass2          = bounce2.mass;
        float   timeOfImpact   = SetTimeOfImpactPositionSphere(bounce1, bounce2);
        Vector3 center1        = bounce1.transform.position;
        Vector3 center2        = bounce2.transform.position;
        Vector3 normal         = ((center2 - center1).normalized);
        Vector3 parallel1      = Parallel(velocity1, normal);
        Vector3 parallel2      = Parallel(velocity2, normal);
        Vector3 perpendicular1 = Perpendicular(velocity1, normal);
        Vector3 perpendicular2 = Perpendicular(velocity2, normal);
        Vector3 v1             = ((mass1 - mass2) / (mass1 + mass2)) * parallel1 + ((2 * mass2) / (mass1 + mass2)) * parallel2;
        Vector3 v2             = ((mass2 - mass1) / (mass1 + mass2)) * parallel2 + ((2 * mass1) / (mass1 + mass2)) * parallel1;

        bounce1.velocity           = ((v1 * bounce1.coefficientOfRestitution) + perpendicular1.normalized);
        bounce2.velocity           = ((v2 * bounce2.coefficientOfRestitution) + perpendicular2.normalized);
        bounce1.transform.position = center1 + (bounce1.velocity * timeOfImpact);
        bounce2.transform.position = center2 + (bounce2.velocity * timeOfImpact);
    }
Example #13
0
    IEnumerator dumpValues()
    {
        runDump = false;


        //bool anothFish = false;
        float closestFish = 1000.0f;

        //m_Vehicles = GameObject.Find ("Container").gameObject.GetComponent<CellSpacePartition> ().getVehicles ();
        int i = 0;

        for (; i < m_Vehicles.Count; i++)
        {
            if (m_Vehicles[i].gameObject.GetComponent <BallBounce>().getFishNumber() == 1)
            {
                break;
            }
        }

        if (m_Vehicles [i].GetComponent <BallBounce> ().getFishNumber() == 1)
        {
            tempScript = m_Vehicles [i].GetComponent <BallBounce> ();

            float tempColdness = Vector3.Distance(m_Vehicles [i].transform.position, hotLight.transform.position);

            double tempHunger = (double)tempScript.getHunger();
            double tempLibido = (double)tempScript.getLibido();


            int   state = tempScript.getState();
            float closestGoldFishFloat = 1000.0f;


            float closestFishFloat    = 1000.0f;
            float closestDolphinFloat = 1000.0f;


            if (tempScript.getAmberjack())
            {
                ////Debug.Log ("Entered Loop!!!"); Working!!!
                for (int j = 0; j < m_WanderList.Count; j++)
                {
                    //    if (m_WanderList[j] != null) {
                    BallBounce tempState = m_WanderList [j].GetComponent <BallBounce> ();

                    if (tempState.getKoi())
                    {
                        //bool areEqual = System.Object.ReferenceEquals (m_Vehicles [i], m_WanderList [j]);
                        //if (!areEqual) {
                        float temp = Vector3.Distance(m_Vehicles [i].transform.position, m_WanderList [j].transform.position);
                        if (temp < closestFishFloat)
                        {
                            closestFishFloat = temp;
                        }
                    }                     //here


                    if (tempState.getAmberjack())
                    {
                        bool areEqual = System.Object.ReferenceEquals(m_Vehicles [i], m_WanderList [j]);
                        if (!areEqual)
                        {
                            float temp = Vector3.Distance(m_Vehicles [i].transform.position, m_WanderList [j].transform.position);
                            if (temp < closestDolphinFloat)
                            {
                                closestDolphinFloat = temp;
                            }
                        }
                    }                     //here
                }
            }

            //File.AppendAllText(fileName, "\n\n\nFish's Number: "  + tempScript.getFishNumber().ToString() + "\n");

            //GUI.Label (new Rect(40, 510, 300, 20), "Fish's Hunger Level: ");
            File.AppendAllText(fileName, "hunger:" + tempScript.getHunger().ToString() + "\n");
            //GUI.Label (new Rect(40, 530, 20, 20), eatValue);

            //libidoValue = variables[3];

            //GUI.Label (new Rect(40, 550, 300, 20), "Fish's Libido Level: ");
            File.AppendAllText(fileName, "libido:" + tempScript.getLibido().ToString() + "\n");
            //GUI.Label (new Rect(40, 570, 20,20), libidoValue);

            File.AppendAllText(fileName, "distPrey:" + closestFishFloat.ToString() + "\n");

            File.AppendAllText(fileName, "distMate:" + closestDolphinFloat.ToString() + "\n");

            File.AppendAllText(fileName, "state:" + tempScript.getState().ToString() + "\n");

            File.AppendAllText(fileName, "timer:" + tempScript.getTimer().ToString() + "\n");

            File.AppendAllText(fileName, "coldness:" + tempColdness.ToString() + "\n");



            yield return(new WaitForSeconds(1));

            runDump = true;
        }
    }
Example #14
0
    public void enterNumber(int i)
    {
        tempDouble = cell.getTempDouble();


        tempScript = m_Vehicles [i].GetComponent <BallBounce> ();

        /*
         * m_WanderList = GameObject.Find ("Container").gameObject.GetComponent<CellSpacePartition> ().getWanderList ();
         *
         * m_PlantList = GameObject.Find ("Container").gameObject.GetComponent<CellSpacePartition> ().getPlantList ();
         *
         * runDump = false;
         */
        /*
         * //bool anothFish = false;
         * float closestFish = 1000.0f;
         * //m_Vehicles = GameObject.Find ("Container").gameObject.GetComponent<CellSpacePartition> ().getVehicles ();
         * tempScript = m_Vehicles [i].GetComponent<BallBounce> ();
         *
         * double tempHunger = (double)tempScript.getHunger ();
         * double tempLibido = (double)tempScript.getLibido ();
         *
         *
         * int state = tempScript.getState ();
         * float closestGoldFishFloat = 1000.0f;
         *
         *
         * float closestFishFloat = 1000.0f;
         * float closestDolphinFloat = 1000.0f;
         *
         *
         * if (tempScript.getAmberjack ()) {
         * ////Debug.Log ("Entered Loop!!!"); Working!!!
         * for (int j = 0; j < m_WanderList.Count; j++) {
         *  //    if (m_WanderList[j] != null) {
         * BallBounce tempState = m_WanderList [i].GetComponent<BallBounce> ();
         *
         *  if (tempState.getKoi ()) {
         *      //bool areEqual = System.Object.ReferenceEquals (m_Vehicles [i], m_WanderList [j]);
         *      //if (!areEqual) {
         *  float temp = Vector3.Distance (m_Vehicles [i].transform.position, m_WanderList [j].transform.position);
         *      if (temp < closestFishFloat) {
         *          closestFishFloat = temp;
         *
         *      }
         *
         *  } //here
         *
         *
         *  if (tempState.getAmberjack ()) {
         *  bool areEqual = System.Object.ReferenceEquals (m_Vehicles [i], m_WanderList [j]);
         *      if (!areEqual) {
         *      float temp = Vector3.Distance (m_Vehicles [i].transform.position, m_WanderList [j].transform.position);
         *          if (temp < closestDolphinFloat) {
         *              closestDolphinFloat = temp;
         *
         *          }
         *      }
         *
         *  } //here
         *
         * }
         *
         *
         * //GoldFishPreyGO.gameObject.GetComponent<BallBounce> ().setAnotherFish (true);//you don"t need this because other fish"s state would be eat or mate, not wander.
         *
         * ////Debug.Log ("Closest Koi Prey: " + closestFishFloat);
         * ////Debug.Log ("Closest Dolphin Mate: " + closestDolphinFloat);
         * if(!cell.getFuzzifyInUse()) {
         * goThru = true;
         *
         * cell.setFuzzifyInUse(true);
         * domDictionary.Clear();
         * createDictionary = true;
         * globalDistance = closestFishFloat;
         * mateDistance = closestDolphinFloat;
         * tempDouble = cp.GetDesirability ((double)closestFishFloat, (double)closestDolphinFloat, tempHunger, tempLibido);
         * cell.setFuzzifyInUse(false);
         * createDictionary = false;
         *
         * }
         * else {
         * goThru = false;
         * }
         * ////Debug.Log ("Eat" + tempDouble [0]);
         * ////Debug.Log ("Mate" + tempDouble [1]);
         *
         * } //end state 4 and isDolphin == true
         * //bool anothFish = false;
         *
         * //dump values to file...
         *
         * if (goThru) {
         * BallBounce tempBallBounce = m_Vehicles [i].GetComponent<BallBounce> ();
         */

        //File.AppendAllText(fileName, "Time Intervale: " + counter.ToString() + "\n\n");

        File.AppendAllText(fileName, "\n\n\nFish's Number: " + tempScript.getFishNumber().ToString() + "\n");

        //GUI.Label (new Rect(40, 510, 300, 20), "Fish's Hunger Level: ");
        File.AppendAllText(fileName, "Fish's Hunger Level: " + tempScript.getHunger().ToString() + "\n");
        //GUI.Label (new Rect(40, 530, 20, 20), eatValue);

        //libidoValue = variables[3];

        //GUI.Label (new Rect(40, 550, 300, 20), "Fish's Libido Level: ");
        File.AppendAllText(fileName, "Fish's Libido Level: " + tempScript.getLibido().ToString() + "\n");
        //GUI.Label (new Rect(40, 570, 20,20), libidoValue);

        //File.AppendAllText(fileName, "Fish's Distance from Prey: " + globalDistance.ToString() + "\n");

        //File.AppendAllText(fileName, "Fish's Distance from Mate: " + mateDistance.ToString() + "\n\n");

        File.AppendAllText(fileName, "Fish's State: " + tempScript.getState().ToString() + "\n\n");


        ///////
        ///

        //GUI.Label (new Rect(40, 170, 300, 20), "Antecedents");
        File.AppendAllText(fileName, "\n\nAntecedents\n");
        //GUI.Label (new Rect (40, 190, 300, 20), "FLV DistToTarget");
        File.AppendAllText(fileName, "FLV DistToTarget\n");
        names[0] = "eTarget_Close";

        domDictionary.TryGetValue("eTarget_Close", out aNumber[0]);
        ////Debug.Log ("this is Fuzzy Set #1: " + aNumber[0]);
        tempNum[0] = aNumber[0].ToString();
        //Debug.Log ("eTargetClose" + aNumber[0]);
        //GUI.Label(new Rect(40, 210, 300, 20), "eTarget_Close: " + tempNum[0]);
        File.AppendAllText(fileName, "eTarget_Close: " + tempNum[0] + "\n");

        domDictionary.TryGetValue("eTarget_Medium", out aNumber[1]);

        tempNum[1] = aNumber[1].ToString();
        //Debug.Log ("eTargetMedium" + aNumber[1]);
        names[1] = "eTarget_Medium";

        //GUI.Label(new Rect(40, 230, 300, 20), "eTarget_Medium: " + tempNum[1]);
        File.AppendAllText(fileName, "eTarget_Medium: " + tempNum[1] + "\n");

        domDictionary.TryGetValue("eTarget_Far", out aNumber[2]);

        tempNum[2] = aNumber[2].ToString();
        ////Debug.Log ("this is Fuzzy Set #3: " + aNumber[2]);
        names[2] = "eTarget_Far";
        //Debug.Log ("eTargetFar" + aNumber[2]);
        //GUI.Label(new Rect(40, 250, 120, 20), "eTarget_Far: " + tempNum[2]);
        File.AppendAllText(fileName, "eTarget_Far: " + tempNum[2] + "\n\n");
        ////

        //GUI.Label(new Rect(40, 270, 300,20), "FLV DistToMate:");
        File.AppendAllText(fileName, "FLV DistToMate: " + "\n");

        domDictionary.TryGetValue("mTarget_Close", out aNumber[3]);

        tempNum[3] = aNumber[3].ToString();

        names[3] = "mTarget_Close";

        //GUI.Label(new Rect(40, 290, 300, 20), "mTarget_Close: " + tempNum[3]);
        File.AppendAllText(fileName, "mTarget_Close: " + tempNum[3] + "\n");

        domDictionary.TryGetValue("mTarget_Medium", out aNumber[4]);

        tempNum[4] = aNumber[4].ToString();

        names[4] = "mTarget_Medium";

        //GUI.Label(new Rect(40, 310, 300, 20), "mTarget_Medium: " + tempNum[4]);
        File.AppendAllText(fileName, "mTarget_Medium: " + tempNum[4] + "\n");

        domDictionary.TryGetValue("mTarget_Far", out aNumber[5]);

        tempNum[5] = aNumber[5].ToString();

        names[5] = "mTarget_Far";

        //GUI.Label(new Rect(40, 330, 300, 20), "mTarget_Far: " + tempNum[5]);
        File.AppendAllText(fileName, "mTarget_Far: " + tempNum[5] + "\n\n");

        ///////
        //GUI.Label(new Rect(40, 350, 120,20), "FLV Hunger:");
        File.AppendAllText(fileName, "FLV Hunger: \n");
        domDictionary.TryGetValue("VeryHungry", out aNumber[6]);

        tempNum[6] = aNumber[6].ToString();

        names[6] = "VeryHungry";

        //GUI.Label(new Rect(40, 370, 300, 20), "Very Hungry: " + tempNum[6]);
        File.AppendAllText(fileName, "Very Hungry: " + tempNum[6] + "\n");

        domDictionary.TryGetValue("Hungry", out aNumber[7]);

        tempNum[7] = aNumber[7].ToString();

        names[7] = "Hungry";

        //GUI.Label(new Rect(40, 390, 300, 20), "Hungry: " + tempNum[7]);
        File.AppendAllText(fileName, "Hungry: " + tempNum[7] + "\n");

        domDictionary.TryGetValue("NotHungry", out aNumber[8]);

        tempNum[8] = aNumber[8].ToString();

        names[8] = "NotHungry";

        //GUI.Label(new Rect(40, 410, 300, 20), "Not Hungry: " + tempNum[8]);
        File.AppendAllText(fileName, "Not Hungry: " + tempNum[8] + "\n\n");

        //////
        //GUI.Label(new Rect(40, 430, 300,20), "FLV Libido:");
        File.AppendAllText(fileName, "FLV Libido: " + "\n");
        domDictionary.TryGetValue("HighLibido", out aNumber[9]);

        tempNum[9] = aNumber[9].ToString();

        names[9] = "HighLibido";

        //GUI.Label(new Rect(40, 450, 300, 20), "High Libido: " + tempNum[9]);
        File.AppendAllText(fileName, "High Libido: " + tempNum[9] + "\n");

        domDictionary.TryGetValue("MediumLibido", out aNumber[10]);

        tempNum[10] = aNumber[10].ToString();

        names[10] = "MediumLibido";

        //GUI.Label(new Rect(40, 470, 300, 20), "Medium Libido: " + tempNum[10]);
        File.AppendAllText(fileName, "Medium Libido: " + tempNum[10] + "\n");

        domDictionary.TryGetValue("NoLibido", out aNumber[11]);

        tempNum[11] = aNumber[11].ToString();

        names[11] = "NoLibido";

        //GUI.Label(new Rect(40, 490, 300, 20), "No Libido: " + tempNum[11]);
        File.AppendAllText(fileName, "No Libido: " + tempNum[11] + "\n\n");

        /*
         * eatValue = variables[2];
         *
         * //GUI.Label (new Rect(40, 510, 300, 20), "Fish's Hunger Level: ");
         * File.AppendAllText(fileName, "Fish's Hunger Level: "  + eatValue + "\n");
         * //GUI.Label (new Rect(40, 530, 20, 20), eatValue);
         *
         * libidoValue = variables[3];
         *
         * //GUI.Label (new Rect(40, 550, 300, 20), "Fish's Libido Level: ");
         * File.AppendAllText(fileName, "Fish's Libido Level: " + libidoValue + "\n");
         * //GUI.Label (new Rect(40, 570, 20,20), libidoValue);
         *
         * File.AppendAllText(fileName, "Fish's Distance from Prey: " + variables[0] + "\n");
         *
         * File.AppendAllText(fileName, "Fish's Distance from Mate: " + variables[1] + "\n\n");
         */
        ////
        //GUI.Label(new Rect(350, 230, 300,20), "Consequents");
        File.AppendAllText(fileName, "Consequents:\n ");
        //GUI.Label(new Rect(350, 250, 300,20), "FVL Desirability to Eat");
        File.AppendAllText(fileName, "FLV Desirability to Eat: \n");
        domDictionary.TryGetValue("VeryDesirable", out aNumber[12]);

        tempNum[12] = aNumber[12].ToString();

        //GUI.Label(new Rect(350, 270, 300, 20), "Very Desirable: " + tempNum[12]);
        File.AppendAllText(fileName, "Very Desirable: " + tempNum[12] + "\n");

        domDictionary.TryGetValue("Desirable", out aNumber[13]);

        tempNum[13] = aNumber[13].ToString();

        //GUI.Label(new Rect(350, 290, 300, 20), "Desirable: " + tempNum[13]);
        File.AppendAllText(fileName, "Desirable: " + tempNum[13] + "\n");

        domDictionary.TryGetValue("Undesirable", out aNumber[14]);

        tempNum[14] = aNumber[14].ToString();

        //GUI.Label(new Rect(350, 310, 300, 20), "Undesirable: " + tempNum[14]);
        File.AppendAllText(fileName, "Undesirable: " + tempNum[14] + "\n\n");

        //GUI.Label(new Rect(350, 330, 300,20), "FVL Desirability to Mate");
        File.AppendAllText(fileName, "FLV Desirability to Mate: \n");

        domDictionary.TryGetValue("HighSex", out aNumber[15]);

        tempNum[15] = aNumber[15].ToString();

        //GUI.Label(new Rect(350, 350, 300, 20), "HighSex: " + tempNum[15]);
        File.AppendAllText(fileName, "HighSex: " + tempNum[15] + "\n");

        domDictionary.TryGetValue("MediumSex", out aNumber[16]);

        tempNum[16] = aNumber[16].ToString();

        //GUI.Label(new Rect(350, 370, 300, 20), "MediumSex: " + tempNum[16]);
        File.AppendAllText(fileName, "MediumSex: " + tempNum[16] + "\n");

        domDictionary.TryGetValue("NoSex", out aNumber[17]);

        tempNum[17] = aNumber[17].ToString();

        //GUI.Label(new Rect(350, 390, 300, 20), "NoSex: " + tempNum[17]);
        File.AppendAllText(fileName, "NoSex: " + tempNum[17] + "\n\n");

        //GUI.Label(new Rect(650, 310, 300, 20), "Dufuzzified Crisp Values");
        File.AppendAllText(fileName, "Defuzzified Crisp Values \n");
        //GUI.Label(new Rect(650, 330, 300, 20), "Desirability to Eat: " + tempDouble[0].ToString());
        File.AppendAllText(fileName, "Desirability to Eat: " + tempDouble[0].ToString() + "\n");
        //GUI.Label(new Rect(650, 350, 300, 20), "Desirability to Mate: " + tempDouble[1].ToString());
        File.AppendAllText(fileName, "Desirability to Mate: " + tempDouble[1].ToString() + "\n\n");

        dist = 0.0d;
        key  = -1;

        for (int y = 0; y < 3; y++)
        {
            if (aNumber[y] > dist)
            {
                dist = aNumber[y];
                key  = y;
            }
        }

        string s1 = names[key];

        dist = 0.0d;
        key  = -1;

        for (int j = 3; j < 6; j++)
        {
            if (aNumber[j] > dist)
            {
                dist = aNumber[j];
                key  = j;
            }
        }

        string s2 = names[key];

        dist = 0.0d;
        key  = -1;

        for (int q = 6; q < 9; q++)           //this is working!!!
        {
            if (aNumber[q] > dist)
            {
                dist = aNumber[q];
                key  = q;
            }
        }

        string s3 = names[key];

        dist = 0.0d;
        key  = -1;

        for (int f = 9; f < 12; f++)          //this is working!!!
        {
            if (aNumber[f] > dist)
            {
                dist = aNumber[f];
                key  = f;
            }
        }

        string s4 = names[key];

        string firstRule = s1 + ", " + s3 + ", " + s4;

        string secondRule = s2 + ", " + s3 + ", " + s4;

        firstRule.Trim();
        secondRule.Trim();



        consequentDictionary.TryGetValue(firstRule, out outcome[0]);
        consequentDictionary.TryGetValue(secondRule, out outcome[1]);

        ////Debug.Log (outcome[0] + " + " + outcome[1]);
        //GUI.Label (new Rect(950, 330, 300, 20), "Fuzzy Rules");
        File.AppendAllText(fileName, "Fuzzy Rules \n");
        //GUI.Label (new Rect(950, 350, 300, 20), "Desire to Eat:");
        File.AppendAllText(fileName, "Desire to Eat: \n");
        //GUI.Label (new Rect(950, 370, 300, 20), firstRule);
        File.AppendAllText(fileName, firstRule + "\n");
        //GUI.Label (new Rect(950, 390, 300, 20), "= " + outcome[0]);
        File.AppendAllText(fileName, "= " + outcome[0] + "\n");
        //GUI.Label (new Rect(950, 410, 300, 20), "Desire to Mate:");
        File.AppendAllText(fileName, "Desire to Mate: \n");
        //GUI.Label (new Rect(950, 430, 300, 20), secondRule);
        File.AppendAllText(fileName, secondRule + "\n");
        //GUI.Label (new Rect(950, 450, 300, 20), "= " + outcome[1]);
        File.AppendAllText(fileName, "= " + outcome[1] + "\n");


        //showFL = false;
        //createDictionary = false;
        //}

        /*
         * yield return new WaitForSeconds (1);
         * runDump = true;
         * if (goThru) {
         * counter++;
         * }
         */
    }     // end enterNumber
Example #15
0
 private void Start()
 {
     _ballBounce = FindObjectOfType <BallBounce>();
 }