public void Initialize(BasicWheelGenome genome, Agent agent) { parentID = genome.parentID; inno = genome.inno; isVisible = agent.isVisible; throttle = new float[1]; steerAngle = new float[1]; brake = new float[1]; //speedX = new float[1]; speed = new float[1]; horsepower = genome.horsepower; maxSteering = genome.maxSteering; brakePower = genome.brakePower; wheelList = new List <WheelCollider>(); //Debug.Log("Agent Segment list count: " + agent.segmentList.Count.ToString()); for (int i = 0; i < genome.wheelIdList.Count; i++) { WheelCollider wheel = agent.segmentList[genome.wheelIdList[i]].GetComponent <WheelCollider>(); if (wheel == null) { Debug.LogAssertion("No existing WheelCollider on segment " + genome.wheelIdList[i].ToString()); } wheel.motorTorque = 0.00001f; wheelList.Add(wheel); } parentBody = agent.segmentList[parentID]; //Debug.Log("BasicAxle horsepower= " + genome.horsepower.ToString()); }
// Settings /*public BasicWheelGenome(int parentID, int inno) { * this.parentID = parentID; * this.inno = inno; * }*/ public BasicWheelGenome(BasicWheelGenome template) { this.parentID = template.parentID; this.wheelIdList = new List <int>(); for (int i = 0; i < template.wheelIdList.Count; i++) { int id = template.wheelIdList[i]; this.wheelIdList.Add(id); } this.inno = template.inno; this.horsepower = template.horsepower; this.maxSteering = template.maxSteering; this.brakePower = template.brakePower; }
public void CopyBodyGenomeFromTemplate(BodyGenome templateGenome) { // This method creates a clone of the provided BodyGenome - should have no shared references!!! bodyType = templateGenome.bodyType; // copy module lists: atmosphereSensorList = new List <AtmosphereSensorGenome>(); for (int i = 0; i < templateGenome.atmosphereSensorList.Count; i++) { AtmosphereSensorGenome genomeCopy = new AtmosphereSensorGenome(templateGenome.atmosphereSensorList[i]); atmosphereSensorList.Add(genomeCopy); } basicJointList = new List <BasicJointGenome>(); for (int i = 0; i < templateGenome.basicJointList.Count; i++) { BasicJointGenome genomeCopy = new BasicJointGenome(templateGenome.basicJointList[i]); basicJointList.Add(genomeCopy); } basicWheelList = new List <BasicWheelGenome>(); for (int i = 0; i < templateGenome.basicWheelList.Count; i++) { BasicWheelGenome genomeCopy = new BasicWheelGenome(templateGenome.basicWheelList[i]); basicWheelList.Add(genomeCopy); } contactSensorList = new List <ContactGenome>(); for (int i = 0; i < templateGenome.contactSensorList.Count; i++) { ContactGenome genomeCopy = new ContactGenome(templateGenome.contactSensorList[i]); contactSensorList.Add(genomeCopy); } gravitySensorList = new List <GravitySensorGenome>(); for (int i = 0; i < templateGenome.gravitySensorList.Count; i++) { GravitySensorGenome genomeCopy = new GravitySensorGenome(templateGenome.gravitySensorList[i]); gravitySensorList.Add(genomeCopy); } healthModuleList = new List <HealthGenome>(); for (int i = 0; i < templateGenome.healthModuleList.Count; i++) { HealthGenome genomeCopy = new HealthGenome(templateGenome.healthModuleList[i]); healthModuleList.Add(genomeCopy); } oscillatorInputList = new List <OscillatorGenome>(); for (int i = 0; i < templateGenome.oscillatorInputList.Count; i++) { OscillatorGenome genomeCopy = new OscillatorGenome(templateGenome.oscillatorInputList[i]); oscillatorInputList.Add(genomeCopy); } raycastSensorList = new List <RaycastSensorGenome>(); for (int i = 0; i < templateGenome.raycastSensorList.Count; i++) { RaycastSensorGenome genomeCopy = new RaycastSensorGenome(templateGenome.raycastSensorList[i]); raycastSensorList.Add(genomeCopy); } shieldList = new List <ShieldGenome>(); for (int i = 0; i < templateGenome.shieldList.Count; i++) { ShieldGenome genomeCopy = new ShieldGenome(templateGenome.shieldList[i]); shieldList.Add(genomeCopy); } targetSensorList = new List <TargetSensorGenome>(); for (int i = 0; i < templateGenome.targetSensorList.Count; i++) { TargetSensorGenome genomeCopy = new TargetSensorGenome(templateGenome.targetSensorList[i]); targetSensorList.Add(genomeCopy); } thrusterList = new List <ThrusterGenome>(); for (int i = 0; i < templateGenome.thrusterList.Count; i++) { ThrusterGenome genomeCopy = new ThrusterGenome(templateGenome.thrusterList[i]); thrusterList.Add(genomeCopy); } torqueList = new List <TorqueGenome>(); for (int i = 0; i < templateGenome.torqueList.Count; i++) { TorqueGenome genomeCopy = new TorqueGenome(templateGenome.torqueList[i]); torqueList.Add(genomeCopy); } trajectorySensorList = new List <TrajectorySensorGenome>(); for (int i = 0; i < templateGenome.trajectorySensorList.Count; i++) { TrajectorySensorGenome genomeCopy = new TrajectorySensorGenome(templateGenome.trajectorySensorList[i]); trajectorySensorList.Add(genomeCopy); } valueInputList = new List <ValueInputGenome>(); for (int i = 0; i < templateGenome.valueInputList.Count; i++) { ValueInputGenome genomeCopy = new ValueInputGenome(templateGenome.valueInputList[i]); valueInputList.Add(genomeCopy); } weaponProjectileList = new List <WeaponProjectileGenome>(); for (int i = 0; i < templateGenome.weaponProjectileList.Count; i++) { WeaponProjectileGenome genomeCopy = new WeaponProjectileGenome(templateGenome.weaponProjectileList[i]); weaponProjectileList.Add(genomeCopy); } weaponTazerList = new List <WeaponTazerGenome>(); for (int i = 0; i < templateGenome.weaponTazerList.Count; i++) { WeaponTazerGenome genomeCopy = new WeaponTazerGenome(templateGenome.weaponTazerList[i]); weaponTazerList.Add(genomeCopy); } }