public override object Read(ES2Reader reader) { FitnessComponent data = new FitnessComponent(); Read(reader, data); return(data); }
private float[][][] weight; // first array is the layer, second is the source node, third is the target node #endregion Fields #region Constructors public BrainANN_FF_Layers_A2A() { Name = "BrainANN_FF_Layers_A2A"; // nothing //Debug.Log("BrainANN_FF_Layers_A2A() Constructor!"); //temp: fitConnectionCost[0] = 0f; brainFitnessComponentList = new List<FitnessComponent>(); FitnessComponent FC_connectionCost = new FitnessComponent(ref fitConnectionCost, false, false, 1f, 1f, "Connection Cost", false); // Turn back on when Fitness Panel can handle it! //brainFitnessComponentList.Add (FC_connectionCost); // 0 }
public BrainANN_FF_Layers_A2A() { Name = "BrainANN_FF_Layers_A2A"; // nothing //Debug.Log("BrainANN_FF_Layers_A2A() Constructor!"); //temp: fitConnectionCost[0] = 0f; brainFitnessComponentList = new List <FitnessComponent>(); FitnessComponent FC_connectionCost = new FitnessComponent(ref fitConnectionCost, false, false, 1f, 1f, "Connection Cost", false); // Turn back on when Fitness Panel can handle it! //brainFitnessComponentList.Add (FC_connectionCost); // 0 }
public override void Write(object obj, ES2Writer writer) { FitnessComponent data = (FitnessComponent)obj; // Add your writer.Write calls here. writer.Write(0); // Version 1 is current version number // Make sure to edit Read() function to properly handle version control! // VERSION 0: writer.Write(data.bigIsBetter); writer.Write(data.componentName); writer.Write(data.divideByTimeSteps); writer.Write(data.on); writer.Write(data.power); writer.Write(data.weight); }
// Constructor Method: public MiniGameMoveToTarget1D() { //DebugBot.DebugFunctionCall("MiniGameMoveToTarget1D; Constructor();", debugFunctionCalls); ownPosX[0] = 0f; targetPosX[0] = 0f; ownVelX[0] = 0f; targetVelX[0] = 0f; targetDirX[0] = 0f; fitDotProduct[0] = 0f; fitTimeToTarget[0] = 1f; fitDistanceToTarget[0] = 0f; fitReachTarget[0] = 0f; collision = false; // Brain Inputs!: inputChannelsList = new List<BrainInputChannel>(); BrainInputChannel BIC_ownPosX = new BrainInputChannel(ref ownPosX, false, "ownPosX"); inputChannelsList.Add (BIC_ownPosX); // 0 BrainInputChannel BIC_targetPosX = new BrainInputChannel(ref targetPosX, false, "targetPosX"); inputChannelsList.Add (BIC_targetPosX); // 1 BrainInputChannel BIC_ownVelX = new BrainInputChannel(ref ownVelX, false, "ownVelX"); inputChannelsList.Add (BIC_ownVelX); // 2 BrainInputChannel BIC_targetVelX = new BrainInputChannel(ref targetVelX, false, "targetVelX"); inputChannelsList.Add (BIC_targetVelX); // 3 BrainInputChannel BIC_targetDirX = new BrainInputChannel(ref targetDirX, false, "targetDirX"); inputChannelsList.Add (BIC_targetDirX); // 4 // Brain Outputs!: outputChannelsList = new List<BrainOutputChannel>(); BrainOutputChannel BOC_ownVelX = new BrainOutputChannel(ref ownVelX, false, "ownVelX"); outputChannelsList.Add (BOC_ownVelX); // 0 fitnessComponentList = new List<FitnessComponent>(); FitnessComponent FC_dotProduct = new FitnessComponent(ref fitDotProduct, false, true, 1f, 1f, "Dot Product To Target", true); fitnessComponentList.Add (FC_dotProduct); // 0 FitnessComponent FC_timeToTarget = new FitnessComponent(ref fitTimeToTarget, false, false, 1f, 1f, "Time To Target", true); fitnessComponentList.Add (FC_timeToTarget); // 1 FitnessComponent FC_distanceToTarget = new FitnessComponent(ref fitDistanceToTarget, false, false, 1f, 1f, "Distance To Target", true); fitnessComponentList.Add (FC_distanceToTarget); // 2 FitnessComponent FC_reachTarget = new FitnessComponent(ref fitReachTarget, false, true, 1f, 1f, "Reaches Target", false); fitnessComponentList.Add (FC_reachTarget); // 3 Reset(); }
public override void Read(ES2Reader reader, object c) { FitnessComponent data = (FitnessComponent)c; // Add your reader.Read calls here to read the data into the object. // Read the version number. int fileVersion = reader.Read <int>(); // VERSION 0: if (fileVersion >= 0) { data.bigIsBetter = reader.Read <bool>(); data.componentName = reader.Read <string>(); data.divideByTimeSteps = reader.Read <bool>(); data.on = reader.Read <bool>(); data.power = reader.Read <float>(); data.weight = reader.Read <float>(); if (fileVersion >= 1) { // new attributes } } }
public override object Read(ES2Reader reader) { FitnessComponent data = new FitnessComponent(); Read(reader, data); return data; }
// Constructor!! public MiniGamePhysXWorm() { piecesBuilt = false; // This refers to if the pieces have all their components and are ready for Simulation, not simply instantiated empty GO's gameInitialized = false; // Reset() is Initialization gameTicked = false; // Has the game been ticked on its current TimeStep gameUpdatedFromPhysX = false; // Did the game just get updated from PhysX Simulation? gameCurrentTimeStep = 0; // Should only be able to increment this if the above are true (which means it went through gameLoop for this timeStep) sa_x = new float[numberOfSegments]; sa_y = new float[numberOfSegments]; sa_z = new float[numberOfSegments]; targetPosX = new float[1]; targetPosY = new float[1]; targetPosZ = new float[1]; targetDirX = new float[1]; targetDirY = new float[1]; targetDirZ = new float[1]; targetDirX[0] = 0f; targetDirY[0] = 0f; targetDirZ[0] = 0f; armTotalLength[0] = 2.0f; GOwormSegments = new GameObject[numberOfSegments]; wormSegmentArray_PosX = new float[numberOfSegments][]; wormSegmentArray_PosY = new float[numberOfSegments][]; wormSegmentArray_PosZ = new float[numberOfSegments][]; wormSegmentArray_Angle = new float[numberOfSegments][];; wormSegmentArray_MotorTarget = new float[numberOfSegments][];; wormSegmentArray_Length = new float[numberOfSegments][];; //GOtargetSphere = new GameObject("GOtargetSphere"); //GOtargetSphere.transform.localScale = new Vector3(targetRadius, targetRadius, targetRadius); for(int i = 0; i < numberOfSegments; i++) { //string name = "GOwormSegment" + i.ToString(); //GOwormSegments[i] = new GameObject(name); //GOwormSegments[i].transform.localPosition = new Vector3(0f, 0f, 0f); // RE-EVALUATE!!! wormSegmentArray_PosX[i] = new float[1]; wormSegmentArray_PosY[i] = new float[1]; wormSegmentArray_PosZ[i] = new float[1]; wormSegmentArray_Angle[i] = new float[1]; wormSegmentArray_MotorTarget[i] = new float[1]; wormSegmentArray_Length[i] = new float[1]; // Calculate surface areas for each face: wormSegmentArray_Length[i][0] = armTotalLength[0]/(float)numberOfSegments; //GOwormSegments[i].transform.localScale = new Vector3(wormSegmentArray_Length[i][0], wormSegmentThickness, wormSegmentThickness*2f); //sa_x[i] = GOwormSegments[i].transform.localScale.y * GOwormSegments[i].transform.localScale.z; //sa_y[i] = GOwormSegments[i].transform.localScale.x * GOwormSegments[i].transform.localScale.z; //sa_z[i] = GOwormSegments[i].transform.localScale.x * GOwormSegments[i].transform.localScale.y; } fitDistFromOrigin[0] = 0f; fitEnergySpent[0] = 0f; fitDistToTarget[0] = 0f; fitTimeToTarget[0] = 0f; // Brain Inputs!: inputChannelsList = new List<BrainInputChannel>(); BrainInputChannel BIC_targetDirX = new BrainInputChannel(ref targetDirX, false, "TargetDir X"); inputChannelsList.Add (BIC_targetDirX); BrainInputChannel BIC_targetDirY = new BrainInputChannel(ref targetDirY, false, "TargetDir Y"); inputChannelsList.Add (BIC_targetDirY); BrainInputChannel BIC_targetDirZ = new BrainInputChannel(ref targetDirZ, false, "TargetDir Z"); inputChannelsList.Add (BIC_targetDirZ); // Brain Outputs!: outputChannelsList = new List<BrainOutputChannel>(); for(int bc = 0; bc < numberOfSegments; bc++) { string inputChannelName = "Worm Segment " + bc.ToString() + " Angle"; BrainInputChannel BIC_wormSegmentAngle = new BrainInputChannel(ref wormSegmentArray_Angle[bc], false, inputChannelName); inputChannelsList.Add (BIC_wormSegmentAngle); string outputChannelName = "Worm Segment " + bc.ToString() + " Motor Target"; BrainOutputChannel BOC_wormSegmentAngleVel = new BrainOutputChannel(ref wormSegmentArray_MotorTarget[bc], false, outputChannelName); outputChannelsList.Add (BOC_wormSegmentAngleVel); } fitnessComponentList = new List<FitnessComponent>(); FitnessComponent FC_distFromOrigin = new FitnessComponent(ref fitDistFromOrigin, true, true, 1f, 1f, "Distance From Origin", true); fitnessComponentList.Add (FC_distFromOrigin); // 0 FitnessComponent FC_energySpent = new FitnessComponent(ref fitEnergySpent, true, false, 1f, 1f, "Energy Spent", true); fitnessComponentList.Add (FC_energySpent); // 1 FitnessComponent FC_distToTarget = new FitnessComponent(ref fitDistToTarget, true, false, 1f, 1f, "Distance To Target", false); fitnessComponentList.Add (FC_distToTarget); // 2 FitnessComponent FC_timeToTarget = new FitnessComponent(ref fitTimeToTarget, true, false, 1f, 1f, "Time To Target", true); fitnessComponentList.Add (FC_timeToTarget); // 3 //Reset(); }
private void SetupFitnessComponentList() { // Fitness Component List: fitnessComponentList = new List<FitnessComponent>(); FitnessComponent FC_distFromOrigin = new FitnessComponent(ref fitDistFromOrigin, true, true, 1f, 0f, "Distance From Origin", true); fitnessComponentList.Add(FC_distFromOrigin); // 0 FitnessComponent FC_energySpent = new FitnessComponent(ref fitEnergySpent, true, false, 1f, 1f, "Energy Spent", true); fitnessComponentList.Add(FC_energySpent); // 1 FitnessComponent FC_distToTarget = new FitnessComponent(ref fitDistToTarget, true, false, 1f, 1f, "Distance To Target", true); fitnessComponentList.Add(FC_distToTarget); // 2 //FitnessComponent FC_timeToTarget = new FitnessComponent(ref fitTimeInTarget, true, true, 1f, 1f, "Time In Target", true); //fitnessComponentList.Add(FC_timeToTarget); // 3 //FitnessComponent FC_moveToTarget = new FitnessComponent(ref fitMoveToTarget, true, true, 1f, 1f, "Move Towards Target", true); //fitnessComponentList.Add(FC_moveToTarget); // 7 FitnessComponent FC_moveSpeed = new FitnessComponent(ref fitMoveSpeed, true, true, 1f, 0f, "Average Speed", true); fitnessComponentList.Add(FC_moveSpeed); // 8 FitnessComponent FC_customBody = new FitnessComponent(ref fitCustomBody, true, true, 1f, 1f, "Custom Body", false); fitnessComponentList.Add(FC_customBody); // 8 //FitnessComponent FC_customPole = new FitnessComponent(ref fitCustomPole, true, true, 1f, 1f, "Custom Pole", false); //fitnessComponentList.Add(FC_customPole); // 8 fitnessContactSensorList = new List<float[]>(); for (int contactSensorIndex = 0; contactSensorIndex < critterBeingTested.segaddonContactSensorList.Count; contactSensorIndex++) { string fitnessComponentName = "Segment " + critterBeingTested.segaddonContactSensorList[contactSensorIndex].segmentID.ToString() + " Contact"; float[] fitnessContact = new float[1]; fitnessContact[0] = 0f; fitnessContactSensorList.Add(fitnessContact); FitnessComponent FC_segmentContact = new FitnessComponent(ref fitnessContact, true, true, 1f, 1f, fitnessComponentName, true); fitnessComponentList.Add(FC_segmentContact); } fitnessRaycastSensorList = new List<float[]>(); for (int raycastSensorIndex = 0; raycastSensorIndex < critterBeingTested.segaddonRaycastSensorList.Count; raycastSensorIndex++) { string fitnessComponentName = "Segment " + critterBeingTested.segaddonRaycastSensorList[raycastSensorIndex].segmentID.ToString() + " Raycast"; float[] fitnessDistance = new float[1]; fitnessDistance[0] = 0f; fitnessRaycastSensorList.Add(fitnessDistance); FitnessComponent FC_segmentRaycast = new FitnessComponent(ref fitnessDistance, true, true, 1f, 1f, fitnessComponentName, true); fitnessComponentList.Add(FC_segmentRaycast); } fitnessCompassSensor1DList = new List<float[]>(); for (int compassSensor1DIndex = 0; compassSensor1DIndex < critterBeingTested.segaddonCompassSensor1DList.Count; compassSensor1DIndex++) { string fitnessComponentName = "Segment " + critterBeingTested.segaddonCompassSensor1DList[compassSensor1DIndex].segmentID.ToString() + " Compass1D"; float[] fitnessDotProduct = new float[1]; fitnessDotProduct[0] = 0f; fitnessCompassSensor1DList.Add(fitnessDotProduct); FitnessComponent FC_segmentCompass1D = new FitnessComponent(ref fitnessDotProduct, true, true, 1f, 1f, fitnessComponentName, true); fitnessComponentList.Add(FC_segmentCompass1D); } fitnessCompassSensor3DListRight = new List<float[]>(); fitnessCompassSensor3DListUp = new List<float[]>(); fitnessCompassSensor3DListForward = new List<float[]>(); for (int compassSensor3DIndex = 0; compassSensor3DIndex < critterBeingTested.segaddonCompassSensor3DList.Count; compassSensor3DIndex++) { string fitnessComponentName = "Segment " + critterBeingTested.segaddonCompassSensor3DList[compassSensor3DIndex].segmentID.ToString() + " Compass3D Right"; float[] fitnessDotProductRight = new float[1]; fitnessDotProductRight[0] = 0f; fitnessCompassSensor3DListRight.Add(fitnessDotProductRight); FitnessComponent FC_segmentCompass3DRight = new FitnessComponent(ref fitnessDotProductRight, true, false, 1f, 1f, fitnessComponentName, true); fitnessComponentList.Add(FC_segmentCompass3DRight); fitnessComponentName = "Segment " + critterBeingTested.segaddonCompassSensor3DList[compassSensor3DIndex].segmentID.ToString() + " Compass3D Up"; float[] fitnessDotProductUp = new float[1]; fitnessDotProductUp[0] = 0f; fitnessCompassSensor3DListUp.Add(fitnessDotProductUp); FitnessComponent FC_segmentCompass3DUp = new FitnessComponent(ref fitnessDotProductUp, true, false, 1f, 1f, fitnessComponentName, true); fitnessComponentList.Add(FC_segmentCompass3DUp); fitnessComponentName = "Segment " + critterBeingTested.segaddonCompassSensor3DList[compassSensor3DIndex].segmentID.ToString() + " Compass3D Forward"; float[] fitnessDotProductForward = new float[1]; fitnessDotProductForward[0] = 0f; fitnessCompassSensor3DListForward.Add(fitnessDotProductForward); FitnessComponent FC_segmentCompass3DForward = new FitnessComponent(ref fitnessDotProductForward, true, true, 1f, 1f, fitnessComponentName, true); fitnessComponentList.Add(FC_segmentCompass3DForward); } fitnessPositionSensor1DList = new List<float[]>(); for(int positionSensor1DIndex = 0; positionSensor1DIndex < critterBeingTested.segaddonPositionSensor1DList.Count; positionSensor1DIndex++) { string fitnessComponentName = "Segment " + critterBeingTested.segaddonPositionSensor1DList[positionSensor1DIndex].segmentID.ToString() + " Position1D Distance"; float[] fitnessDistance = new float[1]; fitnessDistance[0] = 0f; fitnessPositionSensor1DList.Add(fitnessDistance); FitnessComponent FC_segmentPosition1DDistance = new FitnessComponent(ref fitnessDistance, true, false, 1f, 0.25f, fitnessComponentName, true); fitnessComponentList.Add(FC_segmentPosition1DDistance); } fitnessPositionSensor3DList = new List<float[]>(); for (int positionSensor3DIndex = 0; positionSensor3DIndex < critterBeingTested.segaddonPositionSensor3DList.Count; positionSensor3DIndex++) { string fitnessComponentName = "Segment " + critterBeingTested.segaddonPositionSensor3DList[positionSensor3DIndex].segmentID.ToString() + " Position3D Distance"; float[] fitnessDistance = new float[1]; fitnessDistance[0] = 0f; fitnessPositionSensor3DList.Add(fitnessDistance); FitnessComponent FC_segmentPosition3DDistance = new FitnessComponent(ref fitnessDistance, true, false, 1f, 1f, fitnessComponentName, true); fitnessComponentList.Add(FC_segmentPosition3DDistance); } fitnessPositionSensor3DTargetList = new List<float[]>(); for (int positionSensor3DTargetIndex = 0; positionSensor3DTargetIndex < critterBeingTested.segaddonPositionSensor3DList.Count; positionSensor3DTargetIndex++) { string fitnessComponentName = "Segment " + critterBeingTested.segaddonPositionSensor3DList[positionSensor3DTargetIndex].segmentID.ToString() + " Pos3D Custom Target"; float[] fitnessTarget = new float[1]; fitnessTarget[0] = 0f; fitnessPositionSensor3DTargetList.Add(fitnessTarget); FitnessComponent FC_segmentPosition3DTarget = new FitnessComponent(ref fitnessTarget, true, true, 1f, 1f, fitnessComponentName, true); fitnessComponentList.Add(FC_segmentPosition3DTarget); } fitnessRotationSensor1DList = new List<float[]>(); for (int rotationSensor1DIndex = 0; rotationSensor1DIndex < critterBeingTested.segaddonRotationSensor1DList.Count; rotationSensor1DIndex++) { string fitnessComponentName = "Segment " + critterBeingTested.segaddonRotationSensor1DList[rotationSensor1DIndex].segmentID.ToString() + " Rotation1D Rate"; float[] fitnessRate = new float[1]; fitnessRate[0] = 0f; fitnessRotationSensor1DList.Add(fitnessRate); FitnessComponent FC_segmentRotation1D = new FitnessComponent(ref fitnessRate, true, false, 1f, 1f, fitnessComponentName, true); fitnessComponentList.Add(FC_segmentRotation1D); } fitnessRotationSensor3DList = new List<float[]>(); for (int rotationSensor3DIndex = 0; rotationSensor3DIndex < critterBeingTested.segaddonRotationSensor3DList.Count; rotationSensor3DIndex++) { string fitnessComponentName = "Segment " + critterBeingTested.segaddonRotationSensor3DList[rotationSensor3DIndex].segmentID.ToString() + " Rotation3D Rate"; float[] fitnessRate = new float[1]; fitnessRate[0] = 0f; fitnessRotationSensor3DList.Add(fitnessRate); //critterBeingTested.segaddonRotationSensor3DList[rotationSensor3DIndex]; FitnessComponent FC_segmentRotation3D = new FitnessComponent(ref fitnessRate, true, false, 1f, 0.25f, fitnessComponentName, true); fitnessComponentList.Add(FC_segmentRotation3D); } fitnessVelocitySensor3DList = new List<float[]>(); for(int velocitySensor3DIndex = 0; velocitySensor3DIndex < critterBeingTested.segaddonVelocitySensor3DList.Count; velocitySensor3DIndex++) { string fitnessComponentName = "Segment " + critterBeingTested.segaddonVelocitySensor3DList[velocitySensor3DIndex].segmentID.ToString() + " Velocity3D"; float[] fitnessRate = new float[1]; fitnessRate[0] = 0f; fitnessVelocitySensor3DList.Add(fitnessRate); FitnessComponent FC_segmentVelocity3D = new FitnessComponent(ref fitnessRate, true, true, 1f, 0f, fitnessComponentName, true); fitnessComponentList.Add(FC_segmentVelocity3D); } fitnessAltimeterList = new List<float[]>(); for (int altimeterIndex = 0; altimeterIndex < critterBeingTested.segaddonAltimeterList.Count; altimeterIndex++) { string fitnessComponentName = "Segment " + critterBeingTested.segaddonAltimeterList[altimeterIndex].segmentID.ToString() + " Altimeter"; float[] fitnessAltimeter = new float[1]; fitnessAltimeter[0] = 0f; fitnessAltimeterList.Add(fitnessAltimeter); FitnessComponent FC_segmentAltimeter = new FitnessComponent(ref fitnessAltimeter, true, true, 1f, 1f, fitnessComponentName, true); fitnessComponentList.Add(FC_segmentAltimeter); } fitnessGravitySensorList = new List<float[]>(); for (int gravitySensorIndex = 0; gravitySensorIndex < critterBeingTested.segaddonGravitySensorList.Count; gravitySensorIndex++) { string fitnessComponentName = "Segment " + critterBeingTested.segaddonGravitySensorList[gravitySensorIndex].segmentID.ToString() + " Gravity"; float[] fitnessGravitySensor = new float[1]; fitnessGravitySensor[0] = 0f; fitnessGravitySensorList.Add(fitnessGravitySensor); FitnessComponent FC_segmentGravitySensor = new FitnessComponent(ref fitnessGravitySensor, true, false, 1f, 1f, fitnessComponentName, true); fitnessComponentList.Add(FC_segmentGravitySensor); } fitnessMouthBasicList = new List<float[]>(); for (int mouthBasicIndex = 0; mouthBasicIndex < critterBeingTested.segaddonMouthBasicList.Count; mouthBasicIndex++) { string fitnessComponentName = "Segment " + critterBeingTested.segaddonMouthBasicList[mouthBasicIndex].segmentID.ToString() + " MouthBasic"; float[] fitnessMouth = new float[1]; fitnessMouth[0] = 0f; fitnessMouthBasicList.Add(fitnessMouth); FitnessComponent FC_segmentMouthBasic = new FitnessComponent(ref fitnessMouth, true, false, 1f, 1f, fitnessComponentName, true); fitnessComponentList.Add(FC_segmentMouthBasic); } ResetFitnessComponentValues(); }
// Constructor!! public MiniGameRobotArm() { GOarmSegments = new GameObject[numberOfSegments]; armSegmentArray_PosX = new float[numberOfSegments][]; armSegmentArray_PosY = new float[numberOfSegments][]; armSegmentArray_Angle = new float[numberOfSegments][];; armSegmentArray_AngleVel = new float[numberOfSegments][];; armSegmentArray_Length = new float[numberOfSegments][];; for(int i = 0; i < numberOfSegments; i++) { armSegmentArray_PosX[i] = new float[1]; armSegmentArray_PosY[i] = new float[1]; armSegmentArray_Angle[i] = new float[1]; armSegmentArray_AngleVel[i] = new float[1]; armSegmentArray_Length[i] = new float[1]; } armTip_PosX[0] = 0f; armTip_PosY[0] = 0f; armTotalLength[0] = 1.6f; /* armSegmentA_PosX[0] = 0f; armSegmentA_PosY[0] = 0f; armSegmentA_Length[0] = 0.333334f; armSegmentA_Angle[0] = 0f; armSegmentA_AngleVel[0] = 0f; armSegmentB_PosX[0] = 0f; armSegmentB_PosY[0] = 0f; armSegmentB_Angle[0] = 0f; armSegmentB_AngleVel[0] = 0f; armSegmentB_Length[0] = 0.333334f; armSegmentC_PosX[0] = 0f; armSegmentC_PosY[0] = 0f; armSegmentC_Angle[0] = 0f; armSegmentC_AngleVel[0] = 0f; armSegmentC_Length[0] = 0.333334f; armTip_PosX[0] = 0f; armTip_PosY[0] = 0f; target_PosX[0] = 0f; target_PosY[0] = 0f; target_Angle[0] = 0f; target_Distance[0] = 0f; */ fitTimeToTarget[0] = 1f; fitDistanceToTarget[0] = 0f; fitEnergySpent[0] = 0f; fitGapClosed[0] = 0f; fitTimeInTarget[0] = 0f; fitArmReachDistance[0] = 0f; fitDotProduct[0] = 0f; collision = false; // Brain Inputs!: inputChannelsList = new List<BrainInputChannel>(); // Brain Outputs!: outputChannelsList = new List<BrainOutputChannel>(); BrainInputChannel BIC_target_Angle = new BrainInputChannel(ref target_Angle, false, "target_Angle"); inputChannelsList.Add (BIC_target_Angle); // 0 BrainInputChannel BIC_target_Distance = new BrainInputChannel(ref target_Distance, false, "target_Distance"); inputChannelsList.Add (BIC_target_Distance); // 1 for(int bc = 0; bc < numberOfSegments; bc++) { string inputChannelName = "Arm Segment " + bc.ToString() + " Angle"; BrainInputChannel BIC_armSegmentAngle = new BrainInputChannel(ref armSegmentArray_Angle[bc], false, inputChannelName); inputChannelsList.Add (BIC_armSegmentAngle); string outputChannelName = "Arm Segment " + bc.ToString() + " Angle Vel"; BrainOutputChannel BOC_armSegmentAngleVel = new BrainOutputChannel(ref armSegmentArray_AngleVel[bc], false, outputChannelName); outputChannelsList.Add (BOC_armSegmentAngleVel); } //BrainInputChannel BIC_armSegmentA_Angle = new BrainInputChannel(ref armSegmentA_Angle, false, "armSegmentA_Angle"); //inputChannelsList.Add (BIC_armSegmentA_Angle); // 0 //BrainInputChannel BIC_armSegmentB_Angle = new BrainInputChannel(ref armSegmentB_Angle, false, "armSegmentB_Angle"); //inputChannelsList.Add (BIC_armSegmentB_Angle); // 1 //BrainInputChannel BIC_armSegmentC_Angle = new BrainInputChannel(ref armSegmentC_Angle, false, "armSegmentC_Angle"); //inputChannelsList.Add (BIC_armSegmentC_Angle); // 2 //BrainOutputChannel BOC_armSegmentA_AngleVel = new BrainOutputChannel(ref armSegmentA_AngleVel, false, "armSegmentA_AngleVel"); //outputChannelsList.Add (BOC_armSegmentA_AngleVel); // 0 //BrainOutputChannel BOC_armSegmentB_AngleVel = new BrainOutputChannel(ref armSegmentB_AngleVel, false, "armSegmentB_AngleVel"); //outputChannelsList.Add (BOC_armSegmentB_AngleVel); // 1 //BrainOutputChannel BOC_armSegmentC_AngleVel = new BrainOutputChannel(ref armSegmentC_AngleVel, false, "armSegmentC_AngleVel"); //outputChannelsList.Add (BOC_armSegmentC_AngleVel); // 2 fitnessComponentList = new List<FitnessComponent>(); FitnessComponent FC_timeToTarget = new FitnessComponent(ref fitTimeToTarget, false, false, 1f, 1f, "Time To Target", true); fitnessComponentList.Add (FC_timeToTarget); // 0 FitnessComponent FC_distanceToTarget = new FitnessComponent(ref fitDistanceToTarget, false, false, 1f, 1f, "Distance To Target", true); fitnessComponentList.Add (FC_distanceToTarget); // 1 FitnessComponent FC_energySpent = new FitnessComponent(ref fitEnergySpent, false, false, 1f, 1f, "Energy Spent", true); fitnessComponentList.Add (FC_energySpent); // 2 FitnessComponent FC_gapClosed = new FitnessComponent(ref fitGapClosed, false, true, 1f, 1f, "Gap Closed", false); fitnessComponentList.Add (FC_gapClosed); // 3 FitnessComponent FC_timeInTarget = new FitnessComponent(ref fitTimeInTarget, false, true, 1f, 1f, "Time Inside Target", true); fitnessComponentList.Add (FC_timeInTarget); // 4 FitnessComponent FC_armReachDistance = new FitnessComponent(ref fitArmReachDistance, false, false, 1f, 1f, "Arm Reach Distance", false); fitnessComponentList.Add (FC_armReachDistance); // 5 FitnessComponent FC_dotProduct = new FitnessComponent(ref fitDotProduct, false, true, 1f, 1f, "Dot Product", false); fitnessComponentList.Add (FC_dotProduct); // 6 Reset(); }
// Constructor!! public MiniGamePhysXTests() { GOtestAgentBall = new GameObject("GOtestAgentBall"); GOtestAgentBall.transform.localPosition = new Vector3(0f, 0f, 0f); GOtestTargetBall = new GameObject("GOtestTargetBall"); GOtestTargetBall.transform.localPosition = new Vector3(0f, 0f, 0f); ownPosX[0] = 0f; ownPosY[0] = 0f; ownPosZ[0] = 0f; targetPosX[0] = 0f; targetPosY[0] = 0f; targetPosZ[0] = 0f; ownVelX[0] = 0f; ownVelY[0] = 0f; ownVelZ[0] = 0f; targetVelX[0] = 0f; targetVelY[0] = 0f; targetVelZ[0] = 0f; fitDotProduct[0] = 0f; fitTimeToTarget[0] = 1f; fitDistanceToTarget[0] = 0f; fitReachTarget[0] = 0f; collision = false; // Brain Inputs!: inputChannelsList = new List<BrainInputChannel>(); BrainInputChannel BIC_ownPosX = new BrainInputChannel(ref ownPosX, false, "ownPosX"); inputChannelsList.Add (BIC_ownPosX); // 0 BrainInputChannel BIC_ownPosY = new BrainInputChannel(ref ownPosY, false, "ownPosY"); inputChannelsList.Add (BIC_ownPosY); // 1 BrainInputChannel BIC_ownPosZ = new BrainInputChannel(ref ownPosZ, false, "ownPosZ"); inputChannelsList.Add (BIC_ownPosZ); // 2 BrainInputChannel BIC_targetPosX = new BrainInputChannel(ref targetPosX, false, "targetPosX"); inputChannelsList.Add (BIC_targetPosX); // 3 BrainInputChannel BIC_targetPosY = new BrainInputChannel(ref targetPosY, false, "targetPosY"); inputChannelsList.Add (BIC_targetPosY); // 4 BrainInputChannel BIC_targetPosZ = new BrainInputChannel(ref targetPosZ, false, "targetPosZ"); inputChannelsList.Add (BIC_targetPosZ); // 5 BrainInputChannel BIC_ownVelX = new BrainInputChannel(ref ownVelX, false, "ownVelX"); inputChannelsList.Add (BIC_ownVelX); // 6 BrainInputChannel BIC_ownVelY = new BrainInputChannel(ref ownVelY, false, "ownVelY"); inputChannelsList.Add (BIC_ownVelY); // 7 BrainInputChannel BIC_ownVelZ = new BrainInputChannel(ref ownVelZ, false, "ownVelZ"); inputChannelsList.Add (BIC_ownVelZ); // 8 BrainInputChannel BIC_targetDirX = new BrainInputChannel(ref targetDirX, false, "targetDirX"); inputChannelsList.Add (BIC_targetDirX); // 9 BrainInputChannel BIC_targetDirY = new BrainInputChannel(ref targetDirY, false, "targetDirY"); inputChannelsList.Add (BIC_targetDirY); // 10 BrainInputChannel BIC_targetDirZ = new BrainInputChannel(ref targetDirZ, false, "targetDirZ"); inputChannelsList.Add (BIC_targetDirZ); // 11 // Brain Outputs!: outputChannelsList = new List<BrainOutputChannel>(); BrainOutputChannel BOC_ownVelX = new BrainOutputChannel(ref ownVelX, false, "ownVelX"); outputChannelsList.Add (BOC_ownVelX); // 0 BrainOutputChannel BOC_ownVelY = new BrainOutputChannel(ref ownVelY, false, "ownVelY"); outputChannelsList.Add (BOC_ownVelY); // 1 BrainOutputChannel BOC_ownVelZ = new BrainOutputChannel(ref ownVelZ, false, "ownVelZ"); outputChannelsList.Add (BOC_ownVelZ); // 1 fitnessComponentList = new List<FitnessComponent>(); FitnessComponent FC_dotProduct = new FitnessComponent(ref fitDotProduct, true, true, 1f, 1f, "Dot Product To Target", true); fitnessComponentList.Add (FC_dotProduct); // 0 FitnessComponent FC_timeToTarget = new FitnessComponent(ref fitTimeToTarget, true, false, 1f, 1f, "Time To Target", true); fitnessComponentList.Add (FC_timeToTarget); // 1 FitnessComponent FC_distanceToTarget = new FitnessComponent(ref fitDistanceToTarget, true, false, 1f, 1f, "Distance To Target", true); fitnessComponentList.Add (FC_distanceToTarget); // 2 FitnessComponent FC_reachTarget = new FitnessComponent(ref fitReachTarget, true, true, 1f, 1f, "Reaches Target", false); fitnessComponentList.Add (FC_reachTarget); // 3 Reset(); }