void Equilibrium(Vector& x, Vector& a, int rxn)
{
  const double c2 = 10, c3 = 1000;
  double xt = x(0) + 2*x(1);
  double b = xt + 0.5*c3/c2;
  double sd;
  x(1) = 0.5*(b - sqrt(b*b - xt*xt));
  x(0) = xt - 2*x(1);
  sd = sqrt( c3*x(1)/(-4*c2*x(1) + c2*(2*xt + 3) + c3)) ;
  x(1) = x(1) + sd*normalRand();
  x(0) = xt - 2*x(1);
}
Example #2
0
void Level::generate(int rooms, int radius)
{
	this->clear();
	this->onRoomGeneration = 1;
	this->current_room = 0;
	this->onRoomSeparation = 0;
	this->onRoomGenerationFinished = 0;
	this->onRoomSeparationFinished = 0;
	this->onRoomClearing = 0;
	this->onRoomClearingFinished = 0;
	this->onDelaunay = 0;
	this->onDelaunayFinished = 0;
	this->onCorridor = 0;
	this->onCorridorFinished = 0;
	this->current_corridor = 0;
	this->corridor_tiles = 0;
	
	this->separation_steps = 0;
	this->deleted_rooms = 0;

	this->max_rooms = rooms;
	this->rands = (double*) realloc(this->rands, sizeof(double) * this->max_rooms);
	this->randMax = -1.f;
	this->max_radius = radius-1;
	srand(SDL_GetTicks());
	for(int i =0; i<rooms; i++)
	{
		this->rands[i] = abs(normalRand());
		if(this->randMax < this->rands[i] || i == 0)
			this->randMax = this->rands[i];
	}
	//normalize
	for(int i =0; i<rooms; i++)
	{
		this->rands[i] /= randMax;
	}

	this->animation.t_Start();

	delete this->triangulation;
	this->triangulation = new delTriangulation();
}