예제 #1
0
literalt cnft::land(const bvt &bv)
{
  if(bv.size()==0) return const_literal(true);
  if(bv.size()==1) return bv[0];
  if(bv.size()==2) return land(bv[0], bv[1]);

  forall_literals(it, bv)
    if(it->is_false())
      return *it;

  if(is_all(bv, const_literal(true)))
    return const_literal(true);

  bvt new_bv;

  eliminate_duplicates(bv, new_bv);

  bvt lits(2);
  literalt literal=new_variable();
  lits[1]=neg(literal);

  forall_literals(it, new_bv)
  {
    lits[0]=pos(*it);
    lcnf(lits);
  }
예제 #2
0
// -----------------------------------------------------------------------
// handle the resurrection spell
// -----------------------------------------------------------------------
bool t_resurrection_spell::left_click( t_screen_point const& point )
{
	t_map_point_2d         map_point;
	t_combat_creature_list creatures;
	bool                   defender = get_caster()->belongs_to_defender();
	
	creatures = get_targets( point );
	if (creatures.empty())
		return false;

	eliminate_duplicates( creatures );
	if (creatures.size() == 1)
	{
		resurrect( creatures.front().get() );
		return true;
	}
	
	t_combat_creature_list::iterator index;
	t_combat_creature_ptr            creature;
	t_handler                        handler;
	t_window*                        window = t_window::get_modal_window();

	m_menu = new t_scroll_menu( window );
	for (index = creatures.begin(); index != creatures.end(); index++)
	{
		creature = *index;
		handler = add_argument( bound_handler( *this, &t_resurrection_spell::resurrect ),
			                    creature );
		m_menu->add_item( get_text( creature ), handler );
	}
	m_menu->open( get_mouse_position( window ) );
	m_battlefield.get_window()->set_help_balloon_text( "" );
	return true;
}
예제 #3
0
int main()
{
    std::vector<std::string> vs{ "a", "v", "a", "s", "v", "a", "a" };
    println(vs);
    println(eliminate_duplicates(vs));

    return 0;
}
예제 #4
0
파일: z3_prop.cpp 프로젝트: smaorus/rvt
literalt z3_propt::lor(const bvt &bv)
{
  if(bv.size()==0) return const_literal(false);
  if(bv.size()==1) return bv[0];
  if(bv.size()==2) return lor(bv[0], bv[1]);

  for(unsigned i=0; i<bv.size(); i++)
    if(bv[i]==const_literal(true))
      return const_literal(true);

  if(is_all(bv, const_literal(false)))
    return const_literal(false);

  bvt new_bv;

  eliminate_duplicates(bv, new_bv);

  literalt literal=new_variable();

  for(unsigned int i=0; i<new_bv.size(); ++i)
  {
    bvt lits;
    lits.reserve(2);
    lits.push_back(neg(new_bv[i]));
    lits.push_back(pos(literal));
    lcnf(lits);
  }

  bvt lits;
  lits.reserve(new_bv.size()+1);

  for(unsigned int i=0; i<new_bv.size(); ++i)
    lits.push_back(pos(new_bv[i]));

  lits.push_back(neg(literal));
  lcnf(lits);

  return literal;
}