The source code and dockerfile for the GSW2024 AI Lab.
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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

123 lines
6.5 KiB

2 months ago
  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 &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, const bool canBeDroped = false);
  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, const bool canBeDroped = false);
  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 printNonMovementActionsForRobot(const AgentName &agentName);
  32. void printSlipperyMovementActionsForRobot(const AgentName &a);
  33. void printSlipperyMovementActionsForNorth(const AgentName &a);
  34. void printSlipperyMovementActionsForEast(const AgentName &a);
  35. void printSlipperyMovementActionsForSouth(const AgentName &a);
  36. void printSlipperyMovementActionsForWest(const AgentName &a);
  37. void printSlipperyTurnActionsForNorth(const AgentName &a);
  38. void printSlipperyTurnActionsForEast(const AgentName &a);
  39. void printSlipperyTurnActionsForSouth(const AgentName &a);
  40. void printSlipperyTurnActionsForWest(const AgentName &a);
  41. void printSlipperyMovementActionsForNorthWest(const AgentName &a);
  42. void printSlipperyTurnActionsForNorthWest(const AgentName &a);
  43. void printSlipperyMovementActionsForNorthEast(const AgentName &a);
  44. void printSlipperyTurnActionsForNorthEast(const AgentName &a);
  45. void printSlipperyMovementActionsForSouthWest(const AgentName &a);
  46. void printSlipperyTurnActionsForSouthWest(const AgentName &a);
  47. void printSlipperyMovementActionsForSouthEast(const AgentName &a);
  48. void printSlipperyTurnActionsForSouthEast(const AgentName &a);
  49. std::string printMovementGuard(const AgentName &a, const std::string &direction, const size_t &viewDirection);
  50. std::string printMovementUpdate(const AgentName &a, const update &update) const;
  51. std::string printTurnGuard(const AgentName &a, const std::string &direction, const ActionId &actionId, const std::string &cond = "");
  52. std::string printTurnUpdate(const AgentName &a, const update &u, const ActionId &actionId) const;
  53. std::string printSlipperyMovementGuard(const AgentName &a, const std::string &direction, const ViewDirection &viewDirection, const std::vector<std::string> &guards);
  54. std::string printSlipperyMovementUpdate(const AgentName &a, const std::string &direction, const updates &u) const;
  55. std::string printSlipperyTurnGuard(const AgentName &a, const std::string &direction, const std::string &tiltDirection, const ActionId &actionId, const std::vector<std::string> &guards, const std::string &cond);
  56. std::string printSlipperyTurnUpdate(const AgentName &a, const updates &u);
  57. void printFaultyMovementModule(const AgentName &a);
  58. void printMoveModule();
  59. void printConstants(const std::vector<std::string> &constants);
  60. void printDoneActions(const AgentName &agentName);
  61. void printPlayerStruct(const AgentName &agentName);
  62. void printRewards(const AgentName &agentName, const std::map<coordinates, float> &stateRewards, const cells &lava, const cells &goals, const std::map<Color, cells> &backgroundTiles);
  63. void printConfiguration(const std::vector<Configuration>& configurations);
  64. void printConfiguredActions(const AgentName &agentName);
  65. bool anyPortableObject() const;
  66. bool faultyBehaviour() const;
  67. bool slipperyBehaviour() const;
  68. std::string moveGuard(const AgentName &agentName) const;
  69. std::string faultyBehaviourGuard(const AgentName &agentName, const ActionId &actionId) const;
  70. std::string faultyBehaviourUpdate(const AgentName &agentName, const ActionId &actionId) const;
  71. std::string moveUpdate(const AgentName &agentName) const;
  72. std::string updatesToString(const updates &updates) const;
  73. std::string updateToString(const update &u) const;
  74. std::string viewVariable(const AgentName &agentName, const size_t &agentDirection) const;
  75. std::string buildConjunction(const AgentName &a, std::vector<std::string> formulae) const;
  76. std::ostream &os;
  77. std::stringstream actionStream;
  78. ModelType const &modelType;
  79. coordinates const &maxBoundaries;
  80. AgentName agentName;
  81. cells lockedDoors;
  82. cells unlockedDoors;
  83. cells keys;
  84. std::map<std::string, cells> slipperyTiles;
  85. const bool anyLava;
  86. const bool anyGoals;
  87. AgentNameAndPositionMap agentNameAndPositionMap;
  88. std::map<AgentName, size_t> agentIndexMap;
  89. size_t numberOfPlayer;
  90. float const faultyProbability;
  91. float const probIntended;
  92. std::vector<Configuration> configuration;
  93. std::vector<ViewDirection> viewDirections = {0, 1, 2, 3};
  94. std::map<ViewDirection, std::string> viewDirectionToString = {{0, "East"}, {1, "South"}, {2, "West"}, {3, "North"}};
  95. std::vector<std::pair<size_t, std::string>> nonMovementActions = { {PICKUP, "pickup"}, {DROP, "drop"}, {TOGGLE, "toggle"}, {DONE, "done"} };
  96. std::map<AgentName, std::set<std::pair<ActionId, std::string>>> agentNameActionMap;
  97. };
  98. }