void env_cleanup()
{
	freeRLStructPointer(emptyObservation);
	freeRLStructPointer(nonEmptyObservation);
	if(responseMessage!=0){
		free(responseMessage);
		responseMessage=0;
	}
}
Exemple #2
0
void agent_cleanup() {
	freeRLStructPointer(emptyAction);
	freeRLStructPointer(nonEmptyAction);
	emptyAction=0;
	nonEmptyAction=0;
	if(responseMessage!=0){
		free(responseMessage);
		responseMessage=0;
	}
}
/**
 * Pass off the call to env_step
 */
JNIEXPORT void JNICALL Java_org_rlcommunity_rlviz_environmentshell_JNIEnvironment_JNIenvstep(JNIEnv *env, jobject obj, jintArray intArray, jdoubleArray doubleArray, jcharArray charArray) {
    //create a new action to pass in from the 4 parameters. This is needed because the actual Java object cannot be passed in,
    //so the data from the object is passed in, then put into the C equivalent of an action

    jsize numInts,numDoubles,numChars=0;
    numInts = env->GetArrayLength(intArray);
    numDoubles = env->GetArrayLength(doubleArray);
    numChars = env->GetArrayLength(charArray);

    action_t* theAction = allocateRLStructPointer(numInts, numDoubles, numChars);
    //    action_t a;
    //    a.numInts = numInts;
    //    a.intArray = (int*) malloc(sizeof (int) * a.numInts);
    //    a.numDoubles = numDoubles;
    //    a.doubleArray = (double*) malloc(sizeof (double) * a.numDoubles);
    //    a.numChars = numChars;
    //    a.charArray = (char*) malloc(sizeof (char) * a.numChars);
    env->GetIntArrayRegion(intArray, 0, numInts, (jint*) theAction->intArray);
    env->GetDoubleArrayRegion(doubleArray, 0, numDoubles, (jdouble*) theAction->doubleArray);
    env->GetCharArrayRegion(charArray, 0, numChars, (jchar*) theAction->charArray);

    // get the return from env_step and parse it into a form that java can check.
    rewardObs = envFuncPointers.env_step(theAction);
    freeRLStructPointer(theAction);
    sharedReturnVariable = (observation_t *) rewardObs->observation;
}
void env_cleanup() {
	int envState = kEnvCleanup;

	rlBufferClear(&theBuffer);
	rlSendBufferData(rlGetEnvironmentConnection(), &theBuffer, envState);

	rlBufferClear(&theBuffer);
	rlRecvBufferData(rlGetEnvironmentConnection(), &theBuffer, &envState);
	assert(envState == kEnvCleanup);

	rlBufferDestroy(&theBuffer);

	freeRLStructPointer(theObservation);
	theObservation=0;
	
	if (theTaskSpec != 0) {
		free(theTaskSpec);
		theTaskSpec = 0;
	}

	if (theOutMessage != 0) {
		free(theOutMessage);
		theOutMessage = 0;
	}
}
Exemple #5
0
void agent_cleanup() {
	freeRLStructPointer(action);
	action=0;
	if(responseMessage!=0){
		free(responseMessage);
		responseMessage=0;
	}
}
Exemple #6
0
const action_t *agent_step(const double reward, const observation_t *o) {
	__RL_CHECK_STRUCT(o);
	stepCount++;

	freeRLStructPointer(action);
	action=duplicateRLStructToPointer(o);
	__RL_CHECK_STRUCT(action)
	return action;
}
void env_cleanup()
{
	if(responseMessage!=0){
		free(responseMessage);
		responseMessage=0;
	}
	freeRLStructPointer(theObservation);
	theObservation=0;
}
void agent_cleanup() {
	clearRLStruct(&this_action);
	clearRLStruct(&last_action);
	freeRLStructPointer(last_observation);
	
	if(value_function!=0){
		free(value_function);
		value_function=0;
	}
}
Exemple #9
0
/* Tell the agent that we're cleaning up */
void agent_cleanup() {
	int agentState = kAgentCleanup;

	rlBufferClear(&theBuffer);
	rlSendBufferData(rlGetAgentConnection(), &theBuffer, agentState);

	rlBufferClear(&theBuffer);
	rlRecvBufferData(rlGetAgentConnection(), &theBuffer, &agentState);
	assert(agentState == kAgentCleanup);

        rlBufferDestroy(&theBuffer);
	
	freeRLStructPointer(globalAction);
	globalAction=0;

	if (theOutMessage != 0) {
	  free(theOutMessage);
	  theOutMessage = 0;
	}
}