Exemplo n.º 1
0
/// Constructs new random solution; used by PSA, MOSA, SMOSA, NSGA and SPEA
TDSESolution::TDSESolution() : TMOMHSolution() {
    this->WeightVector = GetRandomWeightVector();
    //A solution is formed by filling the map
    //param2Value.
    createRandom(*this);
    // Now I have to set the objective value for the execution time and the power consumption;
    // in order to do this I have to resort to simulation
    this->updateObjectives();
}
Exemplo n.º 2
0
/// Constructs new solution; if there is knowledge on the problem it is possible
/// to use heuristics trying to make the generated solution as good as possible.
/// it might be the case of performing a local search at then end (but this is
/// a hibridization of the algorithm)
TDSESolution::TDSESolution(TScalarizingFunctionType ScalarizingFunctionType,
    TPoint & ReferencePoint, TWeightVector WeightVector, TNondominatedSet & NondominatedSet):
        TMOMHSolution(ScalarizingFunctionType, ReferencePoint, WeightVector, (TNondominatedSet &)NondominatedSet){
    // well, I can simply create a random solution and then modify it through a local
    // search
    createRandom(*this);
    this->updateObjectives();
    //I now perform local search in order to improve the found solution
    this->LocalSearch(ReferencePoint, NondominatedSet);
}
Exemplo n.º 3
0
	Vector * VectorCreator::Create(CreateType createType, string vectorName)
	{
		switch (createType)
		{
		case CreateType::FromConsole:
			return createFromConsole(vectorName);
		case CreateType::Random:
			return createRandom();
		}
		return nullptr;
	}
Exemplo n.º 4
0
// creates a new game field with random tiles
// until the game field is playable
void GameField::create(void)
{
    do
    {
        // create field with random tiles
        createRandom();
    
        // cascade tiles until not more than two eqal tiles are next to each other
        cascade();
        
    } while ( !isPlayable() );
}
Exemplo n.º 5
0
int mainLoop(int passengerThreshold, int maxLevels, int maxWaiters, int maxPassengers, int elevatorSteps,int sleepMS, int doorTime){

	int newPassenger = 1;
	initElevator(maxLevels, maxPassengers, elevatorSteps, doorTime);
	initPassengers(maxWaiters, maxPassengers, maxLevels);

	while(running){
		simulateStep();
		newPassenger += (autoNew) ? 1 : 0;
		if(newPassenger > passengerThreshold){
			createRandom(1);
			newPassenger = 1;
		}
		usleep(sleepMS * microToMilli);
	}
	return running; //should be "0"
}
Exemplo n.º 6
0
unsigned int Zombie::process(float animate)
{
	pos=Vector(x,0,0);
	if(!onFire && moving)
	{
		if(x<390)
		{
			facing=1;
			x+=g_speed*animate*speed;
		}
		else if(x>410)
		{
			facing=0;
			x-=g_speed*animate*speed;
		}
	}
	if(punchedBack>=GetTickCount())
	{
		float diff=1-(float)(punchedBack-GetTickCount())/100.0f;
		if(pushDir)		x=punchX-diff*80;
		else			x=punchX+diff*80;
	}

	if(GetTickCount()-animTick>100)
	{
		animTick=GetTickCount();
		animation++;
		animation%=4;
	}

	if(GetTickCount()-ignitionTime>=IGNITEFOR && onFire)
	{
		if(fireID!=-1)
			parts.KillChild(fireID);
		if(respawn)
			createRandom();

		if(score)
			*score+=50;
		return 50;
	}

	return 0;
}
Exemplo n.º 7
0
Atom3::Atom3(float time) {
    createRandom(time);
}
Exemplo n.º 8
0
int inputLoop(){
	char * buffer = malloc(sizeof(char) * BUFFER_SIZE);
	rInput = 1;
	while(rInput){
		clearBuffer(buffer);
		cleanInputLine();
		char * line = readLine(buffer,BUFFER_SIZE);
		if(line){
			//Analyse and do something with this line...
			if(!strcmp(line,"help")){
				outputLine(HELP_MAIN);
				continue;
			}
			if(!strncmp(line,"help",4)){
				//something was called with help
				line += 5;
				if(!strcmp(line,"new")){
					outputLine(HELP_NEW);
				}
				if(!strcmp(line,"quit")){
					outputLine(HELP_QUIT);
				}
				if(!strcmp(line,"rnew")){
					outputLine(HELP_RNEW);
				}
				if(!strcmp(line,"autonew")){
					outputLine(HELP_AUTONEW);
				}
				// ... more help
				continue;
			}
			// NEW PASSENGER
			if(!strncmp(line,"new",3)){
				line += 4;
				int a, b, c = 1;
				sscanf(line,"%d %d %d",&a,&b,&c);
				while(c--){
					createNew(a,b);
				}
				continue;
			}
			//NEW RANDOM PASSENGER:
			if(!strncmp(line,"rnew",4)){
				line += 5;
				int a = 1;
				sscanf(line,"%d",&a);
				createRandom(a);
			}
			if(!strncmp(line,"autonew",7)){
				line += 8;
				if(!strcmp(line,"on") || !strcmp(line,"off")){
					toggleAutonew(*(line+1) == 'n');
				} else {
					outputLine(HELP_AUTONEW);
				}
				continue;
			}
			// QUIT
			if(!strcmp(line,"quit")){
				stopInputLoop();
				continue;
			}
		}
	}
	free(buffer);
	return rInput;
}