Ejemplo n.º 1
0
 void Start()
 {
     delta          = data.Float(delta);
     speed          = data.Float(speed);
     startPos       = data.Vector3(startPos);
     startPos.Value = target.transform.position;
 }
 // Start is called before the first frame update
 void Start()
 {
     player           = GetComponent <CharacterController>();
     dataSpeed        = data.Float(dataSpeed);
     dataAcceleration = data.Float(dataAcceleration);
     dataInput        = data.Vector3(dataInput);
 }
Ejemplo n.º 3
0
 public override void Start(Data data)
 {
     if (data.Has(dataNode))
     {
         dataNode = data.GetFloat(dataNode.Name);
     }
     else
     {
         data.Add(dataNode);
     }
 }
Ejemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        float dt = Time.deltaTime;

        transform.Translate(0, speed.Value * dt, 0);

        lifeTime -= dt;
        if (lifeTime.Value < 0)
        {
            Destroy(gameObject);
        }
    }
Ejemplo n.º 5
0
    public override void Update()
    {
        //if (active == true)
        //{
        bool currentlyPressedPositive = Input.GetKey(positive);
        bool currentlyPressedNegative = Input.GetKey(negative);

        onPositiveKeyDown = false;
        onPositiveKey     = false;
        onPositiveKeyUp   = false;
        onNegativeKeyDown = false;
        onNegativeKey     = false;
        onNegativeKeyUp   = false;

        if (currentlyPressedPositive && !pressedPositive)
        {
            onPositiveKeyDown = true;
        }
        else if (currentlyPressedPositive && pressedPositive)
        {
            onPositiveKey = true;
        }
        else if (!currentlyPressedPositive && pressedPositive)
        {
            onPositiveKeyUp = true;
        }
        else if (currentlyPressedNegative && !pressedNegative)
        {
            onNegativeKeyDown = true;
        }
        else if (currentlyPressedNegative && pressedNegative)
        {
            onNegativeKey = true;
        }
        else if (!currentlyPressedNegative && pressedNegative)
        {
            onNegativeKeyUp = true;
        }

        dataNode.Value = 0;
        if (currentlyPressedPositive)
        {
            dataNode += 1;
        }
        if (currentlyPressedNegative)
        {
            dataNode -= 1;
        }

        pressedPositive = currentlyPressedPositive;
        pressedNegative = currentlyPressedNegative;
        //}
    }
Ejemplo n.º 6
0
        private DataFloat[] CreateFloatCbAdfData(int numSamples, int randomSeed = 0)
        {
            var random = new Random(randomSeed);

            var sampleData = new DataFloat[numSamples];

            for (int i = 0; i < numSamples; i++)
            {
                int numActions = random.Next(2, 5);

                int[] fIndex = Enumerable.Range(1, numActions).OrderBy(ind => random.Next()).Take(numActions).ToArray();

                var features = new float[numActions][];
                for (int j = 0; j < numActions; j++)
                {
                    features[j] = new float[]
                    {
                        (fIndex[j] + 0) / (float)numActions,
                        (fIndex[j] + 1) / (float)numActions,
                        (fIndex[j] + 2) / (float)numActions,
                        (fIndex[j] + 3) / (float)numActions
                    };
                }

                var adf = new DataFloatADF[numActions];

                int labelIndex = random.Next(-1, numActions);

                for (int j = 0; j < numActions; j++)
                {
                    adf[j] = new DataFloatADF {
                        Features = features[j]
                    };

                    if (j == labelIndex)
                    {
                        adf[j].Label = new ContextualBanditLabel
                        {
                            Cost        = (float)random.NextDouble(),
                            Probability = (float)random.NextDouble()
                        };
                    }
                }

                sampleData[i] = new DataFloat
                {
                    ActionDependentFeatures = adf
                };
            }

            return(sampleData);
        }
Ejemplo n.º 7
0
    public DataFloat Float(DataFloat node)
    {
        DataFloat found = floats.Find(d => d.Name == node.Name);

        if (found != null)
        {
            return(found);
        }
        else
        {
            floats.Add(node);
        }
        return(node);
    }
Ejemplo n.º 8
0
    // Start is called before the first frame update
    void Start()
    {
        desiredSeparation = data.Float(desiredSeparation);
        neibourDistance   = data.Float(neibourDistance);
        maxForce          = data.Float(maxForce);
        maxSpeed          = data.Float(maxSpeed);
        velocity          = data.Vector3(velocity);
        acceleration      = data.Vector3(acceleration);

        float angle = Random.Range(0, Mathf.PI * 2);

        velocity.Value     = new Vector3(Mathf.Cos(angle), Mathf.Sin(angle));
        acceleration.Value = Vector3.zero;
    }
Ejemplo n.º 9
0
    private void DrawFloatElement(Rect rect, int index, bool active, bool focused)
    {
        DataFloat node = data.Floats[index];

        EditorGUI.BeginChangeCheck();

        node.Name = EditorGUI.TextField(new Rect(rect.x, rect.y, rect.width / 3, rect.height - 1), node.Name);

        node.Value = EditorGUI.FloatField(new Rect(rect.x + rect.width / 3 + 8, rect.y, rect.width / 1.5f - 16, rect.height - 1), node.Value);

        if (EditorGUI.EndChangeCheck())
        {
            EditorUtility.SetDirty(target);
        }
    }
Ejemplo n.º 10
0
    public override void Update()
    {
        if (active == true)
        {
            bool currentlyPressedPositive = Input.GetKey(positive);
            bool currentlyPressedNegative = Input.GetKey(negative);

            if (currentlyPressedPositive && !pressedPositive)
            {
                onPositiveKeyDown.Invoke();
            }
            else if (currentlyPressedPositive && pressedPositive)
            {
                onPositiveKey.Invoke();
            }
            else if (!currentlyPressedPositive && pressedPositive)
            {
                onPositiveKeyUp.Invoke();
            }
            else if (currentlyPressedNegative && !pressedNegative)
            {
                onNegativeKeyDown.Invoke();
            }
            else if (currentlyPressedNegative && pressedNegative)
            {
                onNegativeKey.Invoke();
            }
            else if (!currentlyPressedNegative && pressedNegative)
            {
                onNegativeKeyUp.Invoke();
            }

            dataNode.Value = 0;
            if (currentlyPressedPositive)
            {
                dataNode += 1;
            }
            if (currentlyPressedNegative)
            {
                dataNode -= 1;
            }

            pressedPositive = currentlyPressedPositive;
            pressedNegative = currentlyPressedNegative;
        }
    }
Ejemplo n.º 11
0
 // Update is called once per frame
 void Update()
 {
     timer             += Time.deltaTime;
     bulletTimer.Value -= Time.deltaTime;
     if (Input.GetKeyDown(KeyCode.Space))
     {
         if (bulletTimer.Value < 0)
         {
             Debug.Log("Fire");
             bulletTimer.Value = bulletCoolDown.Value;
             Instantiate(bullet, gun.position, gun.transform.rotation);
             gParticle.transform.position = gun.position;
             gParticle.Play();
         }
     }
     if (timer.Value > 2f)
     {
         score         += 100;
         countText.text = score.ToString();
         timer.Value    = 0;
     }
 }
    IEnumerator Start()
    {
        dataNode       = data.Vector2(dataNode);
        reactionRadius = data.Float(reactionRadius);

        while (true)
        {
            if (target != null)
            {
                reactionRadius.Value = 5;
                float d = Vector2.Distance(transform.position, target.transform.position);

                if (d < reactionRadius.Value)
                {
                    dataNode.Value = (target.transform.position - transform.position).normalized;
                }
                if (d > reactionRadius.Value)
                {
                    // int direction = 1 + (int)(2.99f * Mathf.PerlinNoise(counter.Value++ * 0.2f, 0.5f));
                    int direction = Random.Range(1, 4);
                    switch (direction)
                    {
                    case 1:
                        dataNode.Value = (targetIdleA.transform.position - transform.position).normalized;
                        break;

                    case 2:
                        dataNode.Value = (targetIdleB.transform.position - transform.position).normalized;
                        break;

                    case 3:
                        dataNode.Value = (targetIdleC.transform.position - transform.position).normalized;
                        break;
                    }
                }
            }
            yield return(new WaitForSeconds(0.8f));
        }
    }
Ejemplo n.º 13
0
    // Start is called before the first frame update
    void Start()
    {
        data       = GetComponent <Data>();
        rigidbody_ = GetComponent <Rigidbody2D>();

        Condition     = data.Bool(Condition);
        dataFloat     = data.Float(dataFloat);
        dataDirection = data.Float(dataDirection);

        //for (int i = dataBools.Count - 1; i >= 0; i--)
        //{
        //    dataBools[i] = data.Bool(dataBools[i]);
        //}

        //for (int i = dataInts.Count - 1; i >= 0; i--)
        //{
        //    dataInts[i] = data.Int(dataInts[i]);
        //}

        //for (int i = dataFloats.Count - 1; i >= 0; i--)
        //{
        //    dataFloats[i] = data.Float(dataFloats[i]);
        //}
    }
Ejemplo n.º 14
0
 public void Add(DataFloat data)
 {
     floats.Add(data);
 }
Ejemplo n.º 15
0
 public bool Has(DataFloat data)
 {
     return(floats.Find(d => d.Name == data.Name) != null);
 }
Ejemplo n.º 16
0
 // Start is called before the first frame update
 void Start()
 {
     dataSpeed        = data.Float(dataSpeed);
     dataAcceleration = data.Float(dataAcceleration);
     dataInput        = data.Vector2(dataInput);
 }
Ejemplo n.º 17
0
        private DataFloat[] CreateFloatCbAdfData(int numSamples, int randomSeed = 0)
        {
            var random = new Random(randomSeed);

            var sampleData = new DataFloat[numSamples];
            for (int i = 0; i < numSamples; i++)
            {
                int numActions = random.Next(2, 5);

                int[] fIndex = Enumerable.Range(1, numActions).OrderBy(ind => random.Next()).Take(numActions).ToArray();

                var features = new float[numActions][];
                for (int j = 0; j < numActions; j++)
                {
                    features[j] = new float[]
                    {
                        (fIndex[j] + 0) / (float)numActions,
                        (fIndex[j] + 1) / (float)numActions,
                        (fIndex[j] + 2) / (float)numActions,
                        (fIndex[j] + 3) / (float)numActions
                    };
                }

                var adf = new DataFloatADF[numActions];

                for (int j = 0; j < numActions; j++)
                {
                    adf[j] = new DataFloatADF { Features = features[j] };
                }

                sampleData[i] = new DataFloat
                {
                    ActionDependentFeatures = adf,
                    SelectedActionIndex = random.Next(-1, numActions),
                    Label = new ContextualBanditLabel
                    {
                        Cost = (float)random.NextDouble(),
                        Probability = (float)random.NextDouble()
                    }
                };
            }

            return sampleData;
        }
Ejemplo n.º 18
0
 // Start is called before the first frame update
 void Start()
 {
     bulletTimer    = data.Float(bulletTimer);
     bulletCoolDown = data.Float(bulletCoolDown);
     timer          = data.Float(timer);
 }
 private void Start()
 {
     m_bulletTimer    = data.Float(m_bulletTimer);
     m_bulletCoolDown = data.Float(m_bulletCoolDown);
     m_speed          = data.Float(m_speed);
 }
Ejemplo n.º 20
0
 // Use this for initialization
 void Start()
 {
     speed    = data.Float(speed);
     lifeTime = data.Float(lifeTime);
 }
Ejemplo n.º 21
0
        public static System.Single SolveFloat(long timesteps, DataFloat data)
        {
            //Convenience indices
            R RN  = R.El(data.N);          //Same as [n]
            R RN1 = R.El(data.N + 1);      //Same as [n+1]

            System.Single g       = 9.8f;  // gravitational constant
            System.Single dt      = 0.02f; // hardwired timestep
            System.Single dx      = 1.0f;
            System.Single dy      = 1.0f;
            long          droploc = data.N / 4;

            var H  = data.H;
            var U  = data.U;
            var V  = data.V;
            var Hx = data.Hx;
            var Ux = data.Ux;
            var Vx = data.Vx;
            var Hy = data.Hy;
            var Uy = data.Uy;
            var Vy = data.Vy;

            //Splash!!!
            H[droploc, droploc] += 5.0f;

            for (int i = 0; i < timesteps; i++)
            {
                H.Flush();
                // Reflecting boundary conditions
                H[ALL, FIRST] = H[ALL, SECOND];
                U[ALL, FIRST] = U[ALL, SECOND];
                V[ALL, FIRST] = -V[ALL, SECOND];
                H[ALL, RN1]   = H[ALL, RN];
                U[ALL, RN1]   = U[ALL, RN];
                V[ALL, RN1]   = -V[ALL, RN];
                H[FIRST, ALL] = H[SECOND, ALL];
                U[FIRST, ALL] = -U[SECOND, ALL];
                V[FIRST, ALL] = V[SECOND, ALL];
                H[RN1, ALL]   = H[RN, ALL];
                U[RN1, ALL]   = -U[RN, ALL];
                V[RN1, ALL]   = V[RN, ALL];

                //First half-step

                //Height
                Hx[ALL, R.Slice(0, -1)] = (H[SKIP1, INNER] + H[ZM1, INNER]) / 2 -
                                          dt / (2 * dx) * (U[SKIP1, INNER] - U[ZM1, INNER]);

                //x momentum
                Ux[ALL, R.Slice(0, -1)] = (U[SKIP1, INNER] + U[ZM1, INNER]) / 2 -
                                          dt / (2 * dx) * ((U[SKIP1, INNER].Pow(2) / H[SKIP1, INNER] +
                                                            g / 2 * H[SKIP1, INNER].Pow(2)) -
                                                           (U[ZM1, INNER].Pow(2) / H[ZM1, INNER] +
                                                            g / 2 * H[ZM1, INNER].Pow(2)));

                // y momentum
                Vx[ALL, ZM1] = (V[SKIP1, INNER] + V[ZM1, INNER]) / 2 -
                               dt / (2 * dx) * ((U[SKIP1, INNER] *
                                                 V[SKIP1, INNER] / H[SKIP1, INNER]) -
                                                (U[ZM1, INNER] *
                                                 V[ZM1, INNER] / H[ZM1, INNER]));



                // height
                Hy[ZM1, ALL] = (H[INNER, SKIP1] + H[INNER, ZM1]) / 2 -
                               dt / (2 * dy) * (V[INNER, SKIP1] - V[INNER, ZM1]);

                // x momentum
                Uy[ZM1, ALL] = (U[INNER, SKIP1] + U[INNER, ZM1]) / 2 -
                               dt / (2 * dy) * ((V[INNER, SKIP1] *
                                                 U[INNER, SKIP1] / H[INNER, SKIP1]) -
                                                (V[INNER, ZM1] *
                                                 U[INNER, ZM1] / H[INNER, ZM1]));
                // y momentum
                Vy[ZM1, ALL] = (V[INNER, SKIP1] + V[INNER, ZM1]) / 2 -
                               dt / (2 * dy) * ((V[INNER, SKIP1].Pow(2) / H[INNER, SKIP1] +
                                                 g / 2 * H[INNER, SKIP1].Pow(2)) -
                                                (V[INNER, ZM1].Pow(2) / H[INNER, ZM1] +
                                                 g / 2 * H[INNER, ZM1].Pow(2)));

                // Second half step

                // height
                H[INNER, INNER] = H[INNER, INNER] -
                                  (dt / dx) * (Ux[SKIP1, ZM1] - Ux[ZM1, ZM1]) -
                                  (dt / dy) * (Vy[ZM1, SKIP1] - Vy[ZM1, ZM1]);

                // x momentum
                U[INNER, INNER] = U[INNER, INNER] -
                                  (dt / dx) * ((Ux[SKIP1, ZM1].Pow(2) / Hx[SKIP1, ZM1] +
                                                g / 2 * Hx[SKIP1, ZM1].Pow(2)) -
                                               (Ux[ZM1, ZM1].Pow(2) / Hx[ZM1, ZM1] +
                                                g / 2 * Hx[ZM1, ZM1].Pow(2))) -
                                  (dt / dy) * ((Vy[ZM1, SKIP1] *
                                                Uy[ZM1, SKIP1] / Hy[ZM1, SKIP1]) -
                                               (Vy[ZM1, ZM1] *
                                                Uy[ZM1, ZM1] / Hy[ZM1, ZM1]));
                // y momentum
                V[R.Slice(1, -1), R.Slice(1, -1)] = V[R.Slice(1, -1), R.Slice(1, -1)] -
                                                    (dt / dx) * ((Ux[SKIP1, ZM1] *
                                                                  Vx[SKIP1, ZM1] / Hx[SKIP1, ZM1]) -
                                                                 (Ux[ZM1, ZM1] * Vx[ZM1, ZM1] / Hx[ZM1, ZM1])) -
                                                    (dt / dy) * ((Vy[ZM1, SKIP1].Pow(2) / Hy[ZM1, SKIP1] +
                                                                  g / 2 * Hy[ZM1, SKIP1].Pow(2)) -
                                                                 (Vy[ZM1, ZM1].Pow(2) / Hy[ZM1, ZM1] +
                                                                  g / 2 * Hy[ZM1, ZM1].Pow(2)));
            }
            //Make sure we have the actual data and use it as a checksum
            return(NumCIL.Float.Add.Reduce(NumCIL.Float.Add.Reduce(H / data.N)).Value[0]);
        }
Ejemplo n.º 22
0
 public void GetData()
 {
     RigidBody     = GetComponent <Rigidbody2D>();
     RB2DTrigger   = GetComponent <Rigidbody2DTrigger>();
     MovementInput = data.GetFloat(MovementInputNode);
 }
Ejemplo n.º 23
0
    // Use this for initialization
    void Start()
    {
        JumpInput = data.Float(JumpInput);

        shootDelay = true;
    }
Ejemplo n.º 24
0
 public void Initialize(Data data_)
 {
     datum = data_.Float(datum);
 }