本文整理汇总了C++中Levels类的典型用法代码示例。如果您正苦于以下问题:C++ Levels类的具体用法?C++ Levels怎么用?C++ Levels使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Levels类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST
TEST(Levels, load_nph)
{
Levels l;
l.addPath("data/L00_title.nph");
ASSERT_EQ(1, l.numLevels());
ASSERT_STREQ("title", l.levelName(0).c_str());
}
示例2: loadLevel
void Map::loadLevel(int level){
Levels levels;
tile.clear();
std::cout << "Loading level " << level << "..." << std::endl;
levels.getLevel(&tile, level);
this->sizeY = tile.size();
this->sizeX = tile[0].size();
}
示例3: main
int main()
{
window.create(sf::VideoMode(800, 600), "Breakfree");
window.setVerticalSyncEnabled(true);
//, sf::Style::Close|sf::Style::Titlebar);
if (!font.loadFromFile("Nirmala.ttf"))
return EXIT_FAILURE;
Levels lv;
Paddle pad;
InputManager input;
while (window.isOpen())
{
switch (level)
{
case 0:
lv.loadLv0();
break;
}
while (playing)
{
input.ExecuteEvents(window);
pad.Update();
window.clear(); // ------draw graphics here-------
sf::Text text("Score: " + std::to_string(score), font, 20);
text.setPosition(660, 220);
window.draw(text);
lv.Draw(window);
window.draw(pad.sprite);
window.draw(pad.ball);
window.display(); // -----------------------
}
}
return 0;
}
示例4: printMe
void printMe() {
cout << "========================== UKS ==============================" << endl;
cout << " --- Maxes --- " << endl << " ";
for (int k = 0; k < maxes.size(); ++k)
{
cout << " " << maxes[k];
}
cout << " --- Mins --- " << endl << " ";
for (int k = 0; k < mins.size(); ++k)
{
cout << " " << mins[k];
}
cout << " --- Range size --- " << endl << " ";
for (int k = 0; k < range_size.size(); ++k)
{
cout << " " << range_size[k];
}
cout << endl;
cout << " ==== STATES ==== " << endl;
for (int i = 0; i < states.size(); ++i)
{
TSStateProperty s = states[i];
cout << " State: " << s.ID << endl;
cout << " - Levels: ";
for (int k = 0; k < s.levels.size(); ++k)
{
cout << " " << s.levels[k];
}
cout << endl;
cout << " - Transitions: " << endl;
for (int j = 0; j < s.transitions.size(); ++j)
{
TSTransitionProperty tr = s.transitions[j];
cout << " " << j << " Target: " << tr.target_ID << " step_size: " << tr.trans_const.step_size << " req_dir: " << tr.trans_const.req_dir << " comp_value: " << tr.trans_const.comp_value << endl;
cout << " Targets: ";
for (int k = 0; k < tr.trans_const.targets.size(); ++k)
{
cout << " " << tr.trans_const.targets[k];
}
cout << endl;
}
}
}
示例5: getID
inline StateID getID(const Levels & levels) const {
StateID result = 0;
size_t factor = 1;
for (size_t lvl_no = 0; lvl_no < levels.size(); lvl_no++) {
result += (levels[lvl_no] - mins[lvl_no]) * factor;
factor *= (range_size[lvl_no]);
}
return result;
}
示例6: computeID
StateID UnparametrizedStructure::computeID(const Levels & levels) const
{
StateID result = 0;
size_t factor = 1;
for (size_t lvl_no = 0; lvl_no < levels.size(); lvl_no++)
{
result += (levels[lvl_no] - get<0>(_bounds)[lvl_no]) * factor;
factor *= (get<2>(_bounds)[lvl_no]);
}
return result;
}
示例7: nlevels
/** Returns the number of levels in the partition forest. Levels are numbered starting at zero. The return value is one
* more than the maximum level that contains a vertex. */
size_t nlevels() const { return levels.size(); }
示例8: main
int main(int argc, char* argv[])
{
sf::RenderWindow WINDOW(sf::VideoMode(1280, 720, 32), "Arctic", sf::Style::Close);
WINDOW.SetFramerateLimit(60);
Levels* levels;
levels->setLevels();
sf::Clock clock;
float time = clock.GetElapsedTime();
state = Ingame;
prevState = Menu;
/* Main Menu Buttons */
BUTTON play(440, 200, "PLAY");
BUTTON options(440, 320, "OPTIONS");
BUTTON quit(440, 440, "QUIT");
/* Pause Buttons */
BUTTON resume(440, 200, "RESUME");
BUTTON pauseOptions(440, 320, "OPTIONS");
BUTTON quitToMenu(440, 440, "QUIT TO MENU");
/* Strings */
STRING str("Arctic - Sprite Testing", 5, 2, sf::Color(255, 255, 255));
while(WINDOW.IsOpened())
{
sf::Event event;
sf::Vector2i mouse(WINDOW.GetInput().GetMouseX(), WINDOW.GetInput().GetMouseY());
time = clock.GetElapsedTime();
while(WINDOW.GetEvent(event))
{
switch(event.Type)
{
case sf::Event::Closed:
WINDOW.Close();
break;
case sf::Event::KeyPressed:
if(event.Key.Code == sf::Key::Escape)
{
if(state == Menu)
{
WINDOW.Close();
}
else if(state == Ingame)
{
state = Paused;
prevState = Ingame;
}
else if(state == Options)
{
state = prevState;
prevState = Options;
}
else if(state == Paused)
{
state = prevState;
prevState = Paused;
}
}
if(event.Key.Code == sf::Key::Space)
{
for(int i = 0; i < ice.size(); i++)
{
if(ice[i]->state != Ice::IceState::Rock)
{
ice[i]->state = Ice::IceState::Reg;
}
}
}
break;
case sf::Event::MouseButtonReleased:
if(event.MouseButton.Button == sf::Mouse::Button::Left)
{
if(state == Menu)
{
if(play.contains(mouse))
{
state = Ingame;
}
else if(options.contains(mouse))
{
state = Options;
prevState = Menu;
}
else if(quit.contains(mouse))
{
WINDOW.Close();
}
}
else if(state == Paused)
{
if(resume.contains(mouse))
{
state = Ingame;
}
else if(pauseOptions.contains(mouse))
{
state = Options;
//.........这里部分代码省略.........
示例9: addTransitions
/**
* Creates transitions from labelled edges of BA and passes them to the automaton structure.
*/
void addTransitions(AutomatonStructure & automaton, const StateID ID) const {
const PropertyAutomaton::Edges & edges = property.getEdges(ID);
// Transform each edge into transition and pass it to the automaton
for (const PropertyAutomaton::Edge & edge : edges) {
// Compute allowed values from string of constrains
ConstraintParser * parser = new ConstraintParser(maxes.size(), *max_element(maxes.begin(), maxes.end()));
parser->applyFormula(names, edge.cons.values);
parser->addBoundaries(maxes, true);
parser->addBoundaries(mins, false);
automaton.addTransition(ID, { edge.target_ID, parser, edge.cons.transient, edge.cons.stable });
}
}
示例10: renumber_vertices
/** Number the vertices of the forest. */
void renumber_vertices() {
size_t id=0;
for (size_t i=0; i<levels.size(); ++i) {
for (Vertices::const_iterator vi=levels[i].vertices.begin(); vi!=levels[i].vertices.end(); ++vi)
(*vi)->id = id++;
}
}
示例11: print
/** Print the entire forest for debugging output. */
void print(std::ostream &o) const {
for (size_t i=0; i<levels.size(); ++i) {
if (levels[i].vertices.empty()) {
o <<"partition forest level " <<i <<" is empty.\n";
} else {
size_t nsets = levels[i].vertices.size();
size_t nfuncs = 0;
for (Vertices::const_iterator vi=levels[i].vertices.begin(); vi!=levels[i].vertices.end(); ++vi)
nfuncs += (*vi)->functions.size();
o <<"partition forest level " <<i
<<" contains " <<nfuncs <<" function" <<(1==nfuncs?"":"s")
<<" in " <<nsets <<" set" <<(1==nsets?"":"s") <<"\n";
o <<" the following input was used to generate " <<(1==nsets?"this set":"these sets") <<":\n";
o <<StringUtility::prefixLines(levels[i].inputs.toString(), " ");
int setno = 1;
for (Vertices::const_iterator vi=levels[i].vertices.begin(); vi!=levels[i].vertices.end(); ++vi, ++setno) {
Vertex *vertex = *vi;
const Functions &functions = vertex->functions;
o <<" set #" <<setno
<<" contains " <<vertex->functions.size() <<" function" <<(1==vertex->functions.size()?"":"s") <<":\n";
for (Functions::const_iterator fi=functions.begin(); fi!=functions.end(); ++fi) {
SgAsmFunction *func = *fi;
o <<" " <<StringUtility::addrToString(func->get_entry_va()) <<" <" <<func->get_name() <<">\n";
}
o <<" whose output was: {";
for (OutputValues::const_iterator oi=vertex->outputs.begin(); oi!=vertex->outputs.end(); ++oi)
o <<" " <<*oi;
o <<" }\n";
}
}
}
}
示例12: dump_outputsets
/** Dump the output sets to the DBMS. (FIXME: dumping SQL to a file instead; see dump())*/
void dump_outputsets(std::ostream &dbc) const {
for (size_t i=0; i<levels.size(); ++i) {
for (Vertices::const_iterator vi=levels[i].vertices.begin(); vi!=levels[i].vertices.end(); ++vi) {
dbc <<"insert into outputsets (id) values (" <<(*vi)->id <<");\n";
for (OutputValues::const_iterator ni=(*vi)->outputs.begin(); ni!=(*vi)->outputs.end(); ++ni)
dbc <<"insert into outputvalues (outputset_id, val) values (" <<(*vi)->id <<", " <<*ni <<");\n";
}
}
}
示例13: get_leaves
/** Returns the set of all leaf nodes in the forest. */
Vertices get_leaves() const {
Vertices retval;
for (size_t i=0; i<levels.size(); ++i) {
const Vertices &vertices = vertices_at_level(i);
for (Vertices::const_iterator vi=vertices.begin(); vi!=vertices.end(); ++vi) {
if ((*vi)->children.empty())
retval.insert(*vi);
}
}
return retval;
}
示例14: computeBoundaries
/**
* Compute a vector of maximal levels and store information about states.
*/
void computeBoundaries() {
// Compute naive bounds.
for (const SpecieID ID : cscope(model.species)) {
// Maximal values of species
names.push_back(model.species[ID].name);
maxes.push_back(model.species[ID].max_value);
mins.push_back(0);
}
// Add experiment constraints.
ConstraintParser * cons_pars = new ConstraintParser(model.species.size(), ModelTranslators::getMaxLevel(model));
cons_pars->addBoundaries(maxes, true);
cons_pars->applyFormula(ModelTranslators::getAllNames(model), property.getExperiment());
cons_pars->status();
// Compute refined boundaries.
mins = cons_pars->getBounds(false);
maxes = cons_pars->getBounds(true);
rng::transform(maxes, mins, back_inserter(range_size), [](const ActLevel max, const ActLevel min) {
return max - min + 1;
});
}
示例15: dump_inputsets
/** Dump inputsets to the DBMS. (FIXME: dumping SQL to a file instead; see dump()) */
void dump_inputsets(std::ostream &dbc) const {
for (size_t i=0; i<levels.size(); ++i) {
dbc <<"insert into inputsets (id) values(" <<i <<");\n";
const std::vector<uint64_t> &pointers = levels[i].inputs.get_pointers();
for (size_t j=0; j<pointers.size(); ++j)
dbc <<"insert into inputvalues (inputset_id, vtype, pos, val)"
<<" values (" <<i <<", 'P', " <<j <<", " <<pointers[j] <<");\n";
const std::vector<uint64_t> &integers = levels[i].inputs.get_integers();
for (size_t j=0; j<integers.size(); ++j)
dbc <<"insert into inputvalues (inputset_id, vtype, pos, val)"
<<" values (" <<i <<", 'N', " <<j <<", " <<integers[j] <<");\n";
}
}