Skip to content

Commit

Permalink
Continuously incrementing effect IDs, with a special identifier for u…
Browse files Browse the repository at this point in the history
…nconditional effects.
  • Loading branch information
pluehne committed Aug 14, 2016
1 parent e2da46e commit 08113c9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/plasp/pddl/TranslatorASP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ void TranslatorASP::translateActions() const

printActionName(*action);

// TODO: remove quirk
// TODO: implement conditional effects
if (enumerateEffects)
m_outputStream << ", " << utils::Keyword("effect") << "(" << utils::Number("0") << ")";
m_outputStream << ", " << utils::Keyword("effect") << "(unconditional)";

m_outputStream << ", ";

Expand Down
16 changes: 11 additions & 5 deletions src/plasp/sas/TranslatorASP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ void TranslatorASP::translateActions() const

const auto &operators = m_description.operators();

size_t currentEffectID = 0;

std::for_each(operators.cbegin(), operators.cend(),
[&](const auto &operator_)
{
Expand All @@ -164,8 +166,6 @@ void TranslatorASP::translateActions() const

const auto &effects = operator_.effects();

size_t currentEffectID = 0;

std::for_each(effects.cbegin(), effects.cend(),
[&](const auto &effect)
{
Expand All @@ -186,13 +186,19 @@ void TranslatorASP::translateActions() const

m_outputStream << utils::Keyword("postcondition") << "(";
operator_.printPredicateAsASP(m_outputStream);
m_outputStream << ", " << utils::Keyword("effect") << "(" << utils::Number(std::to_string(currentEffectID)) << "), ";

if (conditions.empty())
m_outputStream << ", " << utils::Keyword("effect") << "(unconditional), ";
else
{
m_outputStream << ", " << utils::Keyword("effect") << "(" << utils::Number(std::to_string(currentEffectID)) << "), ";
currentEffectID++;
}

effect.postcondition().variable().printNameAsASPPredicate(m_outputStream);
m_outputStream << ", ";
effect.postcondition().value().printAsASPPredicate(m_outputStream);
m_outputStream << ")." << std::endl;

currentEffectID++;
});

m_outputStream << utils::Keyword("costs") << "(";
Expand Down

0 comments on commit 08113c9

Please sign in to comment.