コード例 #1
0
void tst_horn_subsume_model_converter() {
    ast_manager m;
    reg_decl_plugins(m);
    arith_util a(m);

    ptr_vector<sort> ints;
    ints.push_back(a.mk_int());
    ints.push_back(a.mk_int());
    ints.push_back(a.mk_int());

    func_decl_ref p(m), q(m), r(m);
    p = m.mk_func_decl(symbol("p"), 2, ints.c_ptr(), m.mk_bool_sort());
    q = m.mk_func_decl(symbol("q"), 2, ints.c_ptr(), m.mk_bool_sort());
    r = m.mk_func_decl(symbol("r"), 2, ints.c_ptr(), m.mk_bool_sort());

    ref<horn_subsume_model_converter> mc = alloc(horn_subsume_model_converter,m);
    model_ref mr = alloc(model, m);

    mc->insert(p, m.mk_app(q, a.mk_numeral(rational(1), true), a.mk_numeral(rational(2), true)));

    model_converter_ref mcr = mc.get();
    apply(mcr, mr, 0);
    model_smt2_pp(std::cout, m, *mr.get(), 0);

    mr = alloc(model, m);
    mc->insert(p, m.mk_app(q, a.mk_numeral(rational(3), true), a.mk_numeral(rational(5), true)));
    apply(mcr, mr, 0);
    model_smt2_pp(std::cout, m, *mr.get(), 0);

    mr = alloc(model, m);
    mc->insert(p, m.mk_app(r, m.mk_var(0,a.mk_int()), m.mk_var(1, a.mk_int())));
    apply(mcr, mr, 0);
    model_smt2_pp(std::cout, m, *mr.get(), 0);

    mr = alloc(model, m);
    app_ref head1(m);
    expr_ref body1(m), body2(m);
    func_decl_ref pred(m);
    head1 = m.mk_app(p, m.mk_var(0, a.mk_int()), m.mk_var(0, a.mk_int()));
    body1 = m.mk_app(q, m.mk_var(1, a.mk_int()), m.mk_var(2, a.mk_int()));
    VERIFY(mc->mk_horn(head1, body1, pred, body2));
    mc->insert(pred, body2); 
    apply(mcr, mr, 0);
    model_smt2_pp(std::cout, m, *mr.get(), 0);

    mr = alloc(model, m);
    head1 = m.mk_app(p, m.mk_var(0, a.mk_int()), m.mk_var(0, a.mk_int()));
    body1 = m.mk_app(q, m.mk_var(1, a.mk_int()), m.mk_var(0, a.mk_int()));
    VERIFY(mc->mk_horn(head1, body1, pred, body2));
    mc->insert(pred, body2); 
    apply(mcr, mr, 0);
    model_smt2_pp(std::cout, m, *mr.get(), 0);


}
コード例 #2
0
ファイル: material2.cpp プロジェクト: untgames/funner
int main ()
{
  printf ("Results of material_test:\n");
  
  try
  {
    IDriver* bullet_driver = DriverManager::FindDriver (DRIVER_NAME);

    if (!bullet_driver)
      throw xtl::format_operation_exception ("", "Can't find driver '%s'", DRIVER_NAME);

    ScenePtr scene (bullet_driver->CreateScene (), false);

    ShapePtr sphere_shape (bullet_driver->CreateSphereShape (1.f), false);

    RigidBodyPtr body1 (scene->CreateRigidBody (sphere_shape.get (), 1), false),
                 body2 (scene->CreateRigidBody (sphere_shape.get (), 1), false);

    printf ("body 1 material friction = %.2f, body 2 material friction = %.2f\n", body1->Material ()->Friction (), body2->Material ()->Friction ());

    body2->Material ()->SetFriction (0.3f);

    printf ("body 1 material friction = %.2f, body 2 material friction = %.2f\n", body1->Material ()->Friction (), body2->Material ()->Friction ());

    MaterialPtr material (bullet_driver->CreateMaterial (), false);

    body1->SetMaterial (material.get ());
    body2->SetMaterial (material.get ());

    printf ("body 1 material friction = %.2f, body 2 material friction = %.2f\n", body1->Material ()->Friction (), body2->Material ()->Friction ());

    material->SetFriction (0.25f);

    printf ("body 1 material friction = %.2f, body 2 material friction = %.2f\n", body1->Material ()->Friction (), body2->Material ()->Friction ());
  }
  catch (std::exception& exception)
  {
    printf ("exception: %s\n", exception.what ());
  }

  return 0;
}
コード例 #3
0
ファイル: LibOpenGL.cpp プロジェクト: tacite/cpp_nibbler
void	LibOpenGL::draw_background()
{
  Pave 	ground(0, 0, 0, 64, 64, 64, _tex["stone"]);
  Pave 	wall(0, 0, 0, 64, 64, 64, _tex["wood"]);
  Pave 	body2(0, 0, 0, 8, 32, 16, _tex["body2"]);

  glTranslated(-_x*320, -_y*320, 0);
  _tex["grass"]["top"].load();
  glBegin(GL_QUADS);
  glTexCoord2d(0, 0);
  glVertex3d(0, 0, 0);
  glTexCoord2d(_x*5, 0);
  glVertex3d(_x*640, 0, 0);
  glTexCoord2d(_x*5, _y*5);
  glVertex3d(_x*640, _y*640,0);
  glTexCoord2d(0, _y*5);
  glVertex3d(0, _y*640,0);
  glEnd();
  glTranslated(_x*320, _y*320, 0);
  for(int i = 0; i < _y+2; ++i)
  {
    for(int j = 0; j < _x+2; ++j)
    {
     ground.setpos(j*64, i*64, 0);
     ground.draw();
      if (j == 0 || i == 0)
      {
        wall.setpos(j*64, i*64, 64);
        wall.draw();
      }
      else if (j == (_x + 1) || i == (_y + 1))
      {
        wall.setpos(j*64, i*64, 64);
        wall.draw();
      }
    }
  }
}
コード例 #4
0
ファイル: LibOpenGL.cpp プロジェクト: tacite/cpp_nibbler
void	LibOpenGL::init(int x, int y)
{
  this->_x = x;
  this->_y = y;
  SDL_Init(SDL_INIT_VIDEO);
  SDL_WM_SetCaption("Nibbler", NULL);
  SDL_SetVideoMode(720, 520, 32, SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_OPENGL);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluPerspective(60, 1.3, 1, 10000);
  glEnable(GL_DEPTH_TEST);
  glEnable(GL_TEXTURE_2D);
  glEnable(GL_LIGHTING);
  glEnable(GL_LIGHT0);

  Texture		stone("Textures/stonebrick.bmp", 64, 64);
  Texture		planks("Textures/planks_oak.bmp", 64, 64);
  Texture		cake_top("Textures/cake_top.bmp", 64, 64);
  Texture		cake_bottom("Textures/cake_bottom.bmp", 64, 64);
  Texture		cake_side("Textures/cake_side.bmp", 64, 32);
  Texture		body1("Textures/body1.bmp", 64, 64);
  Texture		body2("Textures/stonebrick.bmp", 32, 64);
  Texture		grass("Textures/grass.bmp", 64, 64);

  _tex["stone"]["top"].set(stone);
  _tex["stone"]["bottom"].set(stone);
  _tex["stone"]["front"].set(stone);
  _tex["stone"]["back"].set(stone);
  _tex["stone"]["left"].set(stone);
  _tex["stone"]["right"].set(stone);

  _tex["wood"]["top"].set(planks);
  _tex["wood"]["bottom"].set(planks);
  _tex["wood"]["front"].set(planks);
  _tex["wood"]["back"].set(planks);
  _tex["wood"]["left"].set(planks);
  _tex["wood"]["right"].set(planks);

  _tex["cake"]["top"].set(cake_top);
  _tex["cake"]["bottom"].set(cake_bottom);
  _tex["cake"]["front"].set(cake_side);
  _tex["cake"]["back"].set(cake_side);
  _tex["cake"]["left"].set(cake_side);
  _tex["cake"]["right"].set(cake_side);

  _tex["body1"]["top"].set(body1);
  _tex["body1"]["bottom"].set(body1);
  _tex["body1"]["front"].set(body1);
  _tex["body1"]["back"].set(body1);
  _tex["body1"]["left"].set(body1);
  _tex["body1"]["right"].set(body1);

  _tex["body2"]["top"].set(body2);
  _tex["body2"]["bottom"].set(body2);
  _tex["body2"]["front"].set(body2);
  _tex["body2"]["back"].set(body2);
  _tex["body2"]["left"].set(body2);
  _tex["body2"]["right"].set(body2);

  _tex["grass"]["top"].set(grass);

  _bg = glGenLists(1);

  glNewList(_bg, GL_COMPILE);
  this->draw_background();
  glEndList();
}