Browse Source

started to add non-directional slippery tiles

overwrites
sp 3 months ago
parent
commit
8c38856faf
  1. 4
      util/Grid.cpp
  2. 1
      util/Grid.h
  3. 1
      util/MinigridGrammar.h
  4. 3
      util/PrismFormulaPrinter.cpp
  5. 1
      util/cell.cpp
  6. 1
      util/cell.h

4
util/Grid.cpp

@ -11,6 +11,7 @@ Grid::Grid(cells gridCells, cells background, const std::map<coordinates, float>
std::copy_if(gridCells.begin(), gridCells.end(), std::back_inserter(walls), [](cell c) { return c.type == Type::Wall; }); std::copy_if(gridCells.begin(), gridCells.end(), std::back_inserter(walls), [](cell c) { return c.type == Type::Wall; });
std::copy_if(gridCells.begin(), gridCells.end(), std::back_inserter(lava), [](cell c) { return c.type == Type::Lava; }); std::copy_if(gridCells.begin(), gridCells.end(), std::back_inserter(lava), [](cell c) { return c.type == Type::Lava; });
std::copy_if(gridCells.begin(), gridCells.end(), std::back_inserter(floor), [](cell c) { return c.type == Type::Floor; }); // TODO CHECK IF ALL AGENTS ARE ADDED TO FLOOR std::copy_if(gridCells.begin(), gridCells.end(), std::back_inserter(floor), [](cell c) { return c.type == Type::Floor; }); // TODO CHECK IF ALL AGENTS ARE ADDED TO FLOOR
std::copy_if(gridCells.begin(), gridCells.end(), std::back_inserter(slippery), [](cell c) { return c.type == Type::Slippery; });
std::copy_if(background.begin(), background.end(), std::back_inserter(slipperyNorth), [](cell c) { return c.type == Type::SlipperyNorth; }); std::copy_if(background.begin(), background.end(), std::back_inserter(slipperyNorth), [](cell c) { return c.type == Type::SlipperyNorth; });
std::copy_if(background.begin(), background.end(), std::back_inserter(slipperyEast), [](cell c) { return c.type == Type::SlipperyEast; }); std::copy_if(background.begin(), background.end(), std::back_inserter(slipperyEast), [](cell c) { return c.type == Type::SlipperyEast; });
std::copy_if(background.begin(), background.end(), std::back_inserter(slipperySouth), [](cell c) { return c.type == Type::SlipperySouth; }); std::copy_if(background.begin(), background.end(), std::back_inserter(slipperySouth), [](cell c) { return c.type == Type::SlipperySouth; });
@ -26,6 +27,7 @@ Grid::Grid(cells gridCells, cells background, const std::map<coordinates, float>
std::copy_if(gridCells.begin(), gridCells.end(), std::back_inserter(boxes), [](cell c) { return c.type == Type::Box; }); std::copy_if(gridCells.begin(), gridCells.end(), std::back_inserter(boxes), [](cell c) { return c.type == Type::Box; });
std::copy_if(gridCells.begin(), gridCells.end(), std::back_inserter(balls), [](cell c) { return c.type == Type::Ball; }); std::copy_if(gridCells.begin(), gridCells.end(), std::back_inserter(balls), [](cell c) { return c.type == Type::Ball; });
std::copy_if(gridCells.begin(), gridCells.end(), std::back_inserter(adversaries), [](cell c) { return c.type == Type::Adversary; }); std::copy_if(gridCells.begin(), gridCells.end(), std::back_inserter(adversaries), [](cell c) { return c.type == Type::Adversary; });
agent = *std::find_if(gridCells.begin(), gridCells.end(), [](cell c) { return c.type == Type::Agent; }); agent = *std::find_if(gridCells.begin(), gridCells.end(), [](cell c) { return c.type == Type::Agent; });
floor.push_back(agent); floor.push_back(agent);
@ -161,7 +163,7 @@ void Grid::printToPrism(std::ostream& os, std::vector<Configuration>& configurat
std::map<std::string, cells> wallRestrictions = {{"North", northRestriction}, {"East", eastRestriction}, {"South", southRestriction}, {"West", westRestriction}}; std::map<std::string, cells> wallRestrictions = {{"North", northRestriction}, {"East", eastRestriction}, {"South", southRestriction}, {"West", westRestriction}};
std::map<std::string, cells> slipperyTiles = {{"North", slipperyNorth}, {"East", slipperyEast}, {"South", slipperySouth}, {"West", slipperyWest}, {"NorthWest", slipperyNorthWest}, {"NorthEast", slipperyNorthEast},{"SouthWest", slipperySouthWest},{"SouthEast", slipperySouthEast}};
std::map<std::string, cells> slipperyTiles = {{"Slippery", slippery}, {"North", slipperyNorth}, {"East", slipperyEast}, {"South", slipperySouth}, {"West", slipperyWest}, {"NorthWest", slipperyNorthWest}, {"NorthEast", slipperyNorthEast},{"SouthWest", slipperySouthWest},{"SouthEast", slipperySouthEast}};
std::vector<AgentName> agentNames; std::vector<AgentName> agentNames;
std::transform(agentNameAndPositionMap.begin(), std::transform(agentNameAndPositionMap.begin(),

1
util/Grid.h

@ -42,6 +42,7 @@ class Grid {
cells walls; cells walls;
cells floor; cells floor;
cells slippery;
cells slipperyNorth; cells slipperyNorth;
cells slipperyEast; cells slipperyEast;
cells slipperySouth; cells slipperySouth;

1
util/MinigridGrammar.h

@ -62,6 +62,7 @@ template <typename It>
("B", Type::Box) ("B", Type::Box)
("G", Type::Goal) ("G", Type::Goal)
("V", Type::Lava) ("V", Type::Lava)
("S", Type::Slippery)
("n", Type::SlipperyNorth) ("n", Type::SlipperyNorth)
("e", Type::SlipperyEast) ("e", Type::SlipperyEast)
("s", Type::SlipperySouth) ("s", Type::SlipperySouth)

3
util/PrismFormulaPrinter.cpp

@ -67,7 +67,6 @@ namespace prism {
for(const auto& [direction, cells] : restrictions) { for(const auto& [direction, cells] : restrictions) {
printRestrictionFormula(agentName, direction, cells); printRestrictionFormula(agentName, direction, cells);
} }
if(slipperyBehaviour()) { if(slipperyBehaviour()) {
for(const auto& [direction, cells] : slipperyTiles) { for(const auto& [direction, cells] : slipperyTiles) {
printIsOnFormula(agentName, "Slippery", cells, direction); printIsOnFormula(agentName, "Slippery", cells, direction);
@ -235,7 +234,7 @@ namespace prism {
} }
bool PrismFormulaPrinter::slipperyBehaviour() const { bool PrismFormulaPrinter::slipperyBehaviour() const {
return !slipperyTiles.at("North").empty() || !slipperyTiles.at("East").empty() || !slipperyTiles.at("South").empty() || !slipperyTiles.at("West").empty();
return !slipperyTiles.at("Slippery").empty() || !slipperyTiles.at("North").empty() || !slipperyTiles.at("East").empty() || !slipperyTiles.at("South").empty() || !slipperyTiles.at("West").empty();
} }
bool PrismFormulaPrinter::anyPortableObject() const { bool PrismFormulaPrinter::anyPortableObject() const {
return !keys.empty(); return !keys.empty();

1
util/cell.cpp

@ -83,6 +83,7 @@ std::string cell::getType() const {
case Type::Lava: return "Lava"; case Type::Lava: return "Lava";
case Type::Agent: return "Agent"; case Type::Agent: return "Agent";
case Type::Adversary: return "Adversary"; case Type::Adversary: return "Adversary";
case Type::Slippery: return "Slippery";
case Type::SlipperyNorth: return "SlipperyNorth"; case Type::SlipperyNorth: return "SlipperyNorth";
case Type::SlipperySouth: return "SlipperySouth"; case Type::SlipperySouth: return "SlipperySouth";
case Type::SlipperyEast: return "SlipperyEast"; case Type::SlipperyEast: return "SlipperyEast";

1
util/cell.h

@ -20,6 +20,7 @@ enum class Type : char {
Lava = 'V', Lava = 'V',
Agent = 'X', Agent = 'X',
Adversary = 'Z', Adversary = 'Z',
Slippery = 'S',
SlipperyNorth = 'n', SlipperyNorth = 'n',
SlipperySouth = 's', SlipperySouth = 's',
SlipperyEast = 'e', SlipperyEast = 'e',

Loading…
Cancel
Save