From 568945c7a81a7861c9bb77607685415fa570aa42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Fri, 26 Aug 2016 15:50:39 +0200 Subject: [PATCH] Fixed incorrect output format of conditional effects with SAS. --- CHANGELOG.md | 6 ++++++ src/plasp/sas/TranslatorASP.cpp | 32 ++++++++++++++++---------------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2ba8e5..ff055f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## (unreleased) + +Bug Fixes: + +* fixes incorrect output format of conditional effects with SAS + ## 3.0.2 (2016-08-18) Features: diff --git a/src/plasp/sas/TranslatorASP.cpp b/src/plasp/sas/TranslatorASP.cpp index 09e96b5..94edfc3 100644 --- a/src/plasp/sas/TranslatorASP.cpp +++ b/src/plasp/sas/TranslatorASP.cpp @@ -171,34 +171,34 @@ void TranslatorASP::translateActions() const { const auto &conditions = effect.conditions(); - std::for_each(conditions.cbegin(), conditions.cend(), - [&](const auto &condition) - { - // Conditions of conditional effects - m_outputStream << utils::RuleName("precondition") << "("; - operator_.printPredicateAsASP(m_outputStream); - m_outputStream << ", " << utils::Keyword("effect") << "(" << utils::Number(std::to_string(currentEffectID)) << "), "; - condition.variable().printNameAsASPPredicate(m_outputStream); - m_outputStream << ", "; - condition.value().printAsASPPredicate(m_outputStream); - m_outputStream << ")." << std::endl; - }); - m_outputStream << utils::RuleName("postcondition") << "("; operator_.printPredicateAsASP(m_outputStream); if (conditions.empty()) m_outputStream << ", " << utils::Keyword("effect") << "(" << utils::Reserved("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; + + std::for_each(conditions.cbegin(), conditions.cend(), + [&](const auto &condition) + { + // Conditions of conditional effects + m_outputStream + << utils::RuleName("precondition") << "(" + << utils::Keyword("effect") << "(" << utils::Number(std::to_string(currentEffectID)) << "), "; + condition.variable().printNameAsASPPredicate(m_outputStream); + m_outputStream << ", "; + condition.value().printAsASPPredicate(m_outputStream); + m_outputStream << ")." << std::endl; + }); + + if (!conditions.empty()) + currentEffectID++; }); m_outputStream << utils::RuleName("costs") << "(";