Exemple #1
0
void getMaxEnergy(int matrix[][4],int M,int N,int x,int y,int e,int& max_e)
{
	e += matrix[x][y];
	if (x == M-1 && y == N-1)
	{
		if (e > max_e)
			max_e = e;
		return;
	}
	int tmp = 	matrix[x][y];
	matrix[x][y] = 0;
	if (y != N-1 && matrix[x][y+1] != 0)
	{
		getMaxEnergy(matrix,M,N,x,y+1,e,max_e);
	}
	if (y != 0 && matrix[x][y-1] != 0)
	{
		getMaxEnergy(matrix,M,N,x,y-1,e,max_e);
	}
	if (x != M-1 && matrix[x+1][y] != 0)
	{
		getMaxEnergy(matrix,M,N,x+1,y,e,max_e);
	}
	if (x != 0 && matrix[x-1][y] != 0)
	{
		getMaxEnergy(matrix,M,N,x-1,y,e,max_e);
	}
	matrix[x][y] = tmp;
}
Exemple #2
0
detail::Configuration *Mechanoid::getConfiguration()
{
    if (configuration)
        return configuration;

    // create new working configuration from the initial one

    // do not create new configuration while in db tool mode
    if (getSettings().flags[gfDbTool])
        return initial_configuration;

    configuration = getStorage()->configurations.createAtEnd(*initial_configuration);
    configuration->deepCopyFrom(*initial_configuration);

    // to differ from initial configurations in DB Tool
    configuration->text_id += L" - " + getName();

    // replace pointers
    auto c = replace<Configuration>(configuration.get());
    for (auto &w : c->weapons)
        replace<ConfigurationWeapon>(w);

    // setup
    c->setMechanoid(this);
    c->armor = c->getMaxArmor();
    c->energy = c->getMaxEnergy();
    c->energy_shield = c->getMaxEnergyShield();

    return configuration;
}
Exemple #3
0
int main(int argc, char* argv[])
{
	int max_e = 0;
	int matrix[][4] = {{1,1,0,0},{2,1,1,0},{1,1,1,0},{1,1,1,1}};
	getMaxEnergy(matrix,4,4,0,0,0,max_e);
	printf("max energy %d\n",max_e);
	return 0;
}
Exemple #4
0
void		FragTrap::setEnergy( int x ) {
	if ( x > getMaxEnergy())
		this->_energy = getMaxEnergy();
	else {
		this->_energy = x; }
}