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.

91 lines
6.1 KiB

  1. #pragma once
  2. #include <iostream>
  3. #include <functional>
  4. #include "MinigridGrammar.h"
  5. #include "PrismPrinter.h"
  6. namespace prism {
  7. class PrismModulesPrinter {
  8. public:
  9. PrismModulesPrinter(const ModelType &modelType, const size_t &numberOfPlayer, const bool enforceOneWays = false);
  10. std::ostream& printRestrictionFormula(std::ostream& os, const AgentName &agentName, const std::string &direction, const cells &cells);
  11. 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);
  12. std::ostream& printGoalLabel(std::ostream& os, const AgentName&agentName, const cells &goals);
  13. std::ostream& printCrashLabel(std::ostream &os, const std::vector<AgentName> agentNames);
  14. std::ostream& printAvoidanceLabel(std::ostream &os, const std::vector<AgentName> agentNames, const int &distance);
  15. std::ostream& printKeysLabels(std::ostream& os, const AgentName&agentName, const cells &keys);
  16. std::ostream& printBackgroundLabels(std::ostream &os, const AgentName &agentName, const std::pair<Color, cells> &backgroundTiles);
  17. std::ostream& printIsInLavaFormula(std::ostream& os, const AgentName &agentName, const cells &lava);
  18. std::ostream& printIsFixedFormulas(std::ostream& os, const AgentName &agentName);
  19. std::ostream& printTurningNotAllowedFormulas(std::ostream& os, const AgentName &agentName, const cells &floor);
  20. std::ostream& printWallFormula(std::ostream& os, const AgentName &agentName, const cells &walls);
  21. std::ostream& printFormulas(std::ostream& os,
  22. const AgentName&agentName,
  23. const cells &restrictionNorth,
  24. const cells &restrictionEast,
  25. const cells &restrictionSouth,
  26. const cells &restrictionWest,
  27. const std::vector<std::reference_wrapper<cells>> &slipperyCollection,
  28. const cells &lava,
  29. const cells &walls,
  30. const cells &noTurnFloor,
  31. const cells &slipperyNorth,
  32. const cells &slipperyEast,
  33. const cells &slipperySouth,
  34. const cells &slipperyWest);
  35. /*
  36. * Representation for Slippery Tile.
  37. * -) North: Slips from North to South
  38. * -) East: Slips from East to West
  39. * -) South: Slips from South to North
  40. * -) West: Slips from West to East
  41. */
  42. enum class SlipperyType { North, East, South, West };
  43. /*
  44. * Prints Slippery on move action.
  45. *
  46. * @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.
  47. * @param orientation: Information of slippery type (either north, south, east, west).
  48. */
  49. 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);
  50. /*
  51. * Prints Slippery on turn action.
  52. *
  53. * @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.
  54. * @param orientation: Information of slippery type (either north, south, east, west).
  55. */
  56. 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);
  57. std::ostream& printModel(std::ostream &os, const ModelType &modelType);
  58. std::ostream& printBooleansForKeys(std::ostream &os, const AgentName &agentName, const cells &keys);
  59. std::ostream& printActionsForKeys(std::ostream &os, const AgentName &agentName, const cells &keys);
  60. std::ostream& printBooleansForBackground(std::ostream &os, const AgentName &agentName, const std::map<Color, cells> &backgroundTiles);
  61. std::ostream& printActionsForBackground(std::ostream &os, const AgentName &agentName, const std::map<Color, cells> &backgroundTiles);
  62. std::ostream& printInitStruct(std::ostream &os, const AgentName &agentName);
  63. 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 = {});
  64. std::ostream& printMovementActions(std::ostream &os, const AgentName &agentName, const size_t &agentIndex, const bool agentWithView, const float &probability = 1.0);
  65. std::ostream& printDoneActions(std::ostream &os, const AgentName &agentName, const size_t &agentIndex);
  66. std::ostream& printEndmodule(std::ostream &os);
  67. std::ostream& printPlayerStruct(std::ostream &os, const AgentName &agentName, const bool agentWithView, const std::vector<float> &probabilities = {}, const std::set<std::string> &slipperyActions = {});
  68. std::ostream& printGlobalMoveVariable(std::ostream &os, const size_t &numberOfPlayer);
  69. 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);
  70. std::string moveGuard(const size_t &agentIndex);
  71. std::string moveUpdate(const size_t &agentIndex);
  72. std::string viewVariable(const AgentName &agentName, const size_t &agentDirection, const bool agentWithView);
  73. bool isGame() const;
  74. private:
  75. ModelType const& modelType;
  76. const size_t numberOfPlayer;
  77. bool enforceOneWays;
  78. };
  79. }