Exemple #1
0
Bot::Bot(int id) : AEntity(id), _health(50), _y(0)
{
  _timerShoot = new Timer(true);
  _sprite = "sprite1.png";
  _name = _sprite;
  _type = E_BOT;
  addSystem(C_HEALTH);
  addSystem(C_POSITION);
  addSystem(C_HITBOX);
  generateX();
  generateY();
  dynamic_cast<SystemPos*>(_systemManager->getSystemByComponent(C_POSITION))->update(_x, _y);
  dynamic_cast<SystemHitbox*>(_systemManager->getSystemByComponent(C_HITBOX))->update(refreshHitbox());
}
    Mahalanobis TogersonMetricLearner::learnMetric() {

        dim = getVectorDim();
        sampleCount = getSampleCount();


        int iIdx = selectI();

        mat B = generateB(iIdx);
        mat X = generateX();
        mat Y = generateY(B);
        mat Z = generateZ(X, Y);
        mat A = Z.t() * Z;

        // normalize it for convenience
        A = 1 / A(0, 0) * A;

        return Mahalanobis(A);

    }
Exemple #3
0
//## Operation: nextValue%36B6D4CD036C
//	********************************************************************************
//
//	Name: RetCode nextValue(Float *pValue)
//
//	Description: Returns the next value of the Uniform distribution.
//
//	Output parameters: Float *pValue;  //next number generated.
//
//	Returns: Zero - successful
//	         Otherwise - error
//
//	********************************************************************************
RetCode BaseGen::nextValue (Float *pValue)
{
  //## begin BaseGen::nextValue%36B6D4CD036C.body preserve=yes
	Int j;
	Float nextNumber;
	Float uniform;

	j = (Int) ((__int64)lenVector * pY[indVector] / moduleY);
	nextNumber = ((Float)pV[j]) / moduleX;
	uniform = nextNumber * (maxValue - minValue) + minValue;
	pV[j] = pX[indVector];
	indVector++;
	if (indVector >= lenVector)
	{
		generateX();
		generateY();
		indVector = 0;
	}
	*pValue = uniform;

	return SCH_SUCCESS;
  //## end BaseGen::nextValue%36B6D4CD036C.body
}
Exemple #4
0
//## Operation: BaseGen%36B6DB4B02FE
//	********************************************************************************
//
//	Name: BaseGen(Ulong seed = 78562, Float minVal = 0, Float maxVal = 1)
//
//	Description: Non-default constructor - requires the initial seed and range to generate the random variables.
//
//	Input parameters: Ulong seed;       //seed to begin the random number generation
//	                  Float minVal = 0; //lower boundary of the range
//	                  Float maxVal = 1; //upper boundary of the range
//
//	Returns: none
//
//	Remarks: The seed value must be: 0 <= seed <= MAX_WORD; and minVal < maxVal.
//
//	********************************************************************************
BaseGen::BaseGen (Ulong seed, Float minVal, Float maxVal)
  //## begin BaseGen::BaseGen%36B6DB4B02FE.hasinit preserve=no
      : firstSeedX(seed),
        firstSeedY(78562),
        incrementX(1),
        incrementY(1),
        lenVector(100),
        maxValue(maxVal),
        minValue(minVal),
        moduleX(0x10000000),
        moduleY(0x04000000),
        multiplierX(5),
        multiplierY(9)
  //## end BaseGen::BaseGen%36B6DB4B02FE.hasinit
  //## begin BaseGen::BaseGen%36B6DB4B02FE.initialization preserve=yes
  //## end BaseGen::BaseGen%36B6DB4B02FE.initialization
{
  //## begin BaseGen::BaseGen%36B6DB4B02FE.body preserve=yes
	RetCode rc = SCH_SUCCESS;
	Int i;

	if ((firstSeedX < 0) || (firstSeedX > MAX_WORD) || (minValue >= maxValue))
	{
		rc = SCH_INVALID_PARAMETER;
	}

	if (rc == SCH_SUCCESS)
	{
		pX = new Ulong [lenVector];
		if (pX == NULL)
		{
			rc = SCH_ALLOCATION_ERROR;
		}
	}

	if (rc == SCH_SUCCESS)
	{
		pY = new Ulong [lenVector];
		if (pY == NULL)
		{
			rc = SCH_ALLOCATION_ERROR;
		}
	}

	if (rc == SCH_SUCCESS)
	{
		pV = new Ulong [lenVector];
		if (pV == NULL)
		{
			rc = SCH_ALLOCATION_ERROR;
		}
	}

	if (rc != SCH_SUCCESS)
	{
		throw SchException (rc);
	}

	for (i=0; i<lenVector; i++)
	{
		pX[i] = 0;
		pY[i] = 0;
		pV[i] = 0;
	}

	// Initialize: generating the first numbers
	nextSeedX = firstSeedX;
	nextSeedY = firstSeedY;
	generateX();
	generateY();
	indVector = 0;
	for (i=0; i<lenVector; i++)
	{
		pV[i] = pX[i];
	}
	generateX();

  //## end BaseGen::BaseGen%36B6DB4B02FE.body
}