Beispiel #1
0
void
Engine::randomLight(void)
{
	bool		tab_bool[3] = {randomBool(), randomBool(), randomBool()};
	if (tab_bool[0] == false && tab_bool[1] == false && tab_bool[2] == false)
	{
		tab_bool[0] = true;
		tab_bool[1] = true;
		tab_bool[2] = true;
	}
	this->switchLight(tab_bool[0], tab_bool[1], tab_bool[2]);
}
void mgsCooperSymbols::drawTri(float x, float y, float s) {
  ofPushStyle();
  ofSetColor(symbolColor);
  ofNoFill();
  glLineWidth(thickness);
  if (randomStrokeP) randomStroke();
  if (randomBool()) ofDrawLine(x+s/2, y, x+s, y+s);
  if (randomStrokeP) randomStroke();
  if (randomBool()) ofDrawLine(x, y+s, x+s, y+s);
  if (randomStrokeP) randomStroke();
  if (randomBool()) ofDrawLine(x, y+s, x+s/2, y);
  ofPopStyle();
}
FormInputCollectionPtr StaticFormInputGenerator::generateFormFields(QSet<FormFieldDescriptorConstPtr> fields,
                                                                    ExecutionResultConstPtr) const
{
    QList<FormInputPair> inputs;

    foreach(FormFieldDescriptorConstPtr field, fields) {

        if (mExcludedFormFields.contains(field->getDomElement()->getId())) {
            continue;
        }

        switch (field->getType()) {
        case TEXT:
            inputs.append(FormInputPair(field, InjectionValue(generateRandomString(10))));
            break;
        case BOOLEAN:
            inputs.append(FormInputPair(field, InjectionValue(randomBool())));
            break;
        case FIXED_INPUT:
            if(field->getInputOptions().size()>0){
                inputs.append(FormInputPair(field, InjectionValue(pickRand(field->getInputOptions()))));
                break;
            }
        default:
            inputs.append(FormInputPair(field, InjectionValue(QString(""))));
        }
    }

    return FormInputCollectionPtr(new FormInputCollection(inputs));
}
void mgsCooperSymbols::drawCircle(float x, float y, float s) {
  ofPushStyle();
  ofSetColor(symbolColor);
  ofNoFill();
  glLineWidth(thickness);
  if (randomStrokeP) randomStroke();
  if (randomBool()) ofDrawCircle(x, y, s/1.13);
  ofPopStyle();
}
Beispiel #5
0
char SimpleVCF::getRandomAllele() const{
    if( homozygousREF ){ return corevcf->ref[0]; }
    if( homozygousALT ){ return corevcf->alt[0]; }
    if( heterozygous ){ 
	//pick an allele at random
	if(randomBool())
	    return corevcf->ref[0]; 
	else
	    return corevcf->alt[0]; 
    }
    //error
    //should we allow heterozygous alt ?
    cerr<<"SimpleVCF: Cannot generate a random allele for "<<(*this)<<endl;
    exit(1);    
}
Beispiel #6
0
char SingleAllele::generateRandomAllele(const char ref,const char alt){
    if(totalCount==0){
	// cerr<<"SingleAllele: cannot call generateRandomAlleleBias() where the allele count is 0 :"<<*this<<endl;
	// exit(1);
	return 'N';
    }

    if(refCount > 0  && altCount == 0) //ref
	return ref;

    if(refCount == 0 && altCount > 0) //alt
	return alt;

    if(randomBool())
	return ref;
    else
    	return alt;
}
Beispiel #7
0
TEST( WaveTable, Clone )
{
    int length       = randomInt( 2, 256 );
    float frequency  = randomFloat( 20, 880 );
    WaveTable* table = new WaveTable( length, frequency );

    table->setAccumulator( randomSample( 0.0, ( SAMPLE_TYPE ) length ));

    // randomly create content

    if ( randomBool() )
    {
        for ( int i = 0; i < length; ++i )
            table->getBuffer()[ i ] = randomSample( -1.0, 1.0 );
    }

    // create clone and validate its properties against the source table

    WaveTable* clone = table->clone();

    EXPECT_EQ( table->tableLength, clone->tableLength )
        << "expected cloned WaveTables length to equal the source WaveTables";

    EXPECT_EQ( table->getFrequency(), clone->getFrequency() )
        << "expected cloned WaveTable frequency to equal the source WaveTables";

    EXPECT_EQ( table->getAccumulator(), clone->getAccumulator() )
        << "expected cloned WaveTable accumulator to equal the source WaveTables";

    EXPECT_EQ( table->hasContent(), table->hasContent() )
        << "expected cloned WaveTable hasContent value to equal the source WaveTables";

    if ( table->hasContent() )
    {
        for ( int i = 0; i < length; ++i ) {
            EXPECT_EQ( table->getBuffer()[ i ], clone->getBuffer()[ i ])
                << "expected cloned WaveTable buffer to have equal buffer contents, but it didn't";
        }
    }
    delete table;
    delete clone;
}
Beispiel #8
0
char SimpleVCF::getRandomAlleleUsingPL(int minPLdiffind) const{

    // if(!observedPL){
    // 	cerr<<"SimpleVCF: getRandomAlleleUsingPL() cannot be called is PL value hasn't been defined for "<<*this<<endl;
    // 	exit(1);
    // }

    if(unresolvedGT)
	return 'X'; //unresolved

    if ( (formatFieldPLHetero-formatFieldPLHomoRef) >= minPLdiffind && (formatFieldPLHomoAlt-formatFieldPLHomoRef) >= minPLdiffind) {  //high likelihood of h**o ref, produce 2 alleles ref
	// cout<<position<<"\t"<<"2,0"<<endl;
	return corevcf->ref[0];
    } else{
	if ((formatFieldPLHetero-formatFieldPLHomoAlt) >= minPLdiffind && (formatFieldPLHomoRef-formatFieldPLHomoAlt) >= minPLdiffind) {  //high likelihood of h**o alt, produce 2 alleles alt
	    // cout<<position<<"\t"<<"0,2"<<endl;
	    return corevcf->alt[0];
	} else {
	    if ((formatFieldPLHomoRef-formatFieldPLHetero) >= minPLdiffind && (formatFieldPLHomoAlt-formatFieldPLHetero) >= minPLdiffind) { //high likelihood of hetero, produce 1 allele of each
		// cout<<position<<"\t"<<"1,1"<<endl;
		if(randomBool())
		    return corevcf->ref[0]; 
		else
		    return corevcf->alt[0]; 

	    }else{
		if ((formatFieldPLHomoRef-formatFieldPLHomoAlt) >= minPLdiffind && (formatFieldPLHetero-formatFieldPLHomoAlt) <minPLdiffind ) { //high likelihood of at least one alt, produce 1 allele alt 
		    // cout<<position<<"\t"<<"0,1"<<endl;
		    return corevcf->alt[0];
		}else{
		    if ( (formatFieldPLHomoAlt-formatFieldPLHomoRef) >= minPLdiffind && (formatFieldPLHetero-formatFieldPLHomoRef) < minPLdiffind ) { // high likelihood of at least one ref, produce 1 allele ref
			// cout<<position<<"\t"<<"1,0"<<endl;
			return corevcf->ref[0]; 
		    }else{
			return 'X'; //unresolved
		    }
		}
	    }
	}
    }// end all cases
}
Beispiel #9
0
	bool makeCorridor(int x, int y, Direction dir)
	{
		static const int minCorridorLength = 3;
		static const int maxCorridorLength = 6;

		Rect corridor;
		corridor.x = x;
		corridor.y = y;

		if (randomBool()) // horizontal corridor
		{
			corridor.width = randomInt(minCorridorLength, maxCorridorLength);
			corridor.height = 1;

			if (dir == North)
			{
				corridor.y = y - 1;

				if (randomBool()) // west
					corridor.x = x - corridor.width + 1;
			}

			else if (dir == South)
			{
				corridor.y = y + 1;

				if (randomBool()) // west
					corridor.x = x - corridor.width + 1;
			}

			else if (dir == West)
				corridor.x = x - corridor.width;

			else if (dir == East)
				corridor.x = x + 1;
		}

		else // vertical corridor
		{
			corridor.width = 1;
			corridor.height = randomInt(minCorridorLength, maxCorridorLength);

			if (dir == North)
				corridor.y = y - corridor.height;

			else if (dir == South)
				corridor.y = y + 1;

			else if (dir == West)
			{
				corridor.x = x - 1;

				if (randomBool()) // north
					corridor.y = y - corridor.height + 1;
			}

			else if (dir == East)
			{
				corridor.x = x + 1;

				if (randomBool()) // north
					corridor.y = y - corridor.height + 1;
			}
		}

		if (placeRect(corridor, Corridor))
		{
			if (dir != South && corridor.width != 1) // north side
				_exits.emplace_back(Rect{ corridor.x, corridor.y - 1, corridor.width, 1 });
			if (dir != North && corridor.width != 1) // south side
				_exits.emplace_back(Rect{ corridor.x, corridor.y + corridor.height, corridor.width, 1 });
			if (dir != East && corridor.height != 1) // west side
				_exits.emplace_back(Rect{ corridor.x - 1, corridor.y, 1, corridor.height });
			if (dir != West && corridor.height != 1) // east side
				_exits.emplace_back(Rect{ corridor.x + corridor.width, corridor.y, 1, corridor.height });

			return true;
		}

		return false;
	}
Beispiel #10
0
//Init
void ce_game::create_level(){

	//Loop through each grid reference
	for (int row = 0; row<level->size.height ; row++){
		for (int col = 0; col<level->size.width ; col++){

			//Get object at grid reference
			int type = level->layout[row][col];
			ce_actor *object;

			//Create blank
			if (type == cet_blank){
				object = new ce_actor();
				object->type = cet_blank;
			//Create wall
			}else if (type == cet_wall){
				object = new ce_wall();
				object->type = cet_wall;
			//Cerate ladder
			}else if (type == cet_ladder){
				object = new ce_ladder();
				object->type = cet_ladder;
			//Create egg
			}else if (type == cet_egg){
				object = new ce_egg();
				object->type = cet_egg;
			//Create grain
			}else if (type == cet_grain){
				object = new ce_grain();
				object->type = cet_grain;
			//Create wall invisible
			}else if (type == cet_inv_wall){
				object = new ce_wall_inv();
				object->type = cet_inv_wall;
			}

			//Construct object
			object->frame.cord = makeCord(col * grid_w, row * grid_h);
			level->grid[row][col] = object;
		}
	}

	//Create player
	player = new ce_player();
	player->frame.cord = makeCord(level->start.x,level->start.y);
	player->level = level;
	player->clearAnimation();

	//Create swans and add to swan vector list
	for (int i=0; i<level->swans.size(); i++){
		ce_swan *swan = new ce_swan();
		swan->frame.cord = level->swans[i];
		swan->level = level;
		swan->clearAnimation();
		swans.push_back(swan);
		//Start in random direction
		if (randomBool()){
			swans[i]->walkLeft();
		}else{
			swans[i]->walkRight();
		}
	}
}