Exemple #1
0
 public override void getPosition(PositionRecorder recorder)
 {
     if (codec == null)
     {
         recorder.addPosition(uncompressedBytes);
     }
     else
     {
         recorder.addPosition(compressedBytes);
         recorder.addPosition(uncompressedBytes);
     }
 }
Exemple #2
0
    public void MoveCaster()
    {
        CreationReferences references = GetComponent <CreationReferences>();

        if (references && references.creator)
        {
            PositionRecorder recorder = references.creator.GetComponent <PositionRecorder>();
            if (recorder)
            {
                UsingAbility ua = references.creator.GetComponent <UsingAbility>();
                if (ua)
                {
                    if (ua.getController().currentState == ua.getController().dying)
                    {
                        return;
                    }

                    if (ua.movementFromAbility && ua.movementFromAbility.moving)
                    {
                        ua.movementFromAbility.onReachingDestination();
                    }

                    StateController controller = ua.getController();
                    if (controller)
                    {
                        controller.forceChangeState(controller.waiting);
                    }
                }

                Vector3 newPosition = recorder.getPositionFromDuration(positionAge);
                references.creator.transform.eulerAngles = recorder.getAngleFromDuration(positionAge);
                references.creator.transform.position    = newPosition;

                if (restoreHealth && recorder.health)
                {
                    recorder.health.currentHealth = Mathf.Clamp(recorder.getHealthFromDuration(positionAge + additionalAgeForHealthRestoration), 1f, recorder.health.maxHealth);
                }

                if (restoreMana && recorder.mana)
                {
                    recorder.mana.currentMana = Mathf.Min(recorder.getManaFromDuration(positionAge + additionalAgeForManaRestoration), recorder.mana.maxMana);
                }
            }
        }
    }
Exemple #3
0
 public void getPosition(PositionRecorder recorder)
 {
     output.getPosition(recorder);
     recorder.addPosition(8 - bitsLeft);
 }
Exemple #4
0
 public void getPosition(PositionRecorder recorder)
 {
     output.getPosition(recorder);
     recorder.addPosition(numLiterals);
 }
 public override void recordPosition(PositionRecorder recorder)
 {
     base.recordPosition(recorder);
     tags.getPosition(recorder);
 }
 /**
  * Record the current position in each of this column's streams.
  * @param recorder where should the locations be recorded
  * @
  */
 public virtual void recordPosition(PositionRecorder recorder)
 {
     if (isPresent != null)
     {
         isPresent.getPosition(recorder);
     }
 }
 public override void recordPosition(PositionRecorder recorder)
 {
     base.recordPosition(recorder);
     seconds.getPosition(recorder);
     nanos.getPosition(recorder);
 }
 public override void recordPosition(PositionRecorder recorder)
 {
     base.recordPosition(recorder);
     valueStream.getPosition(recorder);
     scaleStream.getPosition(recorder);
 }
 public override void recordPosition(PositionRecorder recorder)
 {
     base.recordPosition(recorder);
     stream.getPosition(recorder);
     length.getPosition(recorder);
 }
Exemple #10
0
 public override void getPosition(PositionRecorder recorder)
 {
     if (codec == null)
     {
         recorder.addPosition(uncompressedBytes);
     }
     else
     {
         recorder.addPosition(compressedBytes);
         recorder.addPosition(uncompressedBytes);
     }
 }
 public void getPosition(PositionRecorder recorder)
 {
     output.getPosition(recorder);
     recorder.addPosition(numLiterals);
 }
Exemple #12
0
 // Start is called before the first frame update
 void Start()
 {
     positionRecorder = gameObject.GetComponent <PositionRecorder>();
 }
 /// <summary>
 /// Record the current position to the recorder.
 /// </summary>
 /// <param name="recorder">the object that receives the position</param>
 public abstract void getPosition(PositionRecorder recorder);
    // =======================================
    void Awake()
    {
        // Sensor data

        /**
         * x
         * y
         * health_percent
         * Can shoot
         * forward_x
         * forward_y
         *
         * eye_active
         * eye_x
         * eye_y
         *  .
         *  . drive by eyeCount
         *  .
         * hit_from_active
         * hit_from_x
         * hit_from_y
         */
        this.eyes = new Vector3[this.eyeCount];

        this.sensorBuffer = new NameIndexedBuffer();

        this.sensorBuffer.AddIndex("time", 1);
        this.sensorBuffer.AddIndex("position", 2);
        this.sensorBuffer.AddIndex("health", 1);
        this.sensorBuffer.AddIndex("shoot_time", 1);
        this.sensorBuffer.AddIndex("forward", 2);

        for (int i = 0; i < this.eyeCount; i++)
        {
            this.sensorBuffer.AddIndex($"eye_{i}", 3);
        }

        this.sensorBuffer.AddIndex("hit_from", 3);

        // Reaction data

        /**
         * forward
         * backwards
         * turn left
         * turn right
         * shoot
         */
        this.reaction = new float[5];

        this.brain = BrainFactory.Create()
                     .WithInput(this.sensorBuffer.size)
                     .WithLayer(16, LayerType.Tanh)
                     .WithLayer(8, LayerType.Tanh)
                     .WithLayer(this.reaction.Length, LayerType.Sigmoid)
                     .WithWeightBiasAmplitude(10f)
                     .Build();

        this.physics          = GetComponent <Rigidbody>();
        this.positionRecorder = GetComponent <PositionRecorder>();
        this.lookToFriend     = new FloatRecorder();
        this.lookToFoe        = new FloatRecorder();
    }
Exemple #15
0
 /// <summary>
 /// Record the current position to the recorder.
 /// </summary>
 /// <param name="recorder">the object that receives the position</param>
 abstract public void getPosition(PositionRecorder recorder);
Exemple #16
0
    void writeArraysToJSON()
    {
        PositionRecorder positionRecorder = gameObject.GetComponent <PositionRecorder>();

        InstantPosition[] instantPosition = new InstantPosition[(int)(Settings.duration * Settings.FPS)];

        for (int i = 0; i < (int)(Settings.duration * Settings.FPS); i++)
        {
            float time = (float)i / (float)Settings.FPS;
            var   vec  = positionRecorder.getPositionForTime(time);
            vec = rotateAxis(vec);

            instantPosition[i]      = new InstantPosition();
            instantPosition[i].time = time;
            instantPosition[i].x    = vec.x;
            instantPosition[i].y    = vec.y;
            instantPosition[i].z    = vec.z;

            objectName = gameObject.name;
        }

        Debug.Log("JSONWriter works up to here");

        //Convert to JSON
        string instantPositionToJson = JsonHelper.ToJson(instantPosition, true);

        string pathString = System.IO.Path.Combine(Application.dataPath, "JSONFiles");

        Debug.Log(pathString);

        // You can extend the depth of your path if you want to.
        //pathString = System.IO.Path.Combine(pathString, "SubSubFolder");

        // Create the subfolder. You can verify in File Explorer that you have this
        // structure in the C: drive.
        //    Local Disk (C:)
        //        Top-Level Folder
        //            SubFolder
        System.IO.Directory.CreateDirectory(pathString);

        // Create a file name for the file you want to create.
        objectName += ".json";

        // This example uses a random string for the name, but you also can specify
        // a particular name.
        //string fileName = "MyNewFile.txt";

        // Use Combine again to add the file name to the path.
        pathString = System.IO.Path.Combine(pathString, objectName);

        // Verify the path that you have constructed.
        Console.WriteLine("Path to my file: {0}\n", pathString);

        // Check that the file doesn't already exist. If it doesn't exist, create
        // the file and write the JSON.
        // DANGER: System.IO.File.Create will overwrite the file if it already exists.
        // This could happen even with random file names, although it is unlikely.
        if (!System.IO.File.Exists(pathString))
        {
            StreamWriter sr = File.CreateText(pathString);
            sr.WriteLine(instantPositionToJson);
            sr.Close();
        }
        else
        {
            Console.WriteLine("File \"{0}\" already exists.", objectName);
            return;
        }
    }