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.

116 lines
5.9 KiB

  1. #pragma once
  2. #include <iostream>
  3. #include <set>
  4. #include <functional>
  5. #include "MinigridGrammar.h"
  6. #include "PrismPrinter.h"
  7. #include "ConfigYaml.h"
  8. std::string northUpdate(const AgentName &a);
  9. std::string southUpdate(const AgentName &a);
  10. std::string eastUpdate(const AgentName &a);
  11. std::string westUpdate(const AgentName &a);
  12. namespace prism {
  13. class PrismModulesPrinter {
  14. public:
  15. PrismModulesPrinter(std::ostream& os, const ModelType &modelType, const coordinates &maxBoundaries, const cells &boxes, const cells &balls, const cells &lockedDoors, const cells &unlockedDoors, const cells &keys, const std::map<std::string, cells> &slipperyTiles, const AgentNameAndPositionMap &agentNameAndPositionMap, std::vector<Configuration> config, const float probIntended, const float faultyProbability, const bool anyLava, const bool anyGoals);
  16. std::ostream& print();
  17. void printModelType(const ModelType &modelType);
  18. bool isGame() const;
  19. private:
  20. void printPortableObjectModule(const cell &object);
  21. void printPortableObjectActions(const std::string &agentName, const std::string &identifier);
  22. void printDoorModule(const cell &object, const bool &opened);
  23. void printLockedDoorActions(const std::string &agentName, const std::string &identifier);
  24. void printUnlockedDoorActions(const std::string &agentName, const std::string &identifier);
  25. void printRobotModule(const AgentName &agentName, const coordinates &initialPosition);
  26. void printPortableObjectActionsForRobot(const std::string &agentName, const std::string &identifier);
  27. void printUnlockedDoorActionsForRobot(const std::string &agentName, const std::string &identifier);
  28. void printLockedDoorActionsForRobot(const std::string &agentName, const std::string &identifier, const std::string &key);
  29. void printMovementActionsForRobot(const std::string &a);
  30. void printTurnActionsForRobot(const std::string &a);
  31. void printSlipperyMovementActionsForRobot(const AgentName &a);
  32. void printSlipperyMovementActionsForNorth(const AgentName &a);
  33. void printSlipperyMovementActionsForEast(const AgentName &a);
  34. void printSlipperyMovementActionsForSouth(const AgentName &a);
  35. void printSlipperyMovementActionsForWest(const AgentName &a);
  36. void printSlipperyTurnActionsForNorth(const AgentName &a);
  37. void printSlipperyTurnActionsForEast(const AgentName &a);
  38. void printSlipperyTurnActionsForSouth(const AgentName &a);
  39. void printSlipperyTurnActionsForWest(const AgentName &a);
  40. std::string printMovementGuard(const AgentName &a, const std::string &direction, const size_t &viewDirection);
  41. std::string printMovementUpdate(const AgentName &a, const update &update) const;
  42. std::string printTurnGuard(const AgentName &a, const std::string &direction, const ActionId &actionId, const std::string &cond = "");
  43. std::string printTurnUpdate(const AgentName &a, const update &u, const ActionId &actionId) const;
  44. std::string printSlipperyMovementGuard(const AgentName &a, const std::string &direction, const ViewDirection &viewDirection, const std::vector<std::string> &guards);
  45. std::string printSlipperyMovementUpdate(const AgentName &a, const std::string &direction, const updates &u) const;
  46. std::string printSlipperyTurnGuard(const AgentName &a, const std::string &direction, const ActionId &actionId, const std::vector<std::string> &guards, const std::string &cond);
  47. std::string printSlipperyTurnUpdate(const AgentName &a, const updates &u);
  48. void printFaultyMovementModule(const AgentName &a);
  49. void printMoveModule();
  50. void printConstants(const std::vector<std::string> &constants);
  51. void printDoneActions(const AgentName &agentName);
  52. void printPlayerStruct(const AgentName &agentName);
  53. void printRewards(const AgentName &agentName, const std::map<coordinates, float> &stateRewards, const cells &lava, const cells &goals, const std::map<Color, cells> &backgroundTiles);
  54. void printConfiguration(const std::vector<Configuration>& configurations);
  55. void printConfiguredActions(const AgentName &agentName);
  56. bool anyPortableObject() const;
  57. bool faultyBehaviour() const;
  58. bool slipperyBehaviour() const;
  59. std::string moveGuard(const AgentName &agentName) const;
  60. std::string faultyBehaviourGuard(const AgentName &agentName, const ActionId &actionId) const;
  61. std::string faultyBehaviourUpdate(const AgentName &agentName, const ActionId &actionId) const;
  62. std::string moveUpdate(const AgentName &agentName) const;
  63. std::string updatesToString(const updates &updates) const;
  64. std::string updateToString(const update &u) const;
  65. std::string viewVariable(const AgentName &agentName, const size_t &agentDirection) const;
  66. std::string buildConjunction(const AgentName &a, std::vector<std::string> formulae) const;
  67. std::ostream &os;
  68. std::stringstream actionStream;
  69. ModelType const &modelType;
  70. coordinates const &maxBoundaries;
  71. AgentName agentName;
  72. cells boxes;
  73. cells balls;
  74. cells lockedDoors;
  75. cells unlockedDoors;
  76. cells keys;
  77. std::map<std::string, cells> slipperyTiles;
  78. const bool anyLava;
  79. const bool anyGoals;
  80. AgentNameAndPositionMap agentNameAndPositionMap;
  81. std::map<AgentName, size_t> agentIndexMap;
  82. size_t numberOfPlayer;
  83. float const faultyProbability;
  84. float const probIntended;
  85. std::vector<Configuration> configuration;
  86. std::vector<ViewDirection> viewDirections = {0, 1, 2, 3};
  87. std::map<ViewDirection, std::string> viewDirectionToString = {{0, "East"}, {1, "South"}, {2, "West"}, {3, "North"}};
  88. std::vector<std::pair<size_t, std::string>> nonMovementActions = { {PICKUP, "pickup"}, {DROP, "drop"}, {TOGGLE, "toggle"}, {DONE, "done"} };
  89. std::map<AgentName, std::set<std::pair<ActionId, std::string>>> agentNameActionMap;
  90. };
  91. }