void ManagerBase::notifyFixMaster(const ClaimMaster& cm) { Message m(MsgType::FixMaster); auto msg = m.get<FixMasterMsg>(); msg->set_seat(cm.seat); msg->set_card(cm.card.value()); msg->set_pair(cm.pair); msg->set_king(cm.king.value()); notify(&m); }
void SlideShip::create_bullet() { double bw = BULLET_W, bh = BULLET_H; double bx = dims[0] + 0.5 * (dims[2] - bw); double by = dims[1] + 0.5 * (dims[3] - bh); for (int i = 0; i < 5; i++) { Bullet *bullet = new Bullet(level, bx, by, bw, bh, 1, 5); set_pair(bullet->v, 2 * (i - 2), 6 - 2 * fabs(i - 2)); } }
void DynamicPersistenceTrails<D,CT,OT,E,Cmp,CCmp>:: pairing_switch(iterator i, iterator j) { OrderIndex i_pair = i->pair; OrderIndex j_pair = j->pair; // rLog(rlTranspositions, " (%x %x %x) (%x %x %x)", &*i, i->pair, i->pair->pair, &*j, j->pair, j->pair->pair); if (i_pair == index(i)) set_pair(j, j); else { set_pair(j, i_pair); set_pair(i_pair, j); } if (j_pair == index(j)) set_pair(i, i); else { set_pair(i, j_pair); set_pair(j_pair, i); } // rLog(rlTranspositions, " (%x %x %x) (%x %x %x)", &*i, i->pair, i->pair->pair, &*j, j->pair, j->pair->pair); }
void SlideShip::update() { Ship::update(); if (timer == 0) { timer = randint(5, 25); int n = randint(0, 3); if (n == 0) { set_pair(v, 0, -1 * s); } else if (n == 1) { set_pair(v, 0, s); } else if (n == 2) { set_pair(v, -1 * s, 0); } else if (n == 3) { set_pair(v, s, 0); } } else timer--; int k = 20; if (health < 40) k = 10; if (randint(0, k) == 0) create_bullet(); }
SlideShip::SlideShip(Level *l) :Ship(l, "orb_yellow.png") { dims[0] = 0.5 * level->dims[2] - 0.5 * image->get_width(); dims[1] = -200; s = 8; set_pair(v, 0, s); timer = 30; health = 80; score = 12000; level->boss = this; in_level = false; }
void StaticPersistence<D, CT, OT, E, Cmp>:: initialize(const Filtration& filtration) { order_.assign(filtration.size(), OrderElement()); rLog(rlPersistence, "Initializing persistence"); OffsetMap<typename Filtration::Index, iterator> om(filtration.begin(), begin()); for (typename Filtration::Index cur = filtration.begin(); cur != filtration.end(); ++cur) { Cycle z; BOOST_FOREACH(const typename Filtration::Simplex& s, std::make_pair(cur->boundary_begin(), cur->boundary_end())) z.push_back(index(om[filtration.find(s)])); z.sort(ocmp_); iterator ocur = om[cur]; swap_cycle(ocur, z); set_pair(ocur, ocur); } }
static void apply_changes(lua_State *L, Lua_Hstore *strg){ HStore *hsout; int32 buflen; HStore *in; int i; int count; int pcount; char *base; HEntry *entries; Pairs *pairs; if (strg->issync == 1) return; in = strg->hstore; count = HS_COUNT(in); base = STRPTR(in); entries = ARRPTR(in); lua_pushlightuserdata(L, strg); lua_gettable(L, LUA_REGISTRYINDEX); for (i=0; i < count; i++) { char *key = HS_KEY(entries, base, i); int klen = HS_KEYLEN(entries, i); lua_pushlstring(L, key, klen); lua_rawget(L, -2); if (lua_isnil(L,-1)){ lua_pop(L, 1); lua_pushlstring(L, key, klen); lua_pushinteger(L, i); lua_rawset(L, -3); }else { lua_pop(L, 1); } } pcount = 0; lua_pushnil(L); /* first key */ while (lua_next(L, -2) != 0) { ++pcount; /* removes 'value'; keeps 'key' for next iteration */ lua_pop(L, 1); } MTOLUA(L); pairs = palloc(pcount * sizeof(*pairs)); MTOPG; i = 0; //------------------------------- lua_pushnil(L); while (lua_next(L, -2) != 0) { const char *key = lua_tostring(L, -2); int ltype = lua_type(L, -1); if (ltype == LUA_TNUMBER){ int idx = lua_tointeger(L, -1); set_pair(L, &pairs[i], entries, base, idx); } else { char *mov_value = (char *)lua_touserdata (L, -1); set_pair_from_lv(L, &pairs[i], key, mov_value); } lua_pop(L, 1); ++i; } //------------------------------- lua_pop(L, 1); MTOLUA(L); pcount = hstoreUniquePairs(pairs, pcount, &buflen); hsout = hstorePairs(pairs, pcount, buflen); MTOPG; if (strg->havetodel){ pg_datumFree(strg->datum, hs_type.byval, hs_type.len); } strg->hstore = hsout; strg->datum = PointerGetDatum(hsout); strg->issync = 1; strg->havetodel = 1; lua_pushlightuserdata(L, strg); lua_newtable(L); lua_settable(L, LUA_REGISTRYINDEX); }
void StaticPersistence<D, CT, OT, E, Cmp>:: pair_simplices(iterator bg, iterator end, bool store_negative, const Visitor& visitor) { #if LOGGING typename ContainerTraits::OutputMap outmap(order_); #endif // FIXME: need sane output for logging rLog(rlPersistence, "Entered: pair_simplices"); for (iterator j = bg; j != end; ++j) { visitor.init(j); rLog(rlPersistence, "Simplex %s", outmap(j).c_str()); Cycle z; swap_cycle(j, z); rLog(rlPersistence, " has boundary: %s", z.tostring(outmap).c_str()); // Sparsify the cycle by removing the negative elements if (!store_negative) { typename OrderElement::Cycle zz; BOOST_FOREACH(OrderIndex i, z) if (i->sign()) // positive zz.push_back(i); z.swap(zz); } // -------------------------- CountNum(cPersistencePairBoundaries, z.size()); #ifdef COUNTERS Count(cPersistencePair); #endif // COUNTERS while(!z.empty()) { OrderIndex i = z.top(ocmp_); // take the youngest element with respect to the OrderComparison rLog(rlPersistence, " %s: %s", outmap(i).c_str(), outmap(i->pair).c_str()); // TODO: is this even a meaningful assert? AssertMsg(!ocmp_(i, index(j)), "Simplices in the cycle must precede current simplex: (%s in cycle of %s)", outmap(i).c_str(), outmap(j).c_str()); // i is not paired, so we pair j with i if (iterator_to(i->pair) == iterator_to(i)) { rLog(rlPersistence, " Pairing %s and %s with cycle %s", outmap(i).c_str(), outmap(j).c_str(), z.tostring(outmap).c_str()); set_pair(i, j); swap_cycle(j, z); set_pair(j, i); CountNum(cPersistencePairCycleLength, j->cycle.size()); CountBy (cPersistencePairCycleLength, j->cycle.size()); break; } // update element z.add(i->pair->cycle, ocmp_); visitor.update(j, iterator_to(i)); rLog(rlPersistence, " new cycle: %s", z.tostring(outmap).c_str()); } // if z was empty, so is (already) j->cycle, so nothing to do visitor.finished(j); rLog(rlPersistence, "Finished with %s: %s", outmap(j).c_str(), outmap(j->pair).c_str()); }