当前位置: 首页>>代码示例>>C++>>正文


C++ Pos类代码示例

本文整理汇总了C++中Pos的典型用法代码示例。如果您正苦于以下问题:C++ Pos类的具体用法?C++ Pos怎么用?C++ Pos使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Pos类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Pos

bool GiantLocust::onActorTurn_() {
  if(deadState == ActorDeadState::alive) {
    if(awareOfPlayerCounter_ > 0) {
      if(Rnd::percentile() < chanceToSpawnNew) {

        bool blockers[MAP_W][MAP_H];
        MapParse::parse(CellPred::BlocksActor(*this, true, eng), blockers);

        Pos spawnPos;
        for(int dx = -1; dx <= 1; dx++) {
          for(int dy = -1; dy <= 1; dy++) {
            spawnPos.set(pos + Pos(dx, dy));
            if(blockers[spawnPos.x][spawnPos.y] == false) {
              Actor* const actor =
                eng.actorFactory->spawnActor(data_->id, spawnPos);
              GiantLocust* const locust = dynamic_cast<GiantLocust*>(actor);
              chanceToSpawnNew -= 2;
              locust->chanceToSpawnNew = chanceToSpawnNew;
              locust->awareOfPlayerCounter_ = awareOfPlayerCounter_;
              eng.gameTime->actorDidAct();
              return true;
            }
          }
        }
      }
    }
  }
  return false;
}
开发者ID:jachamp,项目名称:ia,代码行数:29,代码来源:ActorMonsterSpecific.cpp

示例2: solve

int solve(){
  memset(tick, 0x1f, sizeof(tick));  
  Pos start = findCh('S');
  Pos target = findCh('T');
  //start.display("S");
  //start.display("T");
  queue<Pos> Q;
  Q.push(start);
  tick[start.x][start.y][start.color][start.dir] = 0;
  while (Q.size()){
    Pos s = Q.front(); Q.pop();
    //s.display("Pop");
    for (int i = 0; i < 3; i++){
      Pos t = s.action(i);
      if (!t.isValid()) continue;
      if (tick[t.x][t.y][t.color][t.dir] != INF) continue;
      if (grid[t.x][t.y] == '#') continue;
      tick[t.x][t.y][t.color][t.dir] = tick[s.x][s.y][s.color][s.dir] + 1;
      Q.push(t);
      //s.display("   Push");
    }
  }
  int best = INF;
  for (int i = 0; i < 4; i++){
    target.dir = i;
    best = min(best, tick[target.x][target.y][target.color][target.dir]);
  }
  return best;
}
开发者ID:LiaoZhuo,项目名称:Practice,代码行数:29,代码来源:uva_10047.cpp

示例3: main

int main()
{
	while(cin >> n && n!=0)
	{
		for(int i=0;i!=88888889;i++)
		check[i] = false;
		float ok = 0.12345678;
		finish = (pow(10.0,n))*ok;
		Pos pos;
		vector<int> init;
		for(int i=0;i!=n;i++)
			init.push_back(0);
		for(int i=0;i!=n;i++)
			pos.push_back(init);
		for(int i=0;i!=n;i++)
		{
			int in;
			cin >> in;
			(pos[i])[0] = in;
		}
		int ans = search(pos,n);
		if(ans==-1)
		cout << "IMPOSSIBLE" <<endl;
		else
		cout << ans <<endl;
	}
	system("pause");
	return 0;
}
开发者ID:zzh8829,项目名称:CompetitiveProgramming,代码行数:29,代码来源:ccc12j5s4.cpp

示例4:

bool Pos::operator==(const Pos& s) const
{
    if (_type == FRAMES)
        return _frame == s.frame();
    else
        return _tick == s.tick();
}
开发者ID:faesong,项目名称:oom,代码行数:7,代码来源:pos.cpp

示例5:

vector<Pos> Board::MoveGung(Pos pos)
{
    vector<Pos> candidates;
    int curr_id = stage[pos.y][pos.x];
    int nx, ny;
    for (int dy = -1; dy <= 1; dy++) {
        for (int dx = -1; dx <= 1; dx++) {
            nx = pos.x + dx;
            ny = pos.y + dy;
            if ((pos.x == 3 && (pos.y == 1 || pos.y == 8)) ||
                (pos.x == 4 && (pos.y == 0 || pos.y == 2 || pos.y == 7 || pos.y == 9)) ||
                (pos.x == 5 && (pos.y == 1 || pos.y == 8))) {
                // movable to only up, right, left, down side
                if (pos.DistWith(nx, ny) > 1)
                    continue;
            }
            if (nx >= 3 && nx <= 5
                && ((ny >= 0 && ny <= 2) || (ny >= 7 && ny <= 9))) {
                if (curr_id <= 6) {
                    if (stage[ny][nx]<0 || stage[ny][nx]>6) {
                        candidates.push_back(Pos(nx, ny));
                    }
                }
                else {
                    if (stage[ny][nx]<0 || stage[ny][nx] <= 6) {
                        candidates.push_back(Pos(nx, ny));
                    }
                }
            }
        }
    }
    
    return candidates;
}
开发者ID:chankyu-choi,项目名称:janggi,代码行数:34,代码来源:board.cpp

示例6: generate_path

 Int generate_path( const PosMatrix& prev, const Pos& start, Path& path ) {
   Pos cur = start;
   while ( cur != POS_NONE ) {
     path.push_back(cur);
     cur = prev[cur.get_row()][cur.get_col()];
   }
   std::reverse(std::begin(path), std::end(path));
   return path.size();
 }
开发者ID:sh19910711,项目名称:codeforces-solutions,代码行数:9,代码来源:main.cpp

示例7: rotateUntilBorder

void ModButterfly::rotateUntilBorder(RgbVertexC& v, Pos& pos)
{
	assert(v.vp() == pos.v);
	do 
	{
		pos.FlipE();
		pos.FlipF();
	} while (!pos.IsBorder());
	assert(v.vp() == pos.v);
}
开发者ID:Booley,项目名称:nbis,代码行数:10,代码来源:modButterfly.cpp

示例8: addMatches

bool Matches::addMatches( char *s, int32_t slen, mf_t flags ) {
	// . do not breach
	// . happens a lot with a lot of link info text
	if ( m_numMatchGroups >= MAX_MATCHGROUPS ) {
		return true;
	}

	// get some new ptrs for this match group
	Words    *wp = &m_wordsArray    [ m_numMatchGroups ];
	Bits     *bp = &m_bitsArray     [ m_numMatchGroups ];
	Pos      *pb = &m_posArray      [ m_numMatchGroups ];

	// set the words class for this match group
	if ( !wp->set( s, slen, true ) ) {
		return false;
	}

	// bits vector
	if ( ! bp->setForSummary ( wp ) ) {
		return false;
	}

	// position vector
	if ( ! pb->set ( wp ) ) {
		return false;
	}

	// record the start
	int32_t startNumMatches = m_numMatches;
	// sometimes it returns true w/o incrementing this
	int32_t n = m_numMatchGroups;
	// . add all the Match classes from this match group
	// . this increments m_numMatchGroups on success
	bool status = addMatches( wp, NULL, NULL, bp, pb, flags );

	// if this matchgroup had some, matches, then keep it
	if ( m_numMatches > startNumMatches ) {
		return status;
	}

	// otherwise, reset it, useless
	wp->reset();
	bp->reset();
	pb->reset();

	// do not decrement the counter if we never incremented it
	if ( n == m_numMatchGroups ) {
		return status;
	}

	// ok, remove it
	m_numMatchGroups--;

	return status;
}
开发者ID:privacore,项目名称:open-source-search-engine,代码行数:55,代码来源:Matches.cpp

示例9: setPos

void PosLen::setPos(const Pos& pos)
      {
      switch(pos.type()) {
            case FRAMES:
                  setFrame(pos.frame());
                  break;
            case TICKS:
                  setTick(pos.tick());
                  break;
            }
      }
开发者ID:hanabokuro,项目名称:MuseScore,代码行数:11,代码来源:pos.cpp

示例10: p

void MarkerView::tickChanged(const Pos& pos)
{
	MarkerItem* item = (MarkerItem*) table->currentItem();
	if (item)
	{
		item->setTick(pos.tick());
		Pos p(pos.tick(), true);
		song->setPos(0, p, true, true, false);
		table->sortByColumn(COL_TICK, Qt::AscendingOrder);
	}
}
开发者ID:faesong,项目名称:oom,代码行数:11,代码来源:markerview.cpp

示例11: throw_

 void throw_(typename Exception::error_code code, S1 msg, Pos const& pos)
 {
     std::stringstream stream;
     stream << Exception::severity_text(code) << ": "
            << Exception::error_text(code);
     if (msg[0] != 0) 
         stream << ": " << msg;
     stream << std::ends;
     std::string throwmsg = stream.str(); 
     boost::throw_exception(Exception(throwmsg.c_str(), code,
         pos.get_line(), pos.get_column(), pos.get_file().c_str()));
 }
开发者ID:avasopht,项目名称:boost_1_55_0-llvm,代码行数:12,代码来源:cpp_throw.hpp

示例12: setValue

void PosEdit::setValue(const Pos& time)
      {
      if (time > maxValue() || time < minValue())
            return;
      if (_smpte)
            time.msf(&(sec[0].val), &(sec[1].val), &(sec[2].val),
               &(sec[3].val));
      else
            time.mbt(&(sec[0].val), &(sec[1].val), &(sec[2].val));
      changed = false;
      
      updateButtons();
      ed->repaint(ed->rect(), false);
      }
开发者ID:muse-sequencer,项目名称:muse,代码行数:14,代码来源:posedit_OLD.cpp

示例13: findGoal

int simplehero::selectNeighbor(GraphMap* map, int cur_x, int cur_y)
{
	// printf("Selecting neighbor\n");
	int x, y, a, b;	
	Pos* goal = findGoal(map, cur_x, cur_y);
	int g;

	if(goal == 0)
	{
		printf("Couldn't find goal\n");
		return 0;
	}

	g = map->getVertex(goal->getX(), goal->getY());

	int toGo = BFSearch(map, cur_x, cur_y, g);
	
	//printf("Done searching\n");

	if(toGo == -1)
	{
	//	printf("No target found\n");
		delete goal;
		return 0;
	}
	
/*	if(p == 0 || p[1]->getX() < 0)
	{
		printf("ERRRORRORROR\n");
		goal = findGoal(map, cur_x, cur_y);
		toGo = BFSearch(map ,cur_x, cur_y, goal);
	}*/

	map->getPosition(toGo, x, y);
	
	
	for(int i = 0; i < map->getNumNeighbors(cur_x, cur_y); i++)
	{
		map->getNeighbor(cur_x, cur_y, i, a, b);
		if(x == a && y == b)
		{
			delete goal;

			return i;
		}
	}
	printf("Shouldn't get here");
	return 0;
}
开发者ID:nevets2707,项目名称:229--proj2,代码行数:49,代码来源:simplehero.cpp

示例14: printCornerPointsXY

  void printCornerPointsXY(Box* box, FILE* f){
    OSGBox* obox = (OSGBox*)box->getOSGPrimitive();
    std::list<Pos> ps;
    Pos dim = obox->getDim();
    ps.push_back(Pos(dim.x()*  0.5, dim.y()*  0.5,0));
    ps.push_back(Pos(dim.x()*  0.5, dim.y()* -0.5,0));
    ps.push_back(Pos(dim.x()* -0.5, dim.y()* -0.5,0));
    ps.push_back(Pos(dim.x()* -0.5, dim.y()*  0.5,0));
//     for(int i=0; i<8; i++){
//       ps.push_back(Pos(dim.x()*( (i&4) ? 0.5: -0.5),dim.y()*( (i&2) ? 0.5: -0.5),dim.z()*( (i&1) ? 0.5: -0.5)));
//     }
    // transform them into global coords
    FOREACH(std::list<Pos>, ps, p){
      *p = (*p) * box->getPose();
    }
开发者ID:Sosi,项目名称:lpzrobots,代码行数:15,代码来源:abstractground.cpp

示例15: GetCluster

void Filler::GetCluster(Pos pos, std::unordered_set<int>& cluster_out)
{
	if (IsOutside(pos) ||
		visited_.find(pos.GetHash()) != visited_.end() ||
		piece_index_.find(pos.GetHash()) == piece_index_.end())
	{
		return;
	}

	visited_.insert(pos.GetHash());
	cluster_out.insert(piece_index_[pos.GetHash()]);
	for (const auto& direction : directions_)
	{
		GetCluster({ pos.x + direction.first, pos.y + direction.second }, cluster_out);
	}
}
开发者ID:GauthamBanasandra,项目名称:Hackerrank_Solutions,代码行数:16,代码来源:2D+nim.cpp


注:本文中的Pos类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。