// Update is called once per frame
    void FixedUpdate()
    {
        if (activate)
        {
            brain.inputLayers[0] = boardPhysics.velocity.x;
            brain.inputLayers[1] = Mathf.Deg2Rad * polePhysics.transform.eulerAngles.z;
            brain.inputLayers[2] = polePhysics.angularVelocity;
            //brain.inputLayers[3] = (transform.position.x)/10f;
            //brain.inputLayers[4] = polePhysics.transform.localPosition.x;
            brain.ping();


            float speed = brain.outputLayers[0];
            boardPhysics.velocity += new Vector2(speed, 0);
            float angle  = polePhysics.transform.eulerAngles.z;
            bool  failed = false;

            if ((angle <= 45 && angle >= 0) || (angle <= 360 && angle >= 315))
            {
                failed = false;
            }
            else
            {
                failed = true;
            }



            //polePhysics.transform.localPosition -= new Vector3(polePhysics.transform.localPosition.x, 0,0);


            if ((failed || polePhysics.transform.position.y <= 0) && testMode == false)
            {
                Finish();
            }

            /*if ((failed || polePhysics.transform.position.y <= 0 || transform.position.x>=4f || transform.position.x <= -4f) && testMode == false)
             * {
             *  Finish();
             * }*/

            if (Mathf.Abs(transform.position.x) >= 4f)
            {
                fitTick += (Time.deltaTime / 2f);
            }
            else
            {
                fitTick += Time.deltaTime;
            }
        }
    }
    void Update()
    {
        if (activate)
        {
            transform.position += transform.up * Time.deltaTime * 0.5f;

            brain.inputLayers[0] = Vector3.Distance(pos1.transform.position, food.position);
            brain.inputLayers[1] = Vector3.Distance(pos2.transform.position, food.position);
            brain.ping();


            float out1 = brain.outputLayers[0];
            float out2 = brain.outputLayers[1];
            //Debug.Log(out1+" "+out2);
            if (out1 > out2)
            {
                transform.eulerAngles += new Vector3(0, 0, -1f);
            }
            else if (out2 > out1)
            {
                transform.eulerAngles += new Vector3(0, 0, 1f);
            }
        }
    }