diff --git a/util/Grid.cpp b/util/Grid.cpp index 1184e1e..d13c2b5 100644 --- a/util/Grid.cpp +++ b/util/Grid.cpp @@ -130,6 +130,9 @@ void Grid::printToPrism(std::ostream& os, const prism::ModelType& modelType) { walkable.push_back(agent); walkable.insert(walkable.end(), adversaries.begin(), adversaries.end()); walkable.insert(walkable.end(), lava.begin(), lava.end()); + walkable.insert(walkable.end(), keys.begin(), keys.end()); + walkable.insert(walkable.end(), lockedDoors.begin(), lockedDoors.end()); + for(auto const& c : walkable) { if(isBlocked(c.getNorth())) northRestriction.push_back(c); if(isBlocked(c.getEast())) eastRestriction.push_back(c); @@ -178,10 +181,11 @@ void Grid::printToPrism(std::ostream& os, const prism::ModelType& modelType) { size_t agentIndex = 0; for(auto agentNameAndPosition = agentNameAndPositionMap.begin(); agentNameAndPosition != agentNameAndPositionMap.end(); ++agentNameAndPosition, agentIndex++) { AgentName agentName = agentNameAndPosition->first; + //std::cout << "Agent Name: " << agentName << std::endl; bool agentWithView = std::find(gridOptions.agentsWithView.begin(), gridOptions.agentsWithView.end(), agentName) != gridOptions.agentsWithView.end(); bool agentWithProbabilisticBehaviour = std::find(gridOptions.agentsWithProbabilisticBehaviour.begin(), gridOptions.agentsWithProbabilisticBehaviour.end(), agentName) != gridOptions.agentsWithProbabilisticBehaviour.end(); std::set slipperyActions; - printer.printInitStruct(os, agentName); + printer.printInitStruct(os, agentName, keys); if(agentWithProbabilisticBehaviour) printer.printModule(os, agentName, agentIndex, maxBoundaries, agentNameAndPosition->second, keys, backgroundTiles, agentWithView, gridOptions.probabilitiesForActions); else printer.printModule(os, agentName, agentIndex, maxBoundaries, agentNameAndPosition->second, keys, backgroundTiles, agentWithView); for(auto const& c : slipperyNorth) { diff --git a/util/PrismModulesPrinter.cpp b/util/PrismModulesPrinter.cpp index f6aca04..0b15af2 100644 --- a/util/PrismModulesPrinter.cpp +++ b/util/PrismModulesPrinter.cpp @@ -253,7 +253,7 @@ namespace prism { std::ostream& PrismModulesPrinter::printBooleansForKeys(std::ostream &os, const AgentName &agentName, const cells &keys) { for(auto const& key : keys) { - os << "\t" << agentName << "_has_"<< key.getColor() << "_key : bool init false;\n"; + os << "\t" << agentName << "_has_"<< key.getColor() << "_key : bool;\n";//init false;\n"; } os << "\n"; return os; @@ -292,7 +292,7 @@ namespace prism { return os; } - std::ostream& PrismModulesPrinter::printInitStruct(std::ostream &os, const AgentName &agentName) { + std::ostream& PrismModulesPrinter::printInitStruct(std::ostream &os, const AgentName &agentName, const cells &keys) { os << "init\n"; os << "\t(!AgentIsInGoal & !AgentIsInLava & !AgentDone & !AgentIsOnWall)"; if(enforceOneWays) { @@ -300,8 +300,14 @@ namespace prism { } else { os << " & ( !AgentIsOnSlippery ) "; } + + for (auto const& key : keys) { + os << " & ( !" << agentName << "_has_" << key.getColor() << "_key )"; + } + os << "\nendinit\n\n"; + return os; } diff --git a/util/PrismModulesPrinter.h b/util/PrismModulesPrinter.h index 7a196fc..12dc99f 100644 --- a/util/PrismModulesPrinter.h +++ b/util/PrismModulesPrinter.h @@ -66,7 +66,7 @@ namespace prism { std::ostream& printActionsForKeys(std::ostream &os, const AgentName &agentName, const cells &keys); std::ostream& printBooleansForBackground(std::ostream &os, const AgentName &agentName, const std::map &backgroundTiles); std::ostream& printActionsForBackground(std::ostream &os, const AgentName &agentName, const std::map &backgroundTiles); - std::ostream& printInitStruct(std::ostream &os, const AgentName &agentName); + std::ostream& printInitStruct(std::ostream &os, const AgentName &agentName, const cells &keys); std::ostream& printModule(std::ostream &os, const AgentName &agentName, const size_t &agentIndex, const coordinates &boundaries, const coordinates& initialPosition, const cells &keys, const std::map &backgroundTiles, const bool agentWithView, const std::vector &probabilities = {}); std::ostream& printMovementActions(std::ostream &os, const AgentName &agentName, const size_t &agentIndex, const bool agentWithView, const float &probability = 1.0); std::ostream& printDoneActions(std::ostream &os, const AgentName &agentName, const size_t &agentIndex);