本文整理汇总了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;
}
示例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;
}
示例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;
}
示例4:
bool Pos::operator==(const Pos& s) const
{
if (_type == FRAMES)
return _frame == s.frame();
else
return _tick == s.tick();
}
示例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;
}
示例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();
}
示例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);
}
示例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;
}
示例9: setPos
void PosLen::setPos(const Pos& pos)
{
switch(pos.type()) {
case FRAMES:
setFrame(pos.frame());
break;
case TICKS:
setTick(pos.tick());
break;
}
}
示例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);
}
}
示例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()));
}
示例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);
}
示例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;
}
示例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();
}
示例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);
}
}