You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
7.0 KiB

  1. #pragma once
  2. #include <iostream>
  3. #include <functional>
  4. #include "MinigridGrammar.h"
  5. #include "PrismPrinter.h"
  6. #include "ConfigYaml.h"
  7. namespace prism {
  8. class PrismModulesPrinter {
  9. public:
  10. PrismModulesPrinter(const ModelType &modelType, const size_t &numberOfPlayer, std::vector<Configuration> config ,const bool enforceOneWays = false);
  11. std::ostream& printRestrictionFormula(std::ostream& os, const AgentName &agentName, const std::string &direction, const cells &cells);
  12. std::ostream& printKeyRestrictionFormula(std::ostream& os, const AgentName &agentName, const std::string &direction, const cells &keys);
  13. std::ostream& printIsOnSlipperyFormula(std::ostream& os, const AgentName &agentName, const std::vector<std::reference_wrapper<cells>> &slipperyCollection, const cells &slipperyNorth, const cells &slipperyEast, const cells &slipperySouth, const cells &slipperyWest);
  14. std::ostream& printGoalLabel(std::ostream& os, const AgentName&agentName, const cells &goals);
  15. std::ostream& printCrashLabel(std::ostream &os, const std::vector<AgentName> agentNames);
  16. std::ostream& printAvoidanceLabel(std::ostream &os, const std::vector<AgentName> agentNames, const int &distance);
  17. std::ostream& printKeysLabels(std::ostream& os, const AgentName&agentName, const cells &keys);
  18. std::ostream& printBackgroundLabels(std::ostream &os, const AgentName &agentName, const std::pair<Color, cells> &backgroundTiles);
  19. std::ostream& printIsInLavaFormula(std::ostream& os, const AgentName &agentName, const cells &lava);
  20. std::ostream& printIsFixedFormulas(std::ostream& os, const AgentName &agentName);
  21. std::ostream& printTurningNotAllowedFormulas(std::ostream& os, const AgentName &agentName, const cells &floor);
  22. std::ostream& printWallFormula(std::ostream& os, const AgentName &agentName, const cells &walls);
  23. std::ostream& printFormulas(std::ostream& os,
  24. const AgentName&agentName,
  25. const cells &restrictionNorth,
  26. const cells &restrictionEast,
  27. const cells &restrictionSouth,
  28. const cells &restrictionWest,
  29. const std::vector<std::reference_wrapper<cells>> &slipperyCollection,
  30. const cells &lava,
  31. const cells &walls,
  32. const cells &noTurnFloor,
  33. const cells &slipperyNorth,
  34. const cells &slipperyEast,
  35. const cells &slipperySouth,
  36. const cells &slipperyWest,
  37. const cells &keys);
  38. std::ostream& printKeyModule(std::ostream &os, const cell &key, const coordinates &boundaries);
  39. /*
  40. * Representation for Slippery Tile.
  41. * -) North: Slips from North to South
  42. * -) East: Slips from East to West
  43. * -) South: Slips from South to North
  44. * -) West: Slips from West to East
  45. */
  46. enum class SlipperyType { North, East, South, West };
  47. /*
  48. * Prints Slippery on move action.
  49. *
  50. * @param neighborhood: Information of wall-blocks in 8-neighborhood { n, nw, e, se, s, sw, w, nw }. If entry is false, then corresponding neighboorhood position is a wall.
  51. * @param orientation: Information of slippery type (either north, south, east, west).
  52. */
  53. std::ostream& printSlipperyMove(std::ostream &os, const AgentName &agentName, const size_t &agentIndex, const coordinates &c, std::set<std::string> &slipperyActions, const std::array<bool, 8>& neighborhood, SlipperyType orientation);
  54. /*
  55. * Prints Slippery on turn action.
  56. *
  57. * @param neighborhood: Information of wall-blocks in 8-neighborhood { n, nw, e, se, s, sw, w, nw }. If entry is false, then corresponding neighboorhood position is a wall.
  58. * @param orientation: Information of slippery type (either north, south, east, west).
  59. */
  60. std::ostream& printSlipperyTurn(std::ostream &os, const AgentName &agentName, const size_t &agentIndex, const coordinates &c, std::set<std::string> &slipperyActions, const std::array<bool, 8>& neighborhood, SlipperyType orientation);
  61. std::ostream& printModel(std::ostream &os, const ModelType &modelType);
  62. std::ostream& printBooleansForKeys(std::ostream &os, const AgentName &agentName, const cells &keys);
  63. std::ostream& printActionsForKeys(std::ostream &os, const AgentName &agentName, const cells &keys);
  64. std::ostream& printBooleansForBackground(std::ostream &os, const AgentName &agentName, const std::map<Color, cells> &backgroundTiles);
  65. std::ostream& printActionsForBackground(std::ostream &os, const AgentName &agentName, const std::map<Color, cells> &backgroundTiles);
  66. std::ostream& printInitStruct(std::ostream &os, const AgentName &agentName, const cells &keys);
  67. 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<Color, cells> &backgroundTiles, const bool agentWithView, const std::vector<float> &probabilities = {});
  68. std::ostream& printMovementActions(std::ostream &os, const AgentName &agentName, const size_t &agentIndex, const bool agentWithView, const float &probability = 1.0);
  69. std::ostream& printDoneActions(std::ostream &os, const AgentName &agentName, const size_t &agentIndex);
  70. std::ostream& printEndmodule(std::ostream &os);
  71. std::ostream& printPlayerStruct(std::ostream &os, const AgentName &agentName, const bool agentWithView, const std::vector<float> &probabilities = {}, const std::set<std::string> &slipperyActions = {});
  72. std::ostream& printGlobalMoveVariable(std::ostream &os, const size_t &numberOfPlayer);
  73. std::ostream& printKeyActions(std::ostream &os, const cell& key ,const std::string &keyIdentifier);
  74. std::ostream& printRewards(std::ostream &os, const AgentName &agentName, const std::map<coordinates, float> &stateRewards, const cells &lava, const cells &goals, const std::map<Color, cells> &backgroundTiles);
  75. std::ostream& printConfiguration(std::ostream &os, const std::vector<Configuration>& configurations);
  76. std::ostream& printConfiguredActions(std::ostream &os, const AgentName &agentName);
  77. std::string moveGuard(const size_t &agentIndex);
  78. std::string pickupGuard(const AgentName &agentName, const std::string keyColor);
  79. std::string dropGuard(const AgentName &agentName, const std::string keyColor, size_t view);
  80. std::string moveUpdate(const size_t &agentIndex);
  81. std::string viewVariable(const AgentName &agentName, const size_t &agentDirection, const bool agentWithView);
  82. bool isGame() const;
  83. private:
  84. ModelType const& modelType;
  85. const size_t numberOfPlayer;
  86. bool enforceOneWays;
  87. std::vector<Configuration> configuration;
  88. std::map<int, std::string> viewDirectionMapping;
  89. };
  90. }