示例#1
0
    public static void Main()
    {
        var ic = new IntContainer(3);

        F(ic);
        F(null);
    }
示例#2
0
    public static void Main(string[] args)
    {
        var container = new IntContainer();

        container.Contents = 42;
        Print(ref container.Contents);
    }
示例#3
0
    public void setResolution(IntContainer resolutionIndex)
    {
        Resolution resolution = resolutions[resolutionIndex.Value];

        Screen.SetResolution(resolution.width, resolution.height, Screen.fullScreen);
        Debug.Log("Resolution Changed " + resolution.width + "x" + resolution.height);
    }
示例#4
0
    public static void F(IntContainer x)
    {
        IntContainer ic;

        ic = x ?? new IntContainer(4);
        // ic = x != null ? x : new IntContainer(4);
        Contract.Assert(ic != null);
        Contract.Assert(x == null ? ic.val == 4 : ic.val == x.val);
    }
示例#5
0
        private IEnumerator ProcessGeneration()
        {
            int xSize = (int)Math.Sqrt(Population);

            var finishedCount = new IntContainer();

            var prefabInstances = new List <GameObject>();
            var testInterfaces  = new List <IPIDTunerTestInterface>();

            for (int i = 0; i < Population; i++)
            {
                int xPos = i % xSize;
                int yPos = i / xSize;

                float3 prefabPos = _testSize * new float3(xPos, 0.0f, yPos);

                var prefabInstance = GameObject.Instantiate(TestPrefab, prefabPos, Quaternion.identity);
                prefabInstances.Add(prefabInstance);
                var testInterface = prefabInstance.GetComponentInChildren <IPIDTunerTestInterface>();
                var requs         = testInterface.GetTestRequirements();

                var geneticIndividual = _geneticTuner.CurrentPopulation[i];

                for (int j = 0; j < requs.Controllers.Count; j++)
                {
                    requs.Controllers[j].Controller.CopyFrom(geneticIndividual.ControllerGeneticData[j]);
                }

                var incrementer = new CounterIncrementer(finishedCount);
                testInterface.ProvideOnFinished(incrementer.Trigger());
                testInterface.OnStartTest();
                testInterfaces.Add(testInterface);
            }

            float[] accumulatedError = new float[Population];

            while (finishedCount.Value < Population)
            {
                //Accumualte error
                for (int i = 0; i < Population; i++)
                {
                    accumulatedError[i] += testInterfaces[i].GetErrorForFrame();
                }

                yield return(new WaitForFixedUpdate());
            }

            //Now everything is finished, apply scores to generation
            for (int i = 0; i < Population; i++)
            {
                _geneticTuner.CurrentPopulation[i].CurrentScore = -accumulatedError[i];//Stupid hack to get score working right
            }

            _geneticTuner.PrintDebugScores();
            DestroyList(prefabInstances);
        }
示例#6
0
    private IEnumerator Increase(IntContainer container)
    {
        WaitForSeconds waitForSeconds = new WaitForSeconds(0.5f);

        while (true)
        {
            ++container.x;
            yield return(waitForSeconds);
        }
    }
示例#7
0
        public AgentListEvaluator(IGenomeDecoder <NeatGenome, IBlackBox> decoder, GameObject gameObject, GameObject agentPrefab, IntContainer tickPerEvalCount)
        {
            _gameObject       = gameObject;
            _decoder          = decoder;
            _agentPrefab      = agentPrefab;
            _tickPerEvalCount = tickPerEvalCount;
            _evaluationCount  = 0;

            _novelty_Archive = new Novelty_archive();
            _novelty_Archive.Add(Vec3ToVec2(gameObject.transform.position));

            UnityThread.InitUnityThread();
        }
示例#8
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        GUI.enabled = Application.isPlaying;

        IntContainer m_Target = target as IntContainer;

        if (GUILayout.Button("Update Changes"))
        {
            m_Target.OnValueChanged.Invoke(m_Target);
        }
        GUILayout.Label("Delegate Count : " + m_Target.OnValueChanged.GetInvocationList().Length.ToString());
    }
示例#9
0
    public override bool Accept(Assignment delta, Assignment unused_deltadelta)
    {
        IntContainer solution_delta      = delta.IntVarContainer();
        int          solution_delta_size = solution_delta.Size();

        for (int i = 0; i < solution_delta_size; ++i)
        {
            if (!solution_delta.Element(i).Activated())
            {
                return(true);
            }
        }
        long new_sum = sum_;

        for (int index = 0; index < solution_delta_size; ++index)
        {
            int  touched_var = Index(solution_delta.Element(index).Var());
            long old_value   = Value(touched_var);
            long new_value   = solution_delta.Element(index).Value();
            new_sum += new_value - old_value;
        }
        return(new_sum < sum_);
    }
示例#10
0
 public void UpdateChanges(IntContainer value)
 {
     dropdown.value = value.Value;
     dropdown.RefreshShownValue();
 }
示例#11
0
    public static void ShouldFail(IntContainer x)
    {
        var ic = x ?? new IntContainer(4);

        Contract.Assert(ic.val == 4);
    }
示例#12
0
    public static void ShouldPass()
    {
        var ic = new IntContainer(3);

        F(ic);
    }
示例#13
0
 public void SetInteger(IntContainer container)
 {
     Animator.SetInteger(parameterHash, container.Value);
 }
示例#14
0
 public CounterIncrementer(IntContainer container)
 {
     _intTarget = container;
 }
示例#15
0
 public void AddAmount(IntContainer amount)
 {
     Value += amount.Value;
 }