public void FixedUpdate() { HSBColor floorBodyColor, floorLeftColor, floorRightColor; floorBodyColor = map.GetColor((int)transform.position.x, (int)transform.position.y); floorLeftColor = map.GetColor((int)left.position.x, (int)left.position.y); floorRightColor = map.GetColor((int)right.position.x, (int)right.position.y); Collider2D leftCol = Physics2D.OverlapPoint(left.position); Collider2D rightCol = Physics2D.OverlapPoint(left.position); if (leftCol != null) { floorLeftColor = HSBColor.FromColor(leftCol.GetComponent <Renderer>().material.color); } if (rightCol != null) { floorRightColor = HSBColor.FromColor(rightCol.GetComponent <Renderer>().material.color); } float[] previousOutput = brain.GetOutput(); float[] input = new float[] { floorBodyColor.h, floorBodyColor.s, floorBodyColor.b, floorLeftColor.h, floorLeftColor.s, floorLeftColor.b, floorRightColor.h, floorRightColor.s, floorRightColor.b, brain.GetSize(), previousOutput[5], previousOutput[6] }; float[] output = brain.feedforward(input); Vector2 veloCheck = rBody.velocity; veloCheck += (Vector2)transform.up * output[0] * 1f * Time.fixedDeltaTime; if (veloCheck.magnitude < 0.5f) { rBody.velocity = veloCheck; } float angularCheck = rBody.angularVelocity; angularCheck += output[1]; if (Mathf.Abs(angularCheck) < 25f) { rBody.angularVelocity = angularCheck; } //float[] output = brain.GetOutput(); float h1 = output[2] < 0 ? 1f + output[2] : output[2]; float h2 = output[3] < 0 ? 1f + output[3] : output[3]; bodyMat.color = new HSBColor(h1, 1f, 1f).ToColor(); noseMat.color = new HSBColor(h2, 1f, 1f).ToColor(); //Energy calculations brain.ResetDeltaEnergy(); // Eat food? if (output[7] > 0) { Vector3 pos = transform.position; float energy = map.Eat((int)transform.position.x, (int)transform.position.y); brain.Eat(energy); //eat energy } if (output[4] > 0 && brain.GetEnergy() > 255f) { brain.BirthEnergyLoss(); BirthCreature(); } if (map.GetTileType((int)transform.position.x, (int)transform.position.y) == Tile.TILE_WATER) { brain.NaturalEnergyLoss(10f); } else { brain.NaturalEnergyLoss(1f); //natural body energy loss over time (starvation) } brain.Move(output[0]); //use energy porpotional to the accelration brain.ApplyDeltaEnergy(); //apply delta //Calculate new size of creature float size = brain.CalculateSize(); transform.localScale = new Vector3(size, size, size); }