Пример #1
0
//スペル文字表示パターンの描画
void graph_spell(){
	if(count == 180	  || count == 2160	|| count == 4140  || count == 6120  || count == 8100 ||
		count == 10080 || count == 12060 || count == 14040 || count == 16020 || count == 18000){
			spcount=0;
			se_flag[5]=1;
	}

	if(count >= 180 && count < 1980){
		graph_cut("Spell1「低速ばらまき弾」",215);
	}
	if(count >= 2160 && count < 3960){
		if(stage<=1)
			graph_cut("Spell2「二段速落下弾」",195);
		else
			graph_cut("Spell2「三段速落下弾」",195);
	}
	if(count >= 4140 && count < 5940){
		graph_cut("Spell3「交差弾」",140);
	}
	if(count >= 6120 && count < 7920){
		graph_cut("Spell4「高速ばらまき弾」",215);
	}
	if(count >= 8100 && count < 9900){
		graph_cut("Spell5「回転ワインダー」",215);
	}
	if(count >= 10080 && count < 11880){
		graph_cut("Spell6「自機狙い複合弾」",215);
	}
	if(count >= 12060 && count < 13860){
		if(stage<=3)
			graph_cut("Spell7「詐欺判定弾」",175);
		else
			graph_cut("Spell7「大弾物量殺し」",195);
	}
	if(count >= 14040 && count < 15840){
		graph_cut("Spell8「左右ワインダー」",215);
	}
	if(count >= 16020 && count < 17820){
		if(stage<=1)
			graph_cut("Spell9「左右&上下拘束弾」",235);
		else
			graph_cut("Spell9「低速移動禁止&拘束弾」",275);

	}
	if(count >= 18000 && count < 19800){
		graph_cut("spell10「波紋疾走」",175);
	}

	if(count>=30 && count<180){
		DrawStringToHandle(135,185,"迫る弾幕を",color[0],font[1]);
		DrawStringToHandle(120,225,"避け続けろ!",color[0],font[1]);
	}
	if(spcount>=1800 && sg_flag==1)
		DrawStringToHandle(55,185,"Get Spell Bonus!!",color[0],font[1]);
}
static vtx_t __par_kwayrefine_GREEDY(
    ctrl_t * const ctrl, 
    graph_t * const graph,
    size_t const niter, 
    kwinfo_t * const kwinfo)
{
  vtx_t c, i, k, nmoved;
  adj_t j;
  wgt_t gain, wgt, mycut, ewgt;
  pid_t to, from;
  size_t pass;
  real_t rgain;
  wgt_t * lpwgts;
  kwnbrinfo_t * myrinfo;
  adjinfo_t const * mynbrs;
  vtx_iset_t * bnd;
  vw_pq_t * q;
  wgt_t * minwgt, * maxwgt;
  update_t up;
  update_combuffer_t * combuffer;

  tid_t const myid = dlthread_get_id(ctrl->comm);

  /* Link the graph fields */
  vtx_t const mynvtxs = graph->mynvtxs[myid];
  wgt_t const * const vwgt = graph->vwgt[myid];

  pid_t ** const gwhere = graph->where;
  wgt_t * const pwgts = graph->pwgts;
  
  pid_t const nparts = ctrl->nparts;

  kwnbrinfo_t * const nbrinfo = kwinfo->nbrinfo;
  pid_t * const where = gwhere[myid];
  real_t const * const tpwgts = ctrl->tpwgts;

  combuffer = update_combuffer_create(graph->mynedges[myid],ctrl->comm);

  lpwgts = wgt_alloc(nparts);
  wgt_copy(lpwgts,pwgts,nparts);

  minwgt = wgt_alloc(nparts);
  maxwgt = wgt_alloc(nparts);


  bnd = kwinfo->bnd;

  /* setup max/min partition weights */
  for (i=0;i<nparts;++i) {
    maxwgt[i]  = ctrl->tpwgts[i]*graph->tvwgt*ctrl->ubfactor;
    minwgt[i]  = ctrl->tpwgts[i]*graph->tvwgt*(1.0/ctrl->ubfactor);
  }

  DL_ASSERT(check_kwinfo(kwinfo,graph,(pid_t const **)gwhere),"Bad kwinfo");
  DL_ASSERT(check_kwbnd(kwinfo->bnd,graph,1),"Bad boundary");

  q = vw_pq_create(0,mynvtxs); 

  nmoved = 0;
  for (pass=0; pass<niter; pass++) {
    mycut = 0;
    for (c=0;c<2;++c) {
      dlthread_barrier(ctrl->comm);

      /* fill up my queue with my vertices */
      vw_pq_clear(q);
      for (i=0;i<bnd->size;++i) {
        k = vtx_iset_get(i,bnd);
        DL_ASSERT(k < mynvtxs,"Invalid border vertex %"PF_VTX_T,k);
        if (nbrinfo[k].nnbrs > 0) {
          /* only insert vertices with external neighbors */
          rgain = (1.0*nbrinfo[k].ed/sqrt(nbrinfo[k].nnbrs)) - nbrinfo[k].id;
          vw_pq_push(rgain,k,q);
        }
      }
      /* make moves */

      do {
        /* perform updates */
        while (update_combuffer_next(&up,combuffer)) {
          k = up.nbr;
          ewgt = up.ewgt;
          to = up.to;
          from = up.from;

          mycut += __update_vertex(ctrl,k,to,from,ewgt,graph,kwinfo,q);
        }

        /* move a vertice */
        if (q->size > 0) {
          i = vw_pq_pop(q);

          myrinfo = kwinfo->nbrinfo+i;
          mynbrs = kwinfo_get_nbrs_ro(kwinfo,i, \
              dl_min(nparts,graph->xadj[myid][i+1]-graph->xadj[myid][i]));

          from = where[i];
          wgt = vwgt[i];

          if (myrinfo->id > 0 && lpwgts[from]-wgt < minwgt[from]) {
            continue;
          }

          /* find the first eligible partition */
          for (k=0;k<myrinfo->nnbrs; ++k) {
            to = mynbrs[k].pid;
            if (!__right_side(c,to,from)) {
              continue;
            }
            if (lpwgts[to]+wgt <= maxwgt[to]) {
              if (mynbrs[k].ed >= myrinfo->id) {
                break;
              }
            }
          }
          if (k == myrinfo->nnbrs) {
            /* if there aren't any eligable partitions, abort */
            continue;
          }

          /* see if there is a better one from the eligable one */
          for (j=k+1; j<myrinfo->nnbrs; ++j) {
            to = mynbrs[j].pid;
            if (!__right_side(c,to,from)) {
              continue;
            }
            if (mynbrs[j].ed >= mynbrs[k].ed) {
              gain = mynbrs[j].ed-myrinfo->id; 
              DL_ASSERT(gain >= 0, "Invalid gain of %"PF_WGT_T,gain);
              if ((gain > 0 && lpwgts[to]+wgt <= maxwgt[to]) \
                  || (mynbrs[j].ed == mynbrs[k].ed && \
                     tpwgts[mynbrs[k].pid]*lpwgts[to] < \
                     tpwgts[to]*lpwgts[mynbrs[k].pid])) {
                k = j;
              }
            }
          }
          to = mynbrs[k].pid;

          if (mynbrs[k].ed >= myrinfo->id) { 
            gain = mynbrs[k].ed-myrinfo->id;
            if (!(gain > 0 || (gain == 0 \
                      && (lpwgts[from] >= maxwgt[from]  \
                          || tpwgts[to]*lpwgts[from] > \
                          tpwgts[from]*(lpwgts[to]+wgt))))) {
              continue;
            }
          }

          if (lpwgts[to] + wgt > maxwgt[to] || 
              lpwgts[from] - wgt < minwgt[from]) {
            /* whatever you do, don't push the red button */
            continue;
          }

          /* make the move ***************************************************/
          ++nmoved;

          mycut += __move_vertex(ctrl,graph,myid,i,to,kwinfo,lpwgts, \
              where,q,combuffer);
        } 
      } while ((q->size > 0 && vw_pq_top(q) >= 0) || \
          !update_combuffer_finish(combuffer));

      DL_ASSERT_EQUALS(update_combuffer_next(NULL,combuffer),0,"%d");

      update_combuffer_clear(combuffer);

      /* update my partition weights */
      __par_sync_pwgts(myid,nparts,pwgts,lpwgts,ctrl->comm);

    } /* end directions */

    mycut = wgt_dlthread_sumreduce(mycut,ctrl->comm);

    par_vprintf(ctrl->verbosity,MTMETIS_VERBOSITY_HIGH, \
        "Refinement pass %zu: %"PF_WGT_T" improvement\n",pass,mycut);

    if (mycut == 0) {
      break;
    }

    if (myid == 0) {
      graph->mincut -= (mycut/2);
    }
  } /* end passes */

  nmoved = vtx_dlthread_sumreduce(nmoved,ctrl->comm);

  vw_pq_free(q);

  dl_free(minwgt);
  dl_free(maxwgt);
  dl_free(lpwgts);

  DL_ASSERT(check_kwinfo(kwinfo,graph,(pid_t const **)gwhere),"Bad kwinfo");
  DL_ASSERT(check_kwbnd(kwinfo->bnd,graph,1),"Bad boundary");
  DL_ASSERT(graph->mincut >= 0,"Invalid mincut of %"PF_WGT_T, \
      graph->mincut);
  DL_ASSERT_EQUALS(graph_cut(graph,(pid_t const**)gwhere), \
      graph->mincut,"%"PF_WGT_T);

  /* implicit barrier */
  update_combuffer_free(combuffer);

  return nmoved;
}