void setHandler(int luaHandler) {
     if (mLuaHandler == luaHandler) {
         return;
     }
     resetHandler();
     mLuaHandler = luaHandler;
 }
Ejemplo n.º 2
0
void ConstantValuesBrain::initalizeGenome(shared_ptr<AbstractGenome> _genome) {
	if (initializeConstant) {
		if (initializeConstantValue < valueMin) {
			cout << "ERROR: initializeConstantValue must be greater then or equal to valueMin" << endl;
			exit(1);
		}
		if (initializeConstantValue > valueMax) {
			cout << "ERROR: initializeConstantValue must be less then or equal to valueMax" << endl;
			exit(1);
		}
		auto handler = _genome->newHandler(_genome);
		while (!handler->atEOG()) {
			if (valueType == 1) {
				handler->writeInt(initializeConstantValue, valueMin, valueMax);
			} else if (valueType == 0) {
				handler->writeInt(initializeConstantValue, valueMin, valueMax);
			}
		}
		handler->resetHandler();
		handler->writeInt(initializeConstantValue, valueMin, valueMax);
	} else if (initializeUniform) {
		auto handler = _genome->newHandler(_genome);
		int count = 0;
		double randomValue;
		if (valueType == 1) {
			randomValue = Random::getDouble(valueMin, valueMax);
		} else if (valueType == 0) {
			randomValue = Random::getInt(valueMin, valueMax);
		}
		if (count == samplesPerValue) {
			if (valueType == 1) {
				randomValue = Random::getDouble(valueMin, valueMax);
			} else if (valueType == 0) {
				randomValue = Random::getInt(valueMin, valueMax);
			}
		}
		while (!handler->atEOG()) {
			if (count == samplesPerValue) {
				count = 0;
				if (valueType == 1) {
					randomValue = Random::getDouble(valueMin, valueMax);
				} else if (valueType == 0) {
					randomValue = Random::getInt(valueMin, valueMax);
				}
			}
			if (valueType == 1) {
				handler->writeInt(randomValue, valueMin, valueMax);
			} else if (valueType == 0) {
				handler->writeInt(randomValue, valueMin, valueMax);
			}
			count++;
		}
	} else {
		_genome->fillRandom();
	}
}
 ~ValuePotionListenerLua() {
     resetHandler();
 }
 ~SdkboxPlayListenerLua() {
     resetHandler();
 }
	~FlurryAnalyticsListenerLua() {
		resetHandler();
	}
 ~SdkboxAdsListenerLua() {
     resetHandler();
 }
 ~YoutubeListenerLua() {
     resetHandler();
 }
	~IAPListenerLuaManual() {
		resetHandler();
	}
 ~FacebookListenerLua() {
     resetHandler();
 }
	~ChartboostListenerLuaHelper() {
		resetHandler();
	}