From 7924f28ae2c981d83388373044e45ebbfc50ba1a Mon Sep 17 00:00:00 2001 From: sp Date: Fri, 9 Feb 2024 22:23:19 +0100 Subject: [PATCH] introduced new slippery tiles --- util/Grid.cpp | 6 +++++- util/Grid.h | 4 ++++ util/MinigridGrammar.h | 7 ++++++- util/cell.h | 7 ++++++- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/util/Grid.cpp b/util/Grid.cpp index 8f83703..d8a3287 100644 --- a/util/Grid.cpp +++ b/util/Grid.cpp @@ -15,6 +15,10 @@ Grid::Grid(cells gridCells, cells background, const std::map 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(slipperyWest), [](cell c) { return c.type == Type::SlipperyWest; }); + std::copy_if(background.begin(), background.end(), std::back_inserter(slipperyNorthWest), [](cell c) { return c.type == Type::SlipperyNorthWest; }); + std::copy_if(background.begin(), background.end(), std::back_inserter(slipperyNorthEast), [](cell c) { return c.type == Type::SlipperyNorthEast; }); + std::copy_if(background.begin(), background.end(), std::back_inserter(slipperySouthWest), [](cell c) { return c.type == Type::SlipperySouthWest; }); + std::copy_if(background.begin(), background.end(), std::back_inserter(slipperySouthEast), [](cell c) { return c.type == Type::SlipperySouthEast; }); std::copy_if(gridCells.begin(), gridCells.end(), std::back_inserter(lockedDoors), [](cell c) { return c.type == Type::LockedDoor; }); std::copy_if(gridCells.begin(), gridCells.end(), std::back_inserter(unlockedDoors), [](cell c) { return c.type == Type::Door; }); std::copy_if(gridCells.begin(), gridCells.end(), std::back_inserter(goals), [](cell c) { return c.type == Type::Goal; }); @@ -145,7 +149,7 @@ void Grid::printToPrism(std::ostream& os, std::vector& configurat std::map wallRestrictions = {{"North", northRestriction}, {"East", eastRestriction}, {"South", southRestriction}, {"West", westRestriction}}; - std::map slipperyTiles = {{"North", slipperyNorth}, {"East", slipperyEast}, {"South", slipperySouth}, {"West", slipperyWest}}; + std::map slipperyTiles = {{"North", slipperyNorth}, {"East", slipperyEast}, {"South", slipperySouth}, {"West", slipperyWest}, {"NorthWest", slipperyNorthWest}, {"NorthEast", slipperyNorthEast},{"SouthWest", slipperySouthWest},{"SouthEast", slipperySouthEast}}; std::vector agentNames; std::transform(agentNameAndPositionMap.begin(), diff --git a/util/Grid.h b/util/Grid.h index da593ba..1f594c9 100644 --- a/util/Grid.h +++ b/util/Grid.h @@ -44,6 +44,10 @@ class Grid { cells slipperyEast; cells slipperySouth; cells slipperyWest; + cells slipperyNorthWest; + cells slipperyNorthEast; + cells slipperySouthWest; + cells slipperySouthEast; cells lockedDoors; cells unlockedDoors; cells boxes; diff --git a/util/MinigridGrammar.h b/util/MinigridGrammar.h index e2cfddc..ea6c1cf 100644 --- a/util/MinigridGrammar.h +++ b/util/MinigridGrammar.h @@ -66,6 +66,10 @@ template ("e", Type::SlipperyEast) ("s", Type::SlipperySouth) ("w", Type::SlipperyWest) + ("a", Type::SlipperyNorthWest) + ("b", Type::SlipperyNorthEast) + ("c", Type::SlipperySouthWest) + ("d", Type::SlipperySouthEast) ("X", Type::Agent) ("Z", Type::Adversary); color_.add @@ -74,8 +78,9 @@ template ("B", Color::Blue) ("P", Color::Purple) ("Y", Color::Yellow) + ("W", Color::White) (" ", Color::None); - + cell_ = type_ > color_; row_ = (cell_ % -qi::char_("\n")); diff --git a/util/cell.h b/util/cell.h index ca71559..5e69e3b 100644 --- a/util/cell.h +++ b/util/cell.h @@ -23,7 +23,11 @@ enum class Type : char { SlipperyNorth = 'n', SlipperySouth = 's', SlipperyEast = 'e', - SlipperyWest = 'w' + SlipperyWest = 'w', + SlipperyNorthWest = 'a', + SlipperyNorthEast = 'b', + SlipperySouthWest = 'c', + SlipperySouthEast = 'd' }; enum class Color : char { Red = 'R', @@ -31,6 +35,7 @@ enum class Color : char { Blue = 'B', Purple = 'P', Yellow = 'Y', + White = 'W', //Grey = 'G', None = ' ' };