private UnityState buildUnityState() { UnityState us = new UnityState(); us.birds = birdControls; us.walls = walls; us.goal = goal; us.roomHeight = ROOM_HEIGHT; us.roomWidth = ROOM_WIDTH; us.maxSize = MAX_SIZE; return(us); }
private void Update() { setupDistCache(); UnityState us = buildUnityState(); scoreControl.SetScore(us); Vector2[] forces = decisionControl.MakeDecisions(us); Debug.Assert(forces.Length == birdControls.Length); for (int i = 0; i < forces.Length; i++) { birdControls [i].SetForce(forces [i]); } float remainTime = MAX_TIME - (Time.time - startTime); uiControl.SetTime(generation, remainTime); if (remainTime < 0) { endSimulation(); } }