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);


}
Exemple #2
0
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;
}
Exemple #3
0
void	LibOpenGL::draw_snake_and_food(const std::vector< std::vector<item_type> > &map)
{
    Pave 	cake(0, 0, 0, 64, 64, 32, _tex["cake"]);
    Pave 	body1(0, 0, 0, 64, 64, 64, _tex["body1"]);

    for(int i = 0; i < _y; ++i)
    {
      for (int j = 0; j < _x; ++j)
      {
        if (map[i][j] == BODY || map[i][j] == HEAD)
        {
          body1.setpos(((_x-j)+1)*64, (i+1)*64, 64);
          body1.draw();
        }
        else if (map[i][j] == FOOD)
        {
          cake.setpos(((_x-j)+1)*64, (i+1)*64, 64);
          cake.draw();
        }
      }
    }
}
Exemple #4
0
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();
}