// Constructor to use for training, i.e. when Python starts everything public PythonAgentController(Environment environment, int portSend, int portReceive) { this.environment = environment; network = new UDPNetwork(portSend, portReceive); observationDimension = environment.ObservationDimension(); actionDimension = environment.ActionDimension(); network.AllocateSendBuffer(1 + 4 + 4 * observationDimension); /* Send network msg to Python (12 bytes) * 1. port (int = 4 bytes) (port that python sends and unity receives) * 2. observation dimension (int = 4 bytes) * 3. action dimension (int = 4 bytes) */ byte[] obsdimBytes = BitConverter.GetBytes(observationDimension); byte[] actdimBytes = BitConverter.GetBytes(actionDimension); byte[] introMsg = new byte[2 * 4]; introMsg[0] = obsdimBytes[0]; introMsg[1] = obsdimBytes[1]; introMsg[2] = obsdimBytes[2]; introMsg[3] = obsdimBytes[3]; introMsg[4] = actdimBytes[0]; introMsg[5] = actdimBytes[1]; introMsg[6] = actdimBytes[2]; introMsg[7] = actdimBytes[3]; network.Send(introMsg); }
public BoxExternalAgentController(int observationDimension, int actionDimension, int portSend, int portReceive) { this.observationDimension = observationDimension; this.actionDimension = actionDimension; actions = new float[actionDimension]; receiveBuffer = new float[1 + actionDimension]; network = new UDPNetwork(portSend, portReceive); network.AllocateSendBuffer(4 + 4 * observationDimension + 4 + 4); }