public static void Main() { var ic = new IntContainer(3); F(ic); F(null); }
public static void Main(string[] args) { var container = new IntContainer(); container.Contents = 42; Print(ref container.Contents); }
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); }
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); }
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); }
private IEnumerator Increase(IntContainer container) { WaitForSeconds waitForSeconds = new WaitForSeconds(0.5f); while (true) { ++container.x; yield return(waitForSeconds); } }
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(); }
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()); }
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_); }
public void UpdateChanges(IntContainer value) { dropdown.value = value.Value; dropdown.RefreshShownValue(); }
public static void ShouldFail(IntContainer x) { var ic = x ?? new IntContainer(4); Contract.Assert(ic.val == 4); }
public static void ShouldPass() { var ic = new IntContainer(3); F(ic); }
public void SetInteger(IntContainer container) { Animator.SetInteger(parameterHash, container.Value); }
public CounterIncrementer(IntContainer container) { _intTarget = container; }
public void AddAmount(IntContainer amount) { Value += amount.Value; }