From cf022f9959916b3852106247cac806e7a6877d88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Sat, 13 Aug 2016 02:48:30 +0200 Subject: [PATCH] Started turning translated PDDL predicates into unified variable format. --- src/plasp/pddl/TranslatorASP.cpp | 48 ++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/src/plasp/pddl/TranslatorASP.cpp b/src/plasp/pddl/TranslatorASP.cpp index 25bd8b0..517abc4 100644 --- a/src/plasp/pddl/TranslatorASP.cpp +++ b/src/plasp/pddl/TranslatorASP.cpp @@ -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"); + }); } ////////////////////////////////////////////////////////////////////////////////////////////////////