Vector3f AIManager::randVec3f()
{
    std::default_random_engine generator;
    std::uniform_real_distribution<double> distribution(0.0, 1.0);
    std::uniform_real_distribution<double> placement(0.0, (double)Overlay::OVERLAY_WIDTH/2);
    float quadrant = placement(generator);
    float x = placement(generator);
    float z = placement(generator);
    if(quadrant >= 0 && quadrant < 0.25f)
    {
        return Vector3f(x, 0.5f, z);    //Quadrant I Cartesian (Pos X and pos Z)
    }
    if(quadrant >= 0.25f && quadrant < 0.5f)
    {
        return Vector3f(-x, 0.5f, z);   //Quadrant II
    }
    if(quadrant >= 0.5f && quadrant < 0.75f)
    {
        return Vector3f(-x, 0.5f, -z);  //Quadrant III
    }
    else
    {
        return Vector3f(x, 0.5f, z);    //Quadrnat IV
    }
}   
Пример #2
0
void StaffText::layout()
      {
      if (autoplace())
            setUserOff(QPointF());
      QPointF p(textStyle().offset(spatium()));
      if (placement() == Element::Placement::BELOW)
            p.ry() =  - p.ry() + lineHeight();
      setPos(p);
      Text::layout1();
      if (!parent()) // palette & clone trick
          return;

      if (autoplace() && segment()) {
            qreal minDistance = score()->styleP(StyleIdx::dynamicsMinDistance);  // TODO
            Shape s1          = segment()->staffShape(staffIdx()).translated(segment()->pos());
            Shape s2          = shape().translated(segment()->pos());

            if (placement() == Element::Placement::ABOVE) {
                  qreal d = s2.minVerticalDistance(s1);
                  if (d > -minDistance)
                        rUserYoffset() = -d - minDistance;
                  }
            else {
                  qreal d = s1.minVerticalDistance(s2);
                  if (d > -minDistance)
                        rUserYoffset() = d + minDistance;
                  }
            }
      adjustReadPos();
      }
Пример #3
0
int main(int argc, char** argv){
    uint32_t num_cores = numa_num_configured_cpus();
    uint32_t num_nodes = numa_max_node()+1;

    bool hyper = false;
    if (argc == 2) {
        num_cores = num_cores/2;
        hyper = true;
    }

    FILE* f;
    char name[128];
    for (int j = 2; j < num_cores+1; j++) {
        uint32_t* rr = placement(j, false, hyper);
        uint32_t* fill = placement(j, true, hyper);
        sprintf(name,"rank_files/rfile_fill_%d", j);
        f = fopen(name, "w+");

        for (int i = 0; i < j; i++) {
            if (i+1 < j) {
                fprintf(f,"rank %d=localhost slot=%d \n",i, fill[i]);
                printf("%d,", fill[i]);
            } else {
                printf("%d", fill[i]);
                fprintf(f,"rank %d=localhost slot=%d \n",i, fill[i]);
            }
        }

        printf("\n");
        fprintf(f,"\n");

        fflush(f);
        fclose(f);

        sprintf(name,"rank_files/rfile_rr_%d", j);
        f = fopen(name, "w+");

        for (int i = 0; i < j; i++) {
            if (i+1 < j) {
                fprintf(f,"rank %d=localhost slot=%d \n", i, rr[i]);
                printf("%d,", rr[i]);
            } else {
                printf("%d", rr[i]);
                fprintf(f,"rank %d=localhost slot=%d \n", i, rr[i]);
            }
        }
        printf("\n");

        fflush(f);
        fclose(f);
    }


}
Пример #4
0
void MSEntryFieldCombo::comboButtonLabel(const MSString& label_)
{
    _buttonLabel = label_;
    if(_buttonLabel == "") unsetBit(TextButton);
    else setBit(TextButton);
    placement();
}
Пример #5
0
bool Fermata::setProperty(Pid propertyId, const QVariant& v)
      {
      switch (propertyId) {
            case Pid::PLACEMENT: {
                  Placement p = Placement(v.toInt());
                  if (p != placement()) {
                        QString s = Sym::id2name(_symId);
                        bool up = placeAbove();
                        if (s.endsWith(up ? "Above" : "Below")) {
                              QString s2 = s.left(s.size() - 5) + (up ? "Below" : "Above");
                              _symId = Sym::name2id(s2);
                              }
                        setPlacement(p);
                        }
                  }
                  break;
            case Pid::PLAY:
                  setPlay(v.toBool());
                  break;
            case Pid::TIME_STRETCH:
                  setTimeStretch(v.toDouble());
                  score()->fixTicks();
                  break;
            default:
                  return Element::setProperty(propertyId, v);
            }
      triggerLayout();
      return true;
      }
Пример #6
0
void KWTextImage::drawCustomItem( QPainter* p, int x, int y, int wpix, int hpix, int /*ascentpix*/, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected, int /*offset*/,  bool drawingShadow)
{
    if ( drawingShadow )
        return;

    // (x,y) is the position of the inline item (in pixels)
    // (wpix,hpix) is the size of the inline item (in pixels)
    // (cx,cy,cw,ch) is the rectangle to be painted, in pixels too
    if ( m_image.isNull() ) {
        kdDebug() << "KWTextImage::draw null image!" << endl;
        p->fillRect( x, y, 50, 50, cg.dark() );
        return;
    }

    QSize imgSize( wpix, hpix );

    QRect rect( QPoint(x, y), imgSize );
    if ( !rect.intersects( QRect( cx, cy, cw, ch ) ) )
        return;

    QPixmap pixmap=m_image.generatePixmap( imgSize, true );
    //if ( placement() == PlaceInline )
        p->drawPixmap( x, y, pixmap );
    //else
    //    p->drawPixmap( cx, cy, pixmap, cx - x, cy - y, cw, ch );

    if ( selected && placement() == PlaceInline && p->device()->devType() != QInternal::Printer ) {
        p->fillRect( rect , QBrush( cg.highlight(), QBrush::Dense4Pattern) );
    }
}
Пример #7
0
void MSLayout::computeSize(void)
{
  drawBackground();
  placement();
  positionLabel();
  drawShadow();  
}
Пример #8
0
void Ottava::setYoff(qreal val)
      {
      qreal _spatium = spatium();
      qreal yo(score()->styleS(StyleIdx::ottavaY).val() * _spatium);
      if (placement() == Element::Placement::BELOW)
            yo = -yo + staff()->height();
      rUserYoffset() += val * _spatium - yo;
      }
Пример #9
0
void TempoText::layout()
      {
      Text::layout();
      if (placement() == BELOW) {
            rypos() = -rypos() + 4 * spatium();
            // rUserYoffset() *= -1;
            // text height ?
            }
      }
Пример #10
0
 void add_path(T & path)
 {
     marker_placement_e placement_method = sym_.get_marker_placement();
     box2d<double> bbox_(0,0, src_.width(),src_.height());
     if (placement_method != MARKER_LINE_PLACEMENT)
     {
         double x = 0;
         double y = 0;
         if (placement_method == MARKER_INTERIOR_PLACEMENT)
         {
             if (!label::interior_position(path, x, y))
                 return;
         }
         else
         {
             if (!label::centroid(path, x, y))
                 return;
         }
         agg::trans_affine matrix = marker_trans_;
         matrix.translate(x,y);
         box2d<double> transformed_bbox = bbox_ * matrix;
         if (sym_.get_allow_overlap() ||
             detector_.has_placement(transformed_bbox))
         {
             render_raster_marker(matrix);
             if (!sym_.get_ignore_placement())
             {
                 detector_.insert(transformed_bbox);
             }
             if (!placed_)
             {
                 pixmap_.add_feature(feature_);
                 placed_ = true;
             }
         }
     }
     else
     {
         markers_placement<T, label_collision_detector4> placement(path, bbox_, marker_trans_, detector_,
                                                                   sym_.get_spacing() * scale_factor_,
                                                                   sym_.get_max_error(),
                                                                   sym_.get_allow_overlap());
         double x, y, angle;
         while (placement.get_point(x, y, angle))
         {
             agg::trans_affine matrix = marker_trans_;
             matrix.rotate(angle);
             matrix.translate(x, y);
             render_raster_marker(matrix);
             if (!placed_)
             {
                 pixmap_.add_feature(feature_);
                 placed_ = true;
             }
         }
     }
 }
Пример #11
0
    void add_path(T & path)
    {
        marker_placement_e placement_method = sym_.get_marker_placement();

        if (placement_method != MARKER_LINE_PLACEMENT)
        {
            double x = 0;
            double y = 0;
            if (placement_method == MARKER_INTERIOR_PLACEMENT)
            {
                if (!label::interior_position(path, x, y))
                    return;
            }
            else
            {
                if (!label::centroid(path, x, y))
                    return;
            }
            agg::trans_affine matrix = marker_trans_;
            matrix.translate(x,y);
            box2d<double> transformed_bbox = bbox_ * matrix;

            if (sym_.get_allow_overlap() ||
                detector_.has_placement(transformed_bbox))
            {
                svg_renderer_.render(ras_, sl_, renb_, matrix, sym_.get_opacity(), bbox_);
                if (!sym_.get_ignore_placement())
                {
                    detector_.insert(transformed_bbox);
                }
            }
        }
        else
        {
            markers_placement<T, Detector> placement(path, bbox_, marker_trans_, detector_,
                                                     sym_.get_spacing() * scale_factor_,
                                                     sym_.get_max_error(),
                                                     sym_.get_allow_overlap());
            double x = 0;
            double y = 0;
            double angle = 0;
            while (placement.get_point(x, y, angle))
            {
                agg::trans_affine matrix = marker_trans_;
                matrix.rotate(angle);
                matrix.translate(x, y);
                svg_renderer_.render(ras_, sl_, renb_, matrix, sym_.get_opacity(), bbox_);
            }
        }
    }
Пример #12
0
void
Controller::RobotPlayer::decideTileAndPiecePlacement()
{
	assert( mCurrentBoard );
	assert( mTilesLeft );
	assert( mTileToPlace );

	Utils::Locations const possibleLocations = mCurrentBoard->getPossibleLocations( *mTileToPlace );
	std::vector< PossiblePlacement > possibilities;
	for ( auto const & location : possibleLocations )
	{
		Model::Rotation rotation = Model::kCw0;
		for ( std::size_t i = 0; i < 4; ++i, rotation = rotateCW( rotation ) )
		{
			if ( mCurrentBoard->isValidTilePlacement( Model::TileOnBoard( *mTileToPlace, rotation ), location ) )
			{
				PossiblePlacement placement( location, rotation );
				std::tie( placement.value, placement.piece ) = determineValuePointBased
				(
					*mCurrentBoard,
					*mTilesLeft,
					*mTileToPlace,
					placement,
					*this,
					mNumberOfPlayers
				);
				possibilities.emplace_back( placement );
			}
		}
	}

	printPossibilities( possibilities );

	assert( !possibilities.empty() );
	makePossibilitiesPositive( possibilities );
	printPossibilities( possibilities );
	PossiblePlacement const chosenPlacement = getBestPossibility( possibilities );
	// PossiblePlacement const chosenPlacement = getRandomPossibility( possibilities );

	std::cout << "Chosen placement:" << std::endl;
	printPossibility( chosenPlacement );

	mTilePlacement = TilePlacement( chosenPlacement.location, chosenPlacement.rotation );
	mPiecePlacement = chosenPlacement.piece;

	assert( mTilePlacement );
}
Пример #13
0
/**
 * \brief Adjust the postion of the balloons.
 * \param elapsed_time The time elapsed since the last call.
 */
void bear::engine::balloon_layer::progress( universe::time_type elapsed_time )
{
  if ( get_level().is_paused() )
    return;

  speaker_list::iterator it;
  balloon_placement placement(get_size().x, get_size().y);

  for ( it = m_speakers.begin(); it != m_speakers.end(); )
    if ( (*it) == (speaker_item*)(NULL) )
      it = m_speakers.erase(it);
    else
      {
        placement.add_speaker( **it, get_bounding_box_on_screen(*it) );
        ++it;
      }

  placement.place_balloons();
} // balloon_layer::progress()
Пример #14
0
void jouer(SDL_Surface* ecran)
{
  niveauc[0] = "./niveau/niveau1.txt";
  niveauc[1] = "./niveau/niveau2.txt";
  decor = IMG_Load("./map/tiles/fondHerbe.jpg");
  arbre = IMG_Load("./map/tiles/arbre.png");
  rocher = IMG_Load("./map/tiles/rocher.png");
  magasin = IMG_Load("./map/tiles/store.png");
  monstre = IMG_Load("./map/tiles/mstr.png");
  boss = IMG_Load("./map/tiles/boss.png");
  pnj = IMG_Load("./map/tiles/pnj.png");
  perso[BAS] = IMG_Load("./map/tiles/bas.png");
  perso[GAUCHE] = IMG_Load("./map/tiles/gauche.png");
  perso[HAUT] = IMG_Load("./map/tiles/haut.png");
  perso[DROITE] = IMG_Load("./map/tiles/droite.png");
  persoActuel = perso[BAS];
  placement(ecran, position);
  SDL_FreeSurface(decor);
}
Пример #15
0
int main(int argc, char **argv) {
    Config config(argc, argv);
    SkFILEWStream wStream(config.output_file_name.value.c_str());
    sk_sp<SkDocument> doc = MakePDFDocument(config, &wStream);
    assert(doc);
    Placement placement(&config, doc.get());

    const std::string &font_file = config.font_file.value;
    sk_sp<SkTypeface> typeface;
    if (font_file.size() > 0) {
        typeface = SkTypeface::MakeFromFile(font_file.c_str(), 0 /* index */);
    }
    SkShaper shaper(typeface);
    assert(shaper.good());
    for (std::string line; std::getline(std::cin, line);) {
        placement.WriteLine(shaper, line.c_str(), line.size());
    }

    doc->close();
    return 0;
}
Пример #16
0
void MSEntryFieldCombo::buttonState(ButtonFlag button_, MSBoolean flag_)
{
    if(button_ == TextButton) return; // use comboButtonLabel instead
    if(bitState(button_) != flag_)
    {
        if(flag_ == MSTrue) setBit(button_);
        else unsetBit(button_);

        switch(button_)
        {
        case UpDownArrows:
            if(_upArrow == 0)   _upArrow=new MSArrow(this,MSArrow::Up);
            if(_downArrow == 0) _downArrow=new MSArrow(this,MSArrow::Down);
            break;
        case ComboButton:
            if (_comboArrow == 0) _comboArrow = new MSArrow(this, MSArrow::Down);
        default:
            break;
        }
    }
    placement();
}
Пример #17
0
void TempoText::layout()
      {
      setPos(textStyle().offset(spatium()));
      Text::layout1();

      // tempo text on first chordrest of measure should align over time sig if present
      //
      Segment* s = segment();
      if (s && !s->rtick()) {
            Segment* p = segment()->prev(Segment::Type::TimeSig);
            if (p) {
                  rxpos() -= s->x() - p->x();
                  Element* e = p->element(staffIdx() * VOICES);
                  if (e)
                        rxpos() += e->x();
                  }
            }

      if (placement() == Element::Placement::BELOW)
            rypos() = -rypos() + 4 * spatium();
      adjustReadPos();
      }
Пример #18
0
void backtrack(int ro)
{
	if(ro == 9)
	{	
		//for(int i = 1; i < 9; i++)	printf("%d ", row[i]);
		//printf("\n");
		if(firsttime)
		{
			maxValue = sum();
			firsttime = false;
		}
		else	maxValue = std::max(maxValue,sum());	
		return;

	}
	for(int trycol = 1; trycol < 9; trycol++)
	{
		if(placement(ro, trycol))
		{
			row[ro] = trycol;
			backtrack(ro+1);
		}
	}
}
Пример #19
0
void MSComposite::configure(void)
{
    placement();
}
Пример #20
0
bool MoBody::write(FILE* moFile) const
{
	std::wstring nameStr = name();
	std::wstring defStr = definitionName();

	// --- begin definition of body

	_ftprintf_s(moFile, L"  model %s\n", defStr.c_str());

	_ftprintf_s(moFile, L"    Modelica.Mechanics.MultiBody.Parts.Body body1 (m = %.8g, I_11 = %.8g, I_22 = %.8g, I_33 = %.8g, I_21 = %.8g, I_31 = %.8g, I_32 = %.8g, r_CM = {%.8g, %.8g, %.8g}) "
						L"annotation(Placement(visible = true, transformation(origin = {0, 10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));\n",
				m_mass,
				m_inertia.moments()[0],  m_inertia.moments()[1],  m_inertia.moments()[2],
				m_inertia.products()[0], m_inertia.products()[1], m_inertia.products()[2],
				m_cg.x(), m_cg.y(), m_cg.z());

	// frame interface
	_ftprintf_s(moFile, L"    Modelica.Mechanics.MultiBody.Interfaces.Frame_a frame annotation(Placement(visible = true, transformation(origin = {0, -100}, extent = {{-10, -10}, {10, 10}}, rotation = 90), iconTransformation(origin = {0, -100}, extent = {{-10, -10}, {10, 10}}, rotation = 90)));\n");

	_ftprintf_s(moFile, L"  equation\n");

	// connect frame interface to body frame
	_ftprintf_s(moFile, L"    connect(body1.frame_a, frame) annotation(Line(points = {{0, 0}, {0, -100}}, color = {95, 95, 95}));\n");

	// --- diagram and icon annotations for definition

	_ftprintf_s(moFile, L"    annotation("
						L"Diagram(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2}))"
						L", Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})");
//						L", Text(origin = {-12, 121}, extent = {{-128, 19}, {152, -21}}, textString = \"%%name%%\")");

	// icon thumbnail if present
	if (m_thumbnail.empty())
		_ftprintf_s(moFile, L"));\n"); // close Icon and annotation
	else
		_ftprintf_s(moFile, L", graphics = {Bitmap(origin = {0, 0}, extent = {{-100, -100}, {100, 100}}, imageSource = \"%S\"), Text(extent = {{-150, 145}, {150, 105}}, textString = \"%%name\", lineColor = {0, 0, 255})}));\n",
			m_thumbnail.c_str());

	_ftprintf_s(moFile, L"  end %s;\n\n", defStr.c_str());

	// --- end definition

	// occurrence
	_ftprintf_s(moFile, L"  %s %s annotation(%s);\n\n", defStr.c_str(), nameStr.c_str(), placement().c_str());

	return true;
}
void PlanePlacementLineSource::update()
{
	source()->endpoint(0,placement()->basis().invert(appendCoord(m_pos,-m_endDepths.first)));
	source()->endpoint(1,placement()->basis().invert(appendCoord(m_pos,-m_endDepths.second)));
}
Пример #22
0
int main(int argc, char **argv)
{
    int core_max = -1;
    if (argc>1) {
        core_max = atoi(argv[1]);
        fprintf(stderr, "Limiting number of cores to %d\n", core_max);
    }

    size_t num_cores = sysconf(_SC_NPROCESSORS_ONLN);
    size_t total = num_cores;
    if (core_max>0 && core_max<total) {
        total = core_max;
    }
    fprintf(stderr, "Running %d threads\n", core_max);
    gl_total = total;

    // Allocate memory for Smelt messages
    gl_msg = (struct smlt_msg**) malloc(sizeof(struct smlt_msg*)*num_cores);
    COND_PANIC(gl_msg!=NULL, "Failed to allocate gl_msg");

    for (size_t i=0; i<num_cores; i++) {
        gl_msg[i] = smlt_message_alloc(56);
    }

    // Determine NUMA properties
    size_t max_node = numa_max_node();
    size_t cores_per_node = num_cores/(max_node+1);
    if (total<num_cores) {
        size_t tmp = cores_per_node;
        cores_per_node = tmp/(num_cores/total);
        fprintf(stderr, "Scaling down cores_per_node from %zu to %zu\n",
                tmp, cores_per_node);
    }

    chan = (struct smlt_channel**) malloc(sizeof(struct smlt_channel*)*num_cores);
    COND_PANIC(chan!=NULL, "Failed to allocate chan");

    for (size_t i = 0; i < num_cores; i++) {
        chan[i] = (struct smlt_channel*) malloc(sizeof(struct smlt_channel)*num_cores);
    }

    typedef void* (worker_func_t)(void*);
    worker_func_t * workers[NUM_EXP] = {
        &ab,
        &reduction,
        &agreement,
        &barrier,
    };

    const char *labels[NUM_EXP] = {
        "Atomic Broadcast",
        "Reduction",
        "Agreement",
        "Barrier",
    };

    const char *topo_names[NUM_TOPO] = {
        "mst",
        "bintree",
        "cluster",
        "badtree",
        "fibonacci",
        "sequential",
        "adaptivetree-shuffle-sort",
        "adaptivetree",
    };

    errval_t err;
    err = smlt_init(num_cores, true);
    if (smlt_err_is_fail(err)) {
        printf("FAILED TO INITIALIZE !\n");
        return 1;
    }

    // Full mesh of channels
    for (unsigned int i = 0; i < num_cores; i++) {
        for (unsigned int j = 0; j < num_cores; j++) {
            struct smlt_channel* ch = &chan[i][j];
            err = smlt_channel_create(&ch, (uint32_t *)&i, (uint32_t*) &j, 1, 1);
            if (smlt_err_is_fail(err)) {
                printf("FAILED TO INITIALIZE CHANNELS !\n");
                return 1;
            }
        }
    }

    // Foreach topology
    for (int top = 0; top < NUM_TOPO; top++) {

        // For an increasing number of threads
        for (size_t num_threads = 2; num_threads<total+1;
             num_threads+=INC_CORES) {

            // For an increasing round-robin batch size
            for (size_t step=0; step<=cores_per_node; step+=INC_STEPS) {

                coreid_t cores[num_threads];

                // Make available globally
                gl_num_threads = num_threads;
                gl_cores = cores;
                gl_step = step;

                placement(num_threads, step, cores);

                printf("Cores (%zu threads): ", num_threads);
                for (size_t dbg=0; dbg<num_threads; dbg++) {
                    printf(" %" PRIuCOREID, cores[dbg]);
                }
                printf("\n");

                pthread_barrier_init(&bar, NULL, num_threads);
                struct smlt_generated_model* model = NULL;

                fprintf(stderr, "%s nthreads %zu \n", topo_names[top], num_threads);
                err = smlt_generate_model(cores, num_threads, topo_names[top], &model);

                if (smlt_err_is_fail(err)) {
                    printf("Failed to generated model, aborting\n");
                    return 1;
                }

                struct smlt_topology *topo = NULL;
                smlt_topology_create(model, topo_names[top], &topo);
                active_topo = topo;

                err = smlt_context_create(topo, &context);
                if (smlt_err_is_fail(err)) {
                    printf("FAILED TO INITIALIZE CONTEXT !\n");
                    return 1;
                }

                for (int i = 0; i < NUM_EXP; i++){


                    printf("----------------------------------------\n");
                    printf("Executing experiment %s\n", labels[i]);
                    printf("----------------------------------------\n");

                    struct smlt_node *node;
                    for (uint64_t j = 0; j < num_threads; j++) {
                        node = smlt_get_node_by_id(cores[j]);
                        assert(node!=NULL);
                        err = smlt_node_start(node, workers[i], (void*)(uint64_t) cores[j]);
                        if (smlt_err_is_fail(err)) {
                            printf("Staring node failed \n");
                        }
                    }

                    for (unsigned int j=0; j < num_threads; j++) {
                        node = smlt_get_node_by_id(cores[j]);
                        smlt_node_join(node);
                    }
                }
            }
        }
    }

    // Free space for messages
    for (size_t i=0; i<num_cores; i++) {
        smlt_message_free(gl_msg[i]);
    }

    return 0;
}
Пример #23
0
 bool theirPlacement() const { return placement() && !ourRestart; }
Пример #24
0
int main(){
  int i,j,x,y,a,b,t1=0,t2=0,m;
for(i=0;i<=4;i++)
{
	for(j=0;j<=4;j++)
	{
		scanf("%d",&arr[i][j]);
	}
}

  scanf("%d",&p);
  if(p==1)
  q=2;
  else 
  q=1;
  	count=0;
 
  	
  		t1=myballs(p);
  	
  		t2=myballs(q);
  		
  		count=count+t1+t2;
 
  if(count<=3)
  {
  		if(arr[0][0]==0)
  		{	x=0;
  		y=0;
		  }
  	
  		else if(arr[4][0]==0)
  		{	x=4;
  		y=0;
		  }
  	
  		else if(arr[0][4]==0)
  		{
  			x=0;
  		y=4;
		  }
  		
  		else
  		{
  			x=4;
  		y=4;
		  }
  }
  else
  {
  	count2=checkcrush(p);
  
    m=crushposition(p);
  
	
    if(m==999)
    {
    	placement(&x,&y);
	}
	else
	{
		extractor(m,&x,&y);
	}

  }
  if(x<0||x>4||y<0||y>4)
  {
  	do
  	{
	  
  	x=rand()%5;
  	y=rand()%5;
  }while(arr[x][y]/10==q);
  }
 
  printf("%d %d",x,y);
  
}
Пример #25
0
int main(int argc, char **argv)
{
    char name[100];
    num_threads = sysconf(_SC_NPROCESSORS_ONLN);
    errval_t err;

    err = smlt_init(num_threads, true);
    if (smlt_err_is_fail(err)) {
	    printf("FAILED TO INITIALIZE !\n");
	    return 1;
    }

    for (int i = 4; i < num_threads+1; i++) {

        pthread_barrier_init(&bar, NULL, i);
        printf("Running %d cores\n", i);

        active_threads = i;
        uint32_t* cores = placement(i, false);
        for (int j = 0; j < i; j++) {
            printf("Cores[%d]=%d\n",j,cores[j]);
        }

        active_cores = cores;

        printf("Generating model\n");
        struct smlt_generated_model* model = NULL;
        err = smlt_generate_model(cores, i, NULL, &model);
        if (smlt_err_is_fail(err)) {
            exit(0);
        }

        printf("Generating topology\n");
        struct smlt_topology *topo = NULL;
        sprintf(name, "adaptivetree_rr%d",i);
        smlt_topology_create(model, name, &topo);
        active_topo = topo;

        printf("Generating context\n");
        err = smlt_context_create(topo, &context);
        if (smlt_err_is_fail(err)) {
            printf("FAILED TO INITIALIZE CONTEXT !\n");
            return 1;
        }
       
        printf("----------------------------------------\n");
        printf("Executing Barrier with %d cores rr\n", i);
        printf("----------------------------------------\n");
        
        struct smlt_node *node;
        for (uint64_t j = 0; j < i; j++) {
            node = smlt_get_node_by_id(cores[j]);
            err = smlt_node_start(node, barrier, (void*) j);
            if (smlt_err_is_fail(err)) {
                printf("Staring node failed \n");
            }   
        }

        for (int j=0; j < i; j++) {
            node = smlt_get_node_by_id(cores[j]);
            smlt_node_join(node);
        }
    }

    for (int i = 4; i < num_threads+1; i++) {

        pthread_barrier_init(&bar, NULL, i);

        active_threads = i;
        uint32_t* cores = placement(i, true);
        for (int j = 0; j < i; j++) {
            printf("Cores[%d]=%d\n",j,cores[j]);
        }

        active_cores = cores;

        struct smlt_generated_model* model = NULL;
        err = smlt_generate_model(cores, i, NULL, &model);
        if (smlt_err_is_fail(err)) {
            exit(0);
        }

        struct smlt_topology *topo = NULL;
        sprintf(name, "adaptivetree_fill%d",i);
        smlt_topology_create(model, name, &topo);
        active_topo = topo;

        err = smlt_context_create(topo, &context);
        if (smlt_err_is_fail(err)) {
            printf("FAILED TO INITIALIZE CONTEXT !\n");
            return 1;
        }
       
        printf("----------------------------------------\n");
        printf("Executing Barrier with %d cores fill\n", i);
        printf("----------------------------------------\n");
        
        struct smlt_node *node;
        for (uint64_t j = 0; j < i; j++) {
            node = smlt_get_node_by_id(cores[j]);
            err = smlt_node_start(node, barrier, (void*) j);
            if (smlt_err_is_fail(err)) {
                printf("Staring node failed \n");
            }   
        }

        for (int j=0; j < i; j++) {
            node = smlt_get_node_by_id(cores[j]);
            smlt_node_join(node);
        }
    }

}
Пример #26
0
/**
*\fn partie (void) 
*\brief lance les differente fonction utile au deroulement d'une partie
*/
int partie (int niveau) 

{
	int win = 0;
	int lose = 0;
	int i,j;
	
	for(i = 0; i < (escouade1.nb_perso)*2; i= i + 2){
		tab_pv[i] = i/2;
		tab_pv[i+1] = escouade1.perso[i/2].stat.HP;

	}
	init();
	horde1 = generer_horde(horde1,niveau);
	placement(escouade1,horde1);
	affichage();
	while(win == 0 && lose == 0){
		deplacement_joueur();
		attaque_allie();
		resolve_attaque();
		affichage();
		deplacement_ennemi();
		attaque_nemesis();
		resolve_attaque();
		affichage();
		win = 1;
		lose = 1;
		for(i = 1 ; i < N ; i++)
		{
			for(j = 1 ; j < M ; j++) 
			{
				if(mat[i][j] == 1){
					iallie = 1;
					while((tab_a[iallie] != i || tab_a[iallie+1] != j)&&(iallie < 20)){
						iallie = iallie + 3;
					}
					afficher_perso_uni(escouade1.perso[tab_a[iallie-1]]);
					printf("\n\n");
					lose = 0;
				}else if (mat[i][j] == 2){
					iennemi = 1;
					while((tab_e[iennemi] != i || tab_e[iennemi+1] != j)&&(iennemi < 20)){
						iennemi = iennemi + 3;
					}
					afficher_perso_uni(horde1.perso[tab_e[iennemi-1]]);
					printf("\n\n");
					win = 0;
				}
			}
		}
	}
	for(i = 0; i <(escouade1.nb_perso)*2; i = i + 2){
		escouade1.perso[tab_pv[i]].stat.HP = tab_pv[i+1];
	}
	system("clear");
	if (win == 1){
		printf("You Rock !!\n");
		liste_personnage = mise_a_jour_liste(escouade1,liste_personnage);
	}else if (lose == 1){
		printf("You Lose, try harder next time \n");
	}
	return(EXIT_SUCCESS);
}
Пример #27
0
 bool ourPlacement() const { return placement() && ourRestart; }