patrick
/
plasp
Archived
1
0
Fork 0

Started turning translated PDDL predicates into unified variable format.

This commit is contained in:
Patrick Lühne 2016-08-13 02:48:30 +02:00
parent 0a1044743e
commit cf022f9959
1 changed files with 40 additions and 8 deletions

View File

@ -130,23 +130,55 @@ void TranslatorASP::translatePredicates() const
const auto &predicates = m_description.domain().predicates();
std::for_each(predicates.cbegin(), predicates.cend(),
const auto printPredicateName =
[&](const auto &predicate)
{
m_outputStream << std::endl;
m_outputStream << utils::Keyword("predicate") << "(" << utils::escapeASP(predicate->name());
m_outputStream
<< utils::escapeASP(predicate->name());
this->translateVariablesHead(predicate->arguments());
};
m_outputStream << ")";
const auto printValueRule =
[&](const auto &predicate, const auto &value)
{
m_outputStream
<< utils::Keyword("contains") << "("
<< utils::Keyword("variable") << "(";
printPredicateName(predicate);
m_outputStream
<< "), " << utils::Keyword("value") << "(";
printPredicateName(predicate);
m_outputStream << ", " << utils::Keyword(value) << ")";
this->translateVariablesBody(predicate->arguments());
m_outputStream << ".";
});
m_outputStream << "." << std::endl;
};
m_outputStream << std::endl;
std::for_each(predicates.cbegin(), predicates.cend(),
[&](const auto &predicate)
{
m_outputStream
<< std::endl
<< utils::Keyword("variable") << "("
<< utils::Keyword("variable") << "(";
printPredicateName(predicate);
m_outputStream << "))";
this->translateVariablesBody(predicate->arguments());
m_outputStream << "." << std::endl;
printValueRule(predicate, "true");
printValueRule(predicate, "false");
});
}
////////////////////////////////////////////////////////////////////////////////////////////////////