Browse Source

initial commit

main
sp 2 years ago
commit
02c573f62b
  1. 34
      Minigrid2PRISM/.gitignore
  2. 125
      Minigrid2PRISM/0001-WIP-differentiate-between-slippery-tilt-direction.patch
  3. 22
      Minigrid2PRISM/CMakeLists.txt
  4. 546419
      Minigrid2PRISM/Test.shield
  5. 92
      Minigrid2PRISM/agentView.prism
  6. 762212
      Minigrid2PRISM/agentViewOnlyBlue.explicit
  7. 65
      Minigrid2PRISM/agentViewOnlyBlue.prism
  8. 100
      Minigrid2PRISM/allView.prism
  9. 100
      Minigrid2PRISM/both.prism
  10. 13
      Minigrid2PRISM/emptyGrid
  11. 96
      Minigrid2PRISM/foobar
  12. 27
      Minigrid2PRISM/grid
  13. 65
      Minigrid2PRISM/grid.prism
  14. 19
      Minigrid2PRISM/gridLava
  15. 35
      Minigrid2PRISM/gridLava.prism
  16. 15
      Minigrid2PRISM/gridSave
  17. 166
      Minigrid2PRISM/main.cpp
  18. 88
      Minigrid2PRISM/noview.prism
  19. 20
      Minigrid2PRISM/prop
  20. 2
      Minigrid2PRISM/property.prism
  21. 11
      Minigrid2PRISM/smallerGrid
  22. 486
      Minigrid2PRISM/tags
  23. 303
      Minigrid2PRISM/test.prism
  24. 1
      Minigrid2PRISM/test.prop
  25. 5
      Minigrid2PRISM/testGrid
  26. 6
      Minigrid2PRISM/testGridWithSlippery
  27. 7
      Minigrid2PRISM/testGridWithSlipperyAnnotated
  28. 8
      Minigrid2PRISM/util/CMakeLists.txt
  29. 212
      Minigrid2PRISM/util/Grid.cpp
  30. 62
      Minigrid2PRISM/util/Grid.h
  31. 102
      Minigrid2PRISM/util/MinigridGrammar.h
  32. 32
      Minigrid2PRISM/util/OptionParser.cpp
  33. 13
      Minigrid2PRISM/util/OptionParser.h
  34. 496
      Minigrid2PRISM/util/PrismModulesPrinter.cpp
  35. 78
      Minigrid2PRISM/util/PrismModulesPrinter.h
  36. 15
      Minigrid2PRISM/util/PrismPrinter.h
  37. 83
      Minigrid2PRISM/util/cell.cpp
  38. 62
      Minigrid2PRISM/util/cell.h
  39. 1331
      Minigrid2PRISM/util/popl.hpp
  40. 160
      gym_minigrid/.gitignore
  41. 1
      gym_minigrid/.orig_git/HEAD
  42. 11
      gym_minigrid/.orig_git/config
  43. 1
      gym_minigrid/.orig_git/description
  44. 15
      gym_minigrid/.orig_git/hooks/applypatch-msg.sample
  45. 24
      gym_minigrid/.orig_git/hooks/commit-msg.sample
  46. 109
      gym_minigrid/.orig_git/hooks/fsmonitor-watchman.sample
  47. 8
      gym_minigrid/.orig_git/hooks/post-update.sample
  48. 14
      gym_minigrid/.orig_git/hooks/pre-applypatch.sample
  49. 49
      gym_minigrid/.orig_git/hooks/pre-commit.sample
  50. 13
      gym_minigrid/.orig_git/hooks/pre-merge-commit.sample
  51. 53
      gym_minigrid/.orig_git/hooks/pre-push.sample
  52. 169
      gym_minigrid/.orig_git/hooks/pre-rebase.sample
  53. 24
      gym_minigrid/.orig_git/hooks/pre-receive.sample
  54. 42
      gym_minigrid/.orig_git/hooks/prepare-commit-msg.sample
  55. 128
      gym_minigrid/.orig_git/hooks/update.sample
  56. BIN
      gym_minigrid/.orig_git/index
  57. 6
      gym_minigrid/.orig_git/info/exclude
  58. 1
      gym_minigrid/.orig_git/logs/HEAD
  59. 1
      gym_minigrid/.orig_git/logs/refs/heads/ag_proof_of_concept
  60. 1
      gym_minigrid/.orig_git/logs/refs/remotes/origin/HEAD
  61. BIN
      gym_minigrid/.orig_git/objects/pack/pack-54b6a72683794b61ae148f24378d4f8d4ad4a769.idx
  62. BIN
      gym_minigrid/.orig_git/objects/pack/pack-54b6a72683794b61ae148f24378d4f8d4ad4a769.pack
  63. 3
      gym_minigrid/.orig_git/packed-refs
  64. 1
      gym_minigrid/.orig_git/refs/heads/ag_proof_of_concept
  65. 1
      gym_minigrid/.orig_git/refs/remotes/origin/HEAD
  66. 202
      gym_minigrid/LICENSE
  67. 111
      gym_minigrid/PKG-INFO
  68. 525
      gym_minigrid/README.md
  69. 230
      gym_minigrid/gym_minigrid/Task.py
  70. 625
      gym_minigrid/gym_minigrid/__init__.py
  71. 62
      gym_minigrid/gym_minigrid/benchmark.py
  72. 40
      gym_minigrid/gym_minigrid/envs/__init__.py
  73. 67
      gym_minigrid/gym_minigrid/envs/abagarion.py
  74. 172
      gym_minigrid/gym_minigrid/envs/agExperimentSetTwo.py
  75. 498
      gym_minigrid/gym_minigrid/envs/agExperiments.py
  76. 439
      gym_minigrid/gym_minigrid/envs/agSmall.py
  77. 103
      gym_minigrid/gym_minigrid/envs/blockedunlockpickup.py
  78. 76
      gym_minigrid/gym_minigrid/envs/cliffWalking.py
  79. 65
      gym_minigrid/gym_minigrid/envs/columnsMini.py
  80. 166
      gym_minigrid/gym_minigrid/envs/crossing.py
  81. 110
      gym_minigrid/gym_minigrid/envs/distshift.py
  82. 91
      gym_minigrid/gym_minigrid/envs/doorkey.py
  83. 151
      gym_minigrid/gym_minigrid/envs/dynamicobstacles.py
  84. 98
      gym_minigrid/gym_minigrid/envs/empty.py
  85. 83
      gym_minigrid/gym_minigrid/envs/experimentSlippery.py
  86. 169
      gym_minigrid/gym_minigrid/envs/fetch.py
  87. 119
      gym_minigrid/gym_minigrid/envs/fourrooms.py
  88. 136
      gym_minigrid/gym_minigrid/envs/gotodoor.py
  89. 104
      gym_minigrid/gym_minigrid/envs/gotoobject.py
  90. 91
      gym_minigrid/gym_minigrid/envs/guidedRLExperiments.py
  91. 119
      gym_minigrid/gym_minigrid/envs/keycorridor.py
  92. 79
      gym_minigrid/gym_minigrid/envs/lavaObstaclesMini.py
  93. 58
      gym_minigrid/gym_minigrid/envs/lavaSymmetricMini.py
  94. 122
      gym_minigrid/gym_minigrid/envs/lavagap.py
  95. 167
      gym_minigrid/gym_minigrid/envs/lockedroom.py
  96. 151
      gym_minigrid/gym_minigrid/envs/memory.py
  97. 271
      gym_minigrid/gym_minigrid/envs/multiroom.py
  98. 246
      gym_minigrid/gym_minigrid/envs/obstructedmaze.py
  99. 90
      gym_minigrid/gym_minigrid/envs/playground.py
  100. 192
      gym_minigrid/gym_minigrid/envs/putnear.py

34
Minigrid2PRISM/.gitignore

@ -0,0 +1,34 @@
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
build/*

125
Minigrid2PRISM/0001-WIP-differentiate-between-slippery-tilt-direction.patch

@ -0,0 +1,125 @@
From cbcb339cad57db456fb11dc844c99119cb8485e8 Mon Sep 17 00:00:00 2001
From: sp <stefan.pranger@iaik.tugraz.at>
Date: Wed, 5 Jul 2023 15:44:04 +0200
Subject: [PATCH] WIP: differentiate between slippery tilt direction
---
Minigrid2PRISM/util/Grid.cpp | 24 +++++++++++++++------
Minigrid2PRISM/util/Grid.h | 5 ++++-
Minigrid2PRISM/util/MinigridGrammar.h | 5 ++++-
Minigrid2PRISM/util/PrismModulesPrinter.cpp | 10 ++++-----
4 files changed, 31 insertions(+), 13 deletions(-)
diff --git a/Minigrid2PRISM/util/Grid.cpp b/Minigrid2PRISM/util/Grid.cpp
index 9da5786..c6cf225 100644
--- a/Minigrid2PRISM/util/Grid.cpp
+++ b/Minigrid2PRISM/util/Grid.cpp
@@ -16,8 +16,17 @@ Grid::Grid(cells gridCells, cells background, const GridOptions &gridOptions, co
std::copy_if(gridCells.begin(), gridCells.end(), std::back_inserter(floor), [](cell c) {
return c.type == Type::Floor;
});
- std::copy_if(background.begin(), background.end(), std::back_inserter(slippery), [](cell c) {
- return c.type == Type::Slippery;
+ std::copy_if(background.begin(), background.end(), std::back_inserter(northSlippery), [](cell c) {
+ return c.type == Type::NorthSlippery;
+ });
+ std::copy_if(background.begin(), background.end(), std::back_inserter(southSlippery), [](cell c) {
+ return c.type == Type::SouthSlippery;
+ });
+ std::copy_if(background.begin(), background.end(), std::back_inserter(eastSlippery), [](cell c) {
+ return c.type == Type::EastSlippery;
+ });
+ std::copy_if(background.begin(), background.end(), std::back_inserter(westSlippery), [](cell c) {
+ return c.type == Type::WestSlippery;
});
std::copy_if(gridCells.begin(), gridCells.end(), std::back_inserter(lockedDoors), [](cell c) {
return c.type == Type::LockedDoor;
@@ -158,11 +167,14 @@ void Grid::printToPrism(std::ostream& os, const prism::ModelType& modelType) {
std::set<std::string> slipperyActions;
if(agentWithProbabilisticBehaviour) printer.printModule(os, agentName, agentIndex, maxBoundaries, agentNameAndPosition->second, keys, agentWithView, gridOptions.probabilitiesForActions);
else printer.printModule(os, agentName, agentIndex, maxBoundaries, agentNameAndPosition->second, keys, agentWithView);
- for(auto const& c : slippery) {
+ for(auto const& c : northSlippery) {
+ printer.printSlippery(os, agentName, agentIndex, c.getCoordinates(), slipperyActions, getWalkableDirOf8Neighborhood(c), 3);
+ for(auto const& c : southSlippery) {
+ printer.printSlippery(os, agentName, agentIndex, c.getCoordinates(), slipperyActions, getWalkableDirOf8Neighborhood(c), 3);
+ for(auto const& c : eastSlippery) {
+ printer.printSlippery(os, agentName, agentIndex, c.getCoordinates(), slipperyActions, getWalkableDirOf8Neighborhood(c), 3);
+ for(auto const& c : westSlippery) {
printer.printSlippery(os, agentName, agentIndex, c.getCoordinates(), slipperyActions, getWalkableDirOf8Neighborhood(c), 3);
- printer.printSlippery(os, agentName, agentIndex, c.getCoordinates(), slipperyActions, getWalkableDirOf8Neighborhood(c), 0);
- printer.printSlippery(os, agentName, agentIndex, c.getCoordinates(), slipperyActions, getWalkableDirOf8Neighborhood(c), 1);
- printer.printSlippery(os, agentName, agentIndex, c.getCoordinates(), slipperyActions, getWalkableDirOf8Neighborhood(c), 2);
// printer.printSlipperyMoveNorth(os, agentName, agentIndex, c.getCoordinates(), isBlocked(c.getNorth()), isBlocked(c.getNorth(allGridCells).getEast()), isBlocked(c.getNorth(allGridCells).getWest()), slipperyActions, getWalkableDirOf8Neighborhood(c));
// printer.printSlipperyMoveEast( os, agentName, agentIndex, c.getCoordinates(), isBlocked(c.getEast()), isBlocked(c.getNorth(allGridCells).getEast()), isBlocked(c.getSouth(allGridCells).getEast()), slipperyActions);
// printer.printSlipperyMoveSouth(os, agentName, agentIndex, c.getCoordinates(), isBlocked(c.getSouth()), isBlocked(c.getSouth(allGridCells).getEast()), isBlocked(c.getSouth(allGridCells).getWest()), slipperyActions);
diff --git a/Minigrid2PRISM/util/Grid.h b/Minigrid2PRISM/util/Grid.h
index f42b6e7..f908138 100644
--- a/Minigrid2PRISM/util/Grid.h
+++ b/Minigrid2PRISM/util/Grid.h
@@ -45,7 +45,10 @@ class Grid {
cells walls;
cells floor;
- cells slippery;
+ cells northSlippery;
+ cells southSlippery;
+ cells eastSlippery;
+ cells westSlippery;
cells lockedDoors;
cells boxes;
cells lava;
diff --git a/Minigrid2PRISM/util/MinigridGrammar.h b/Minigrid2PRISM/util/MinigridGrammar.h
index 5d73d87..e32db99 100644
--- a/Minigrid2PRISM/util/MinigridGrammar.h
+++ b/Minigrid2PRISM/util/MinigridGrammar.h
@@ -62,7 +62,10 @@ template <typename It>
("B", Type::Box)
("G", Type::Goal)
("V", Type::Lava)
- ("S", Type::Slippery)
+ ("n", Type::NorthSlippery)
+ ("s", Type::SouthSlippery)
+ ("e", Type::EastSlippery)
+ ("w", Type::WestSlippery)
("X", Type::Agent)
("Z", Type::Adversary);
color_.add
diff --git a/Minigrid2PRISM/util/PrismModulesPrinter.cpp b/Minigrid2PRISM/util/PrismModulesPrinter.cpp
index b6661ef..3a32932 100644
--- a/Minigrid2PRISM/util/PrismModulesPrinter.cpp
+++ b/Minigrid2PRISM/util/PrismModulesPrinter.cpp
@@ -184,9 +184,9 @@ namespace prism {
if(agentWithView) {
os << "\tview" << agentName << " : [0..3] init 0;\n";
os << "\n";
- os << "\t[" << agentName << "_turn_right] " << moveGuard(agentIndex) << " !" << agentName << "IsInGoal & !" << agentName << "IsInLava -> (view" << agentName << "'=mod(view" << agentName << " + 1, 4)) " << moveUpdate(agentIndex) << ";\n";
- os << "\t[" << agentName << "_turn_left] " << moveGuard(agentIndex) << " !" << agentName << "IsInGoal & !" << agentName << "IsInLava & view" << agentName << ">0 -> (view" << agentName << "'=view" << agentName << " - 1) " << moveUpdate(agentIndex) << ";\n";
- os << "\t[" << agentName << "_turn_left] " << moveGuard(agentIndex) << " !" << agentName << "IsInGoal & !" << agentName << "IsInLava & view" << agentName << "=0 -> (view" << agentName << "'=3) " << moveUpdate(agentIndex) << ";\n";
+ os << "\t[" << agentName << "_turn_right] " << moveGuard(agentIndex) << " !" << agentName << "IsInGoal & !" << agentName << "IsInLava & !AgentIsOnSlippery-> (view" << agentName << "'=mod(view" << agentName << " + 1, 4)) " << moveUpdate(agentIndex) << ";\n";
+ os << "\t[" << agentName << "_turn_left] " << moveGuard(agentIndex) << " !" << agentName << "IsInGoal & !" << agentName << "IsInLava & !AgentIsOnSlippery& view" << agentName << ">0 -> (view" << agentName << "'=view" << agentName << " - 1) " << moveUpdate(agentIndex) << ";\n";
+ os << "\t[" << agentName << "_turn_left] " << moveGuard(agentIndex) << " !" << agentName << "IsInGoal & !" << agentName << "IsInLava & !AgentIsOnSlippery& view" << agentName << "=0 -> (view" << agentName << "'=3) " << moveUpdate(agentIndex) << ";\n";
} else {
os << "\t[" << agentName << "_turns] " << moveGuard(agentIndex) << " true -> (x" << agentName << "'=x" << agentName << ")" << moveUpdate(agentIndex) << ";\n";
}
@@ -256,7 +256,7 @@ namespace prism {
// direction specifics
std::size_t straightPosIndex;
- std::string actionName, specialTransition; // if straight ahead is blocked
+ std::string actionName, specialTransition; // if straight ahead is blocked
std::array<std::size_t, ALL_POSS_DIRECTIONS> prob_piece_dir; // from north clockwise
switch (direction)
@@ -367,7 +367,7 @@ namespace prism {
std::ostream& PrismModulesPrinter::printRewards(std::ostream &os, const std::map<coordinates, float> &stateRewards, const cells &lava, const cells &goals) {
os << "rewards \"NoBFS\"\n";
- os << "\tAgentIsInGoalAndNotDone: 100;\n";
+ //os << "\tAgentIsInGoalAndNotDone: 100;\n";
os << "\tAgentIsInLavaAndNotDone: -100;\n";
os << "endrewards\n";
os << "rewards \"WithBFS\"\n";
--
2.25.1

22
Minigrid2PRISM/CMakeLists.txt

@ -0,0 +1,22 @@
include(util/CMakeLists.txt)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'")
add_definitions(-DLOG_DEBUG)
cmake_minimum_required(VERSION 3.0...3.22)
set(CMAKE_BUILD_TYPE Debug)
project(
Minigrid2PRISM
VERSION 0.1
LANGUAGES CXX)
add_executable(main
${SRCS}
main.cpp
)
target_link_libraries(main pthread)

546419
Minigrid2PRISM/Test.shield
File diff suppressed because it is too large
View File

92
Minigrid2PRISM/agentView.prism

@ -0,0 +1,92 @@
smg
player Agent
[Agent_move_north], [Agent_move_east], [Agent_move_south], [Agent_move_west], [Agent_turn_left], [Agent_turn_right]
endplayer
player Blue
[Blue_move_north], [Blue_move_east], [Blue_move_south], [Blue_move_west], [Blue_turns]
endplayer
player Green
[Green_move_north], [Green_move_east], [Green_move_south], [Green_move_west], [Green_turns]
endplayer
global move : [0..2] init 0;
label AgentOnBlue = (xAgent=1&yAgent=1) | (xAgent=1&yAgent=2) | (xAgent=1&yAgent=3) | (xAgent=1&yAgent=6) | (xAgent=1&yAgent=7) | (xAgent=1&yAgent=8) | (xAgent=1&yAgent=9) | (xAgent=1&yAgent=10) | (xAgent=1&yAgent=11) | (xAgent=2&yAgent=1) | (xAgent=2&yAgent=11) | (xAgent=3&yAgent=1) | (xAgent=3&yAgent=2) | (xAgent=3&yAgent=3) | (xAgent=3&yAgent=4) | (xAgent=3&yAgent=5) | (xAgent=3&yAgent=6) | (xAgent=3&yAgent=7) | (xAgent=3&yAgent=8) | (xAgent=3&yAgent=9) | (xAgent=3&yAgent=10) | (xAgent=3&yAgent=11);
label BlueOnBlue = (xBlue=1&yBlue=1) | (xBlue=1&yBlue=2) | (xBlue=1&yBlue=3) | (xBlue=1&yBlue=6) | (xBlue=1&yBlue=7) | (xBlue=1&yBlue=8) | (xBlue=1&yBlue=9) | (xBlue=1&yBlue=10) | (xBlue=1&yBlue=11) | (xBlue=2&yBlue=1) | (xBlue=2&yBlue=11) | (xBlue=3&yBlue=1) | (xBlue=3&yBlue=2) | (xBlue=3&yBlue=3) | (xBlue=3&yBlue=4) | (xBlue=3&yBlue=5) | (xBlue=3&yBlue=6) | (xBlue=3&yBlue=7) | (xBlue=3&yBlue=8) | (xBlue=3&yBlue=9) | (xBlue=3&yBlue=10) | (xBlue=3&yBlue=11);
label GreenOnBlue = (xGreen=1&yGreen=1) | (xGreen=1&yGreen=2) | (xGreen=1&yGreen=3) | (xGreen=1&yGreen=6) | (xGreen=1&yGreen=7) | (xGreen=1&yGreen=8) | (xGreen=1&yGreen=9) | (xGreen=1&yGreen=10) | (xGreen=1&yGreen=11) | (xGreen=2&yGreen=1) | (xGreen=2&yGreen=11) | (xGreen=3&yGreen=1) | (xGreen=3&yGreen=2) | (xGreen=3&yGreen=3) | (xGreen=3&yGreen=4) | (xGreen=3&yGreen=5) | (xGreen=3&yGreen=6) | (xGreen=3&yGreen=7) | (xGreen=3&yGreen=8) | (xGreen=3&yGreen=9) | (xGreen=3&yGreen=10) | (xGreen=3&yGreen=11);
label AgentOnGreen = (xAgent=9&yAgent=1) | (xAgent=9&yAgent=2) | (xAgent=9&yAgent=3) | (xAgent=9&yAgent=4) | (xAgent=9&yAgent=5) | (xAgent=9&yAgent=6) | (xAgent=9&yAgent=7) | (xAgent=9&yAgent=8) | (xAgent=9&yAgent=9) | (xAgent=9&yAgent=10) | (xAgent=9&yAgent=11) | (xAgent=10&yAgent=1) | (xAgent=10&yAgent=11) | (xAgent=11&yAgent=1) | (xAgent=11&yAgent=2) | (xAgent=11&yAgent=3) | (xAgent=11&yAgent=4) | (xAgent=11&yAgent=5) | (xAgent=11&yAgent=6) | (xAgent=11&yAgent=7) | (xAgent=11&yAgent=8) | (xAgent=11&yAgent=9) | (xAgent=11&yAgent=10) | (xAgent=11&yAgent=11);
label BlueOnGreen = (xBlue=9&yBlue=1) | (xBlue=9&yBlue=2) | (xBlue=9&yBlue=3) | (xBlue=9&yBlue=4) | (xBlue=9&yBlue=5) | (xBlue=9&yBlue=6) | (xBlue=9&yBlue=7) | (xBlue=9&yBlue=8) | (xBlue=9&yBlue=9) | (xBlue=9&yBlue=10) | (xBlue=9&yBlue=11) | (xBlue=10&yBlue=1) | (xBlue=10&yBlue=11) | (xBlue=11&yBlue=1) | (xBlue=11&yBlue=2) | (xBlue=11&yBlue=3) | (xBlue=11&yBlue=4) | (xBlue=11&yBlue=5) | (xBlue=11&yBlue=6) | (xBlue=11&yBlue=7) | (xBlue=11&yBlue=8) | (xBlue=11&yBlue=9) | (xBlue=11&yBlue=10) | (xBlue=11&yBlue=11);
label GreenOnGreen = (xGreen=9&yGreen=1) | (xGreen=9&yGreen=2) | (xGreen=9&yGreen=3) | (xGreen=9&yGreen=4) | (xGreen=9&yGreen=5) | (xGreen=9&yGreen=6) | (xGreen=9&yGreen=7) | (xGreen=9&yGreen=8) | (xGreen=9&yGreen=9) | (xGreen=9&yGreen=10) | (xGreen=9&yGreen=11) | (xGreen=10&yGreen=1) | (xGreen=10&yGreen=11) | (xGreen=11&yGreen=1) | (xGreen=11&yGreen=2) | (xGreen=11&yGreen=3) | (xGreen=11&yGreen=4) | (xGreen=11&yGreen=5) | (xGreen=11&yGreen=6) | (xGreen=11&yGreen=7) | (xGreen=11&yGreen=8) | (xGreen=11&yGreen=9) | (xGreen=11&yGreen=10) | (xGreen=11&yGreen=11);
label AgentOnRed = (xAgent=1&yAgent=4) | (xAgent=1&yAgent=5);
label BlueOnRed = (xBlue=1&yBlue=4) | (xBlue=1&yBlue=5);
label GreenOnRed = (xGreen=1&yGreen=4) | (xGreen=1&yGreen=5);
formula AgentCannotMoveNorth = (xAgent=1&yAgent=2) | (xAgent=1&yAgent=3) | (xAgent=1&yAgent=4) | (xAgent=1&yAgent=5) | (xAgent=1&yAgent=6) | (xAgent=1&yAgent=7) | (xAgent=1&yAgent=8) | (xAgent=1&yAgent=9) | (xAgent=1&yAgent=10) | (xAgent=1&yAgent=11) | (xAgent=3&yAgent=2) | (xAgent=3&yAgent=3) | (xAgent=3&yAgent=4) | (xAgent=3&yAgent=5) | (xAgent=3&yAgent=6) | (xAgent=3&yAgent=7) | (xAgent=3&yAgent=8) | (xAgent=3&yAgent=9) | (xAgent=3&yAgent=10) | (xAgent=11&yAgent=2) | (xAgent=11&yAgent=3) | (xAgent=11&yAgent=4) | (xAgent=11&yAgent=5) | (xAgent=11&yAgent=6) | (xAgent=11&yAgent=7) | (xAgent=11&yAgent=8) | (xAgent=11&yAgent=9) | (xAgent=11&yAgent=10) | (xAgent=1&yAgent=1);
formula AgentCannotMoveEast = (xAgent=1&yAgent=11) | (xAgent=2&yAgent=1) | (xAgent=2&yAgent=11) | (xAgent=3&yAgent=11) | (xAgent=4&yAgent=11) | (xAgent=5&yAgent=11) | (xAgent=6&yAgent=11) | (xAgent=8&yAgent=11) | (xAgent=9&yAgent=11) | (xAgent=10&yAgent=1) | (xAgent=10&yAgent=11) | (xAgent=11&yAgent=11) | (xAgent=7&yAgent=11);
formula AgentCannotMoveSouth = (xAgent=1&yAgent=2) | (xAgent=1&yAgent=3) | (xAgent=1&yAgent=4) | (xAgent=1&yAgent=5) | (xAgent=1&yAgent=6) | (xAgent=1&yAgent=7) | (xAgent=1&yAgent=8) | (xAgent=1&yAgent=9) | (xAgent=1&yAgent=10) | (xAgent=9&yAgent=2) | (xAgent=9&yAgent=3) | (xAgent=9&yAgent=4) | (xAgent=9&yAgent=5) | (xAgent=9&yAgent=6) | (xAgent=9&yAgent=7) | (xAgent=9&yAgent=8) | (xAgent=9&yAgent=9) | (xAgent=9&yAgent=10) | (xAgent=11&yAgent=1) | (xAgent=11&yAgent=2) | (xAgent=11&yAgent=3) | (xAgent=11&yAgent=4) | (xAgent=11&yAgent=5) | (xAgent=11&yAgent=6) | (xAgent=11&yAgent=7) | (xAgent=11&yAgent=8) | (xAgent=11&yAgent=9) | (xAgent=11&yAgent=10) | (xAgent=11&yAgent=11);
formula AgentCannotMoveWest = (xAgent=2&yAgent=1) | (xAgent=2&yAgent=11) | (xAgent=3&yAgent=1) | (xAgent=5&yAgent=1) | (xAgent=6&yAgent=1) | (xAgent=7&yAgent=1) | (xAgent=8&yAgent=1) | (xAgent=9&yAgent=1) | (xAgent=10&yAgent=1) | (xAgent=10&yAgent=11) | (xAgent=11&yAgent=1) | (xAgent=1&yAgent=1) | (xAgent=4&yAgent=1);
formula AgentIsOnSlippery = false;
label AgentGoal = false;
formula BlueCannotMoveNorth = (xBlue=1&yBlue=2) | (xBlue=1&yBlue=3) | (xBlue=1&yBlue=4) | (xBlue=1&yBlue=5) | (xBlue=1&yBlue=6) | (xBlue=1&yBlue=7) | (xBlue=1&yBlue=8) | (xBlue=1&yBlue=9) | (xBlue=1&yBlue=10) | (xBlue=1&yBlue=11) | (xBlue=3&yBlue=2) | (xBlue=3&yBlue=3) | (xBlue=3&yBlue=4) | (xBlue=3&yBlue=5) | (xBlue=3&yBlue=6) | (xBlue=3&yBlue=7) | (xBlue=3&yBlue=8) | (xBlue=3&yBlue=9) | (xBlue=3&yBlue=10) | (xBlue=11&yBlue=2) | (xBlue=11&yBlue=3) | (xBlue=11&yBlue=4) | (xBlue=11&yBlue=5) | (xBlue=11&yBlue=6) | (xBlue=11&yBlue=7) | (xBlue=11&yBlue=8) | (xBlue=11&yBlue=9) | (xBlue=11&yBlue=10) | (xBlue=1&yBlue=1);
formula BlueCannotMoveEast = (xBlue=1&yBlue=11) | (xBlue=2&yBlue=1) | (xBlue=2&yBlue=11) | (xBlue=3&yBlue=11) | (xBlue=4&yBlue=11) | (xBlue=5&yBlue=11) | (xBlue=6&yBlue=11) | (xBlue=8&yBlue=11) | (xBlue=9&yBlue=11) | (xBlue=10&yBlue=1) | (xBlue=10&yBlue=11) | (xBlue=11&yBlue=11) | (xBlue=7&yBlue=11);
formula BlueCannotMoveSouth = (xBlue=1&yBlue=2) | (xBlue=1&yBlue=3) | (xBlue=1&yBlue=4) | (xBlue=1&yBlue=5) | (xBlue=1&yBlue=6) | (xBlue=1&yBlue=7) | (xBlue=1&yBlue=8) | (xBlue=1&yBlue=9) | (xBlue=1&yBlue=10) | (xBlue=9&yBlue=2) | (xBlue=9&yBlue=3) | (xBlue=9&yBlue=4) | (xBlue=9&yBlue=5) | (xBlue=9&yBlue=6) | (xBlue=9&yBlue=7) | (xBlue=9&yBlue=8) | (xBlue=9&yBlue=9) | (xBlue=9&yBlue=10) | (xBlue=11&yBlue=1) | (xBlue=11&yBlue=2) | (xBlue=11&yBlue=3) | (xBlue=11&yBlue=4) | (xBlue=11&yBlue=5) | (xBlue=11&yBlue=6) | (xBlue=11&yBlue=7) | (xBlue=11&yBlue=8) | (xBlue=11&yBlue=9) | (xBlue=11&yBlue=10) | (xBlue=11&yBlue=11);
formula BlueCannotMoveWest = (xBlue=2&yBlue=1) | (xBlue=2&yBlue=11) | (xBlue=3&yBlue=1) | (xBlue=5&yBlue=1) | (xBlue=6&yBlue=1) | (xBlue=7&yBlue=1) | (xBlue=8&yBlue=1) | (xBlue=9&yBlue=1) | (xBlue=10&yBlue=1) | (xBlue=10&yBlue=11) | (xBlue=11&yBlue=1) | (xBlue=1&yBlue=1) | (xBlue=4&yBlue=1);
formula BlueIsOnSlippery = false;
label BlueGoal = false;
formula GreenCannotMoveNorth = (xGreen=1&yGreen=2) | (xGreen=1&yGreen=3) | (xGreen=1&yGreen=4) | (xGreen=1&yGreen=5) | (xGreen=1&yGreen=6) | (xGreen=1&yGreen=7) | (xGreen=1&yGreen=8) | (xGreen=1&yGreen=9) | (xGreen=1&yGreen=10) | (xGreen=1&yGreen=11) | (xGreen=3&yGreen=2) | (xGreen=3&yGreen=3) | (xGreen=3&yGreen=4) | (xGreen=3&yGreen=5) | (xGreen=3&yGreen=6) | (xGreen=3&yGreen=7) | (xGreen=3&yGreen=8) | (xGreen=3&yGreen=9) | (xGreen=3&yGreen=10) | (xGreen=11&yGreen=2) | (xGreen=11&yGreen=3) | (xGreen=11&yGreen=4) | (xGreen=11&yGreen=5) | (xGreen=11&yGreen=6) | (xGreen=11&yGreen=7) | (xGreen=11&yGreen=8) | (xGreen=11&yGreen=9) | (xGreen=11&yGreen=10) | (xGreen=1&yGreen=1);
formula GreenCannotMoveEast = (xGreen=1&yGreen=11) | (xGreen=2&yGreen=1) | (xGreen=2&yGreen=11) | (xGreen=3&yGreen=11) | (xGreen=4&yGreen=11) | (xGreen=5&yGreen=11) | (xGreen=6&yGreen=11) | (xGreen=8&yGreen=11) | (xGreen=9&yGreen=11) | (xGreen=10&yGreen=1) | (xGreen=10&yGreen=11) | (xGreen=11&yGreen=11) | (xGreen=7&yGreen=11);
formula GreenCannotMoveSouth = (xGreen=1&yGreen=2) | (xGreen=1&yGreen=3) | (xGreen=1&yGreen=4) | (xGreen=1&yGreen=5) | (xGreen=1&yGreen=6) | (xGreen=1&yGreen=7) | (xGreen=1&yGreen=8) | (xGreen=1&yGreen=9) | (xGreen=1&yGreen=10) | (xGreen=9&yGreen=2) | (xGreen=9&yGreen=3) | (xGreen=9&yGreen=4) | (xGreen=9&yGreen=5) | (xGreen=9&yGreen=6) | (xGreen=9&yGreen=7) | (xGreen=9&yGreen=8) | (xGreen=9&yGreen=9) | (xGreen=9&yGreen=10) | (xGreen=11&yGreen=1) | (xGreen=11&yGreen=2) | (xGreen=11&yGreen=3) | (xGreen=11&yGreen=4) | (xGreen=11&yGreen=5) | (xGreen=11&yGreen=6) | (xGreen=11&yGreen=7) | (xGreen=11&yGreen=8) | (xGreen=11&yGreen=9) | (xGreen=11&yGreen=10) | (xGreen=11&yGreen=11);
formula GreenCannotMoveWest = (xGreen=2&yGreen=1) | (xGreen=2&yGreen=11) | (xGreen=3&yGreen=1) | (xGreen=5&yGreen=1) | (xGreen=6&yGreen=1) | (xGreen=7&yGreen=1) | (xGreen=8&yGreen=1) | (xGreen=9&yGreen=1) | (xGreen=10&yGreen=1) | (xGreen=10&yGreen=11) | (xGreen=11&yGreen=1) | (xGreen=1&yGreen=1) | (xGreen=4&yGreen=1);
formula GreenIsOnSlippery = false;
label GreenGoal = false;
label crash = (xAgent=xBlue)&(yAgent=yBlue) | (xAgent=xGreen)&(yAgent=yGreen);
module Agent
xAgent : [1..12] init 1;
yAgent : [1..12] init 1;
viewAgent : [0..3] init 1;
[Agent_turn_right] move=0 & true -> (viewAgent'=mod(viewAgent + 1, 4)) & (move'=1) ;
[Agent_turn_left] move=0 & viewAgent>0 -> (viewAgent'=viewAgent - 1) & (move'=1) ;
[Agent_turn_left] move=0 & viewAgent=0 -> (viewAgent'=3) & (move'=1) ;
[Agent_move_north] move=0 & viewAgent=3 & !AgentIsOnSlippery & !AgentCannotMoveNorth -> (xAgent'=xAgent-1) & (move'=1) ;
[Agent_move_east] move=0 & viewAgent=0 & !AgentIsOnSlippery & !AgentCannotMoveEast -> (yAgent'=yAgent+1) & (move'=1) ;
[Agent_move_south] move=0 & viewAgent=1 & !AgentIsOnSlippery & !AgentCannotMoveSouth -> (xAgent'=xAgent+1) & (move'=1) ;
[Agent_move_west] move=0 & viewAgent=2 & !AgentIsOnSlippery & !AgentCannotMoveWest -> (yAgent'=yAgent-1) & (move'=1) ;
endmodule
module Blue
xBlue : [1..12] init 7;
yBlue : [1..12] init 11;
[Blue_turns] move=1 & true -> (xBlue'=xBlue) & (move'=2) ;
[Blue_move_north] move=1 & !BlueIsOnSlippery & !BlueCannotMoveNorth -> (xBlue'=xBlue-1) & (move'=2) ;
[Blue_move_east] move=1 & !BlueIsOnSlippery & !BlueCannotMoveEast -> (yBlue'=yBlue+1) & (move'=2) ;
[Blue_move_south] move=1 & !BlueIsOnSlippery & !BlueCannotMoveSouth -> (xBlue'=xBlue+1) & (move'=2) ;
[Blue_move_west] move=1 & !BlueIsOnSlippery & !BlueCannotMoveWest -> (yBlue'=yBlue-1) & (move'=2) ;
endmodule
module Green
xGreen : [1..12] init 4;
yGreen : [1..12] init 1;
[Green_turns] move=2 & true -> (xGreen'=xGreen) & (move'=0) ;
[Green_move_north] move=2 & !GreenIsOnSlippery & !GreenCannotMoveNorth -> (xGreen'=xGreen-1) & (move'=0) ;
[Green_move_east] move=2 & !GreenIsOnSlippery & !GreenCannotMoveEast -> (yGreen'=yGreen+1) & (move'=0) ;
[Green_move_south] move=2 & !GreenIsOnSlippery & !GreenCannotMoveSouth -> (xGreen'=xGreen+1) & (move'=0) ;
[Green_move_west] move=2 & !GreenIsOnSlippery & !GreenCannotMoveWest -> (yGreen'=yGreen-1) & (move'=0) ;
endmodule

762212
Minigrid2PRISM/agentViewOnlyBlue.explicit
File diff suppressed because it is too large
View File

65
Minigrid2PRISM/agentViewOnlyBlue.prism

@ -0,0 +1,65 @@
smg
player Agent
[Agent_move_north], [Agent_move_east], [Agent_move_south], [Agent_move_west], [Agent_turn_left], [Agent_turn_right]
endplayer
player Blue
[Blue_move_north], [Blue_move_east], [Blue_move_south], [Blue_move_west], [Blue_turns]
endplayer
global move : [0..1] init 0;
label AgentOnBlue = (xAgent=1&yAgent=1) | (xAgent=1&yAgent=2) | (xAgent=1&yAgent=3) | (xAgent=1&yAgent=6) | (xAgent=1&yAgent=7) | (xAgent=1&yAgent=8) | (xAgent=1&yAgent=9) | (xAgent=1&yAgent=10) | (xAgent=1&yAgent=11) | (xAgent=2&yAgent=1) | (xAgent=2&yAgent=11) | (xAgent=3&yAgent=1) | (xAgent=3&yAgent=2) | (xAgent=3&yAgent=3) | (xAgent=3&yAgent=4) | (xAgent=3&yAgent=5) | (xAgent=3&yAgent=6) | (xAgent=3&yAgent=7) | (xAgent=3&yAgent=8) | (xAgent=3&yAgent=9) | (xAgent=3&yAgent=10) | (xAgent=3&yAgent=11);
label BlueOnBlue = (xBlue=1&yBlue=1) | (xBlue=1&yBlue=2) | (xBlue=1&yBlue=3) | (xBlue=1&yBlue=6) | (xBlue=1&yBlue=7) | (xBlue=1&yBlue=8) | (xBlue=1&yBlue=9) | (xBlue=1&yBlue=10) | (xBlue=1&yBlue=11) | (xBlue=2&yBlue=1) | (xBlue=2&yBlue=11) | (xBlue=3&yBlue=1) | (xBlue=3&yBlue=2) | (xBlue=3&yBlue=3) | (xBlue=3&yBlue=4) | (xBlue=3&yBlue=5) | (xBlue=3&yBlue=6) | (xBlue=3&yBlue=7) | (xBlue=3&yBlue=8) | (xBlue=3&yBlue=9) | (xBlue=3&yBlue=10) | (xBlue=3&yBlue=11);
label AgentOnGreen = (xAgent=9&yAgent=1) | (xAgent=9&yAgent=2) | (xAgent=9&yAgent=3) | (xAgent=9&yAgent=4) | (xAgent=9&yAgent=5) | (xAgent=9&yAgent=6) | (xAgent=9&yAgent=7) | (xAgent=9&yAgent=8) | (xAgent=9&yAgent=9) | (xAgent=9&yAgent=10) | (xAgent=9&yAgent=11) | (xAgent=10&yAgent=1) | (xAgent=10&yAgent=11) | (xAgent=11&yAgent=1) | (xAgent=11&yAgent=2) | (xAgent=11&yAgent=3) | (xAgent=11&yAgent=4) | (xAgent=11&yAgent=5) | (xAgent=11&yAgent=6) | (xAgent=11&yAgent=7) | (xAgent=11&yAgent=8) | (xAgent=11&yAgent=9) | (xAgent=11&yAgent=10) | (xAgent=11&yAgent=11);
label BlueOnGreen = (xBlue=9&yBlue=1) | (xBlue=9&yBlue=2) | (xBlue=9&yBlue=3) | (xBlue=9&yBlue=4) | (xBlue=9&yBlue=5) | (xBlue=9&yBlue=6) | (xBlue=9&yBlue=7) | (xBlue=9&yBlue=8) | (xBlue=9&yBlue=9) | (xBlue=9&yBlue=10) | (xBlue=9&yBlue=11) | (xBlue=10&yBlue=1) | (xBlue=10&yBlue=11) | (xBlue=11&yBlue=1) | (xBlue=11&yBlue=2) | (xBlue=11&yBlue=3) | (xBlue=11&yBlue=4) | (xBlue=11&yBlue=5) | (xBlue=11&yBlue=6) | (xBlue=11&yBlue=7) | (xBlue=11&yBlue=8) | (xBlue=11&yBlue=9) | (xBlue=11&yBlue=10) | (xBlue=11&yBlue=11);
label AgentOnRed = (xAgent=1&yAgent=4) | (xAgent=1&yAgent=5);
label BlueOnRed = (xBlue=1&yBlue=4) | (xBlue=1&yBlue=5);
formula AgentCannotMoveNorth = (xAgent=1&yAgent=2) | (xAgent=1&yAgent=3) | (xAgent=1&yAgent=4) | (xAgent=1&yAgent=5) | (xAgent=1&yAgent=6) | (xAgent=1&yAgent=7) | (xAgent=1&yAgent=8) | (xAgent=1&yAgent=9) | (xAgent=1&yAgent=10) | (xAgent=1&yAgent=11) | (xAgent=3&yAgent=2) | (xAgent=3&yAgent=3) | (xAgent=3&yAgent=4) | (xAgent=3&yAgent=5) | (xAgent=3&yAgent=6) | (xAgent=3&yAgent=7) | (xAgent=3&yAgent=8) | (xAgent=3&yAgent=9) | (xAgent=3&yAgent=10) | (xAgent=11&yAgent=2) | (xAgent=11&yAgent=3) | (xAgent=11&yAgent=4) | (xAgent=11&yAgent=5) | (xAgent=11&yAgent=6) | (xAgent=11&yAgent=7) | (xAgent=11&yAgent=8) | (xAgent=11&yAgent=9) | (xAgent=11&yAgent=10) | (xAgent=1&yAgent=1);
formula AgentCannotMoveEast = (xAgent=1&yAgent=11) | (xAgent=2&yAgent=1) | (xAgent=2&yAgent=11) | (xAgent=3&yAgent=11) | (xAgent=4&yAgent=11) | (xAgent=5&yAgent=11) | (xAgent=6&yAgent=11) | (xAgent=8&yAgent=11) | (xAgent=9&yAgent=11) | (xAgent=10&yAgent=1) | (xAgent=10&yAgent=11) | (xAgent=11&yAgent=11) | (xAgent=7&yAgent=11);
formula AgentCannotMoveSouth = (xAgent=1&yAgent=2) | (xAgent=1&yAgent=3) | (xAgent=1&yAgent=4) | (xAgent=1&yAgent=5) | (xAgent=1&yAgent=6) | (xAgent=1&yAgent=7) | (xAgent=1&yAgent=8) | (xAgent=1&yAgent=9) | (xAgent=1&yAgent=10) | (xAgent=9&yAgent=2) | (xAgent=9&yAgent=3) | (xAgent=9&yAgent=4) | (xAgent=9&yAgent=5) | (xAgent=9&yAgent=6) | (xAgent=9&yAgent=7) | (xAgent=9&yAgent=8) | (xAgent=9&yAgent=9) | (xAgent=9&yAgent=10) | (xAgent=11&yAgent=1) | (xAgent=11&yAgent=2) | (xAgent=11&yAgent=3) | (xAgent=11&yAgent=4) | (xAgent=11&yAgent=5) | (xAgent=11&yAgent=6) | (xAgent=11&yAgent=7) | (xAgent=11&yAgent=8) | (xAgent=11&yAgent=9) | (xAgent=11&yAgent=10) | (xAgent=11&yAgent=11);
formula AgentCannotMoveWest = (xAgent=2&yAgent=1) | (xAgent=2&yAgent=11) | (xAgent=3&yAgent=1) | (xAgent=5&yAgent=1) | (xAgent=6&yAgent=1) | (xAgent=7&yAgent=1) | (xAgent=8&yAgent=1) | (xAgent=9&yAgent=1) | (xAgent=10&yAgent=1) | (xAgent=10&yAgent=11) | (xAgent=11&yAgent=1) | (xAgent=1&yAgent=1) | (xAgent=4&yAgent=1);
formula AgentIsOnSlippery = false;
label AgentGoal = false;
formula BlueCannotMoveNorth = (xBlue=1&yBlue=2) | (xBlue=1&yBlue=3) | (xBlue=1&yBlue=4) | (xBlue=1&yBlue=5) | (xBlue=1&yBlue=6) | (xBlue=1&yBlue=7) | (xBlue=1&yBlue=8) | (xBlue=1&yBlue=9) | (xBlue=1&yBlue=10) | (xBlue=1&yBlue=11) | (xBlue=3&yBlue=2) | (xBlue=3&yBlue=3) | (xBlue=3&yBlue=4) | (xBlue=3&yBlue=5) | (xBlue=3&yBlue=6) | (xBlue=3&yBlue=7) | (xBlue=3&yBlue=8) | (xBlue=3&yBlue=9) | (xBlue=3&yBlue=10) | (xBlue=11&yBlue=2) | (xBlue=11&yBlue=3) | (xBlue=11&yBlue=4) | (xBlue=11&yBlue=5) | (xBlue=11&yBlue=6) | (xBlue=11&yBlue=7) | (xBlue=11&yBlue=8) | (xBlue=11&yBlue=9) | (xBlue=11&yBlue=10) | (xBlue=1&yBlue=1);
formula BlueCannotMoveEast = (xBlue=1&yBlue=11) | (xBlue=2&yBlue=1) | (xBlue=2&yBlue=11) | (xBlue=3&yBlue=11) | (xBlue=4&yBlue=11) | (xBlue=5&yBlue=11) | (xBlue=6&yBlue=11) | (xBlue=8&yBlue=11) | (xBlue=9&yBlue=11) | (xBlue=10&yBlue=1) | (xBlue=10&yBlue=11) | (xBlue=11&yBlue=11) | (xBlue=7&yBlue=11);
formula BlueCannotMoveSouth = (xBlue=1&yBlue=2) | (xBlue=1&yBlue=3) | (xBlue=1&yBlue=4) | (xBlue=1&yBlue=5) | (xBlue=1&yBlue=6) | (xBlue=1&yBlue=7) | (xBlue=1&yBlue=8) | (xBlue=1&yBlue=9) | (xBlue=1&yBlue=10) | (xBlue=9&yBlue=2) | (xBlue=9&yBlue=3) | (xBlue=9&yBlue=4) | (xBlue=9&yBlue=5) | (xBlue=9&yBlue=6) | (xBlue=9&yBlue=7) | (xBlue=9&yBlue=8) | (xBlue=9&yBlue=9) | (xBlue=9&yBlue=10) | (xBlue=11&yBlue=1) | (xBlue=11&yBlue=2) | (xBlue=11&yBlue=3) | (xBlue=11&yBlue=4) | (xBlue=11&yBlue=5) | (xBlue=11&yBlue=6) | (xBlue=11&yBlue=7) | (xBlue=11&yBlue=8) | (xBlue=11&yBlue=9) | (xBlue=11&yBlue=10) | (xBlue=11&yBlue=11);
formula BlueCannotMoveWest = (xBlue=2&yBlue=1) | (xBlue=2&yBlue=11) | (xBlue=3&yBlue=1) | (xBlue=5&yBlue=1) | (xBlue=6&yBlue=1) | (xBlue=7&yBlue=1) | (xBlue=8&yBlue=1) | (xBlue=9&yBlue=1) | (xBlue=10&yBlue=1) | (xBlue=10&yBlue=11) | (xBlue=11&yBlue=1) | (xBlue=1&yBlue=1) | (xBlue=4&yBlue=1);
formula BlueIsOnSlippery = false;
label BlueGoal = false;
label crash = (xAgent=xBlue)&(yAgent=yBlue);
module Agent
xAgent : [1..12] init 1;
yAgent : [1..12] init 1;
viewAgent : [0..3] init 1;
[Agent_turn_right] move=0 & true -> (viewAgent'=mod(viewAgent + 1, 4)) & (move'=1) ;
[Agent_turn_left] move=0 & viewAgent>0 -> (viewAgent'=viewAgent - 1) & (move'=1) ;
[Agent_turn_left] move=0 & viewAgent=0 -> (viewAgent'=3) & (move'=1) ;
[Agent_move_north] move=0 & viewAgent=3 & !AgentIsOnSlippery & !AgentCannotMoveNorth -> (xAgent'=xAgent-1) & (move'=1) ;
[Agent_move_east] move=0 & viewAgent=0 & !AgentIsOnSlippery & !AgentCannotMoveEast -> (yAgent'=yAgent+1) & (move'=1) ;
[Agent_move_south] move=0 & viewAgent=1 & !AgentIsOnSlippery & !AgentCannotMoveSouth -> (xAgent'=xAgent+1) & (move'=1) ;
[Agent_move_west] move=0 & viewAgent=2 & !AgentIsOnSlippery & !AgentCannotMoveWest -> (yAgent'=yAgent-1) & (move'=1) ;
endmodule
module Blue
xBlue : [1..12] init 7;
yBlue : [1..12] init 11;
[Blue_turns] move=1 & true -> (xBlue'=xBlue) & (move'=0) ;
[Blue_move_north] move=1 & !BlueIsOnSlippery & !BlueCannotMoveNorth -> (xBlue'=xBlue-1) & (move'=0) ;
[Blue_move_east] move=1 & !BlueIsOnSlippery & !BlueCannotMoveEast -> (yBlue'=yBlue+1) & (move'=0) ;
[Blue_move_south] move=1 & !BlueIsOnSlippery & !BlueCannotMoveSouth -> (xBlue'=xBlue+1) & (move'=0) ;
[Blue_move_west] move=1 & !BlueIsOnSlippery & !BlueCannotMoveWest -> (yBlue'=yBlue-1) & (move'=0) ;
endmodule

100
Minigrid2PRISM/allView.prism

@ -0,0 +1,100 @@
smg
player Agent
[Agent_move_north], [Agent_move_east], [Agent_move_south], [Agent_move_west], [Agent_turn_left], [Agent_turn_right]
endplayer
player Blue
[Blue_move_north], [Blue_move_east], [Blue_move_south], [Blue_move_west], [Blue_turn_left], [Blue_turn_right]
endplayer
player Green
[Green_move_north], [Green_move_east], [Green_move_south], [Green_move_west], [Green_turn_left], [Green_turn_right]
endplayer
global move : [0..2] init 0;
label AgentOnBlue = (xAgent=1&yAgent=1) | (xAgent=1&yAgent=2) | (xAgent=1&yAgent=3) | (xAgent=1&yAgent=6) | (xAgent=1&yAgent=7) | (xAgent=1&yAgent=8) | (xAgent=1&yAgent=9) | (xAgent=1&yAgent=10) | (xAgent=1&yAgent=11) | (xAgent=2&yAgent=1) | (xAgent=2&yAgent=11) | (xAgent=3&yAgent=1) | (xAgent=3&yAgent=2) | (xAgent=3&yAgent=3) | (xAgent=3&yAgent=4) | (xAgent=3&yAgent=5) | (xAgent=3&yAgent=6) | (xAgent=3&yAgent=7) | (xAgent=3&yAgent=8) | (xAgent=3&yAgent=9) | (xAgent=3&yAgent=10) | (xAgent=3&yAgent=11);
label BlueOnBlue = (xBlue=1&yBlue=1) | (xBlue=1&yBlue=2) | (xBlue=1&yBlue=3) | (xBlue=1&yBlue=6) | (xBlue=1&yBlue=7) | (xBlue=1&yBlue=8) | (xBlue=1&yBlue=9) | (xBlue=1&yBlue=10) | (xBlue=1&yBlue=11) | (xBlue=2&yBlue=1) | (xBlue=2&yBlue=11) | (xBlue=3&yBlue=1) | (xBlue=3&yBlue=2) | (xBlue=3&yBlue=3) | (xBlue=3&yBlue=4) | (xBlue=3&yBlue=5) | (xBlue=3&yBlue=6) | (xBlue=3&yBlue=7) | (xBlue=3&yBlue=8) | (xBlue=3&yBlue=9) | (xBlue=3&yBlue=10) | (xBlue=3&yBlue=11);
label GreenOnBlue = (xGreen=1&yGreen=1) | (xGreen=1&yGreen=2) | (xGreen=1&yGreen=3) | (xGreen=1&yGreen=6) | (xGreen=1&yGreen=7) | (xGreen=1&yGreen=8) | (xGreen=1&yGreen=9) | (xGreen=1&yGreen=10) | (xGreen=1&yGreen=11) | (xGreen=2&yGreen=1) | (xGreen=2&yGreen=11) | (xGreen=3&yGreen=1) | (xGreen=3&yGreen=2) | (xGreen=3&yGreen=3) | (xGreen=3&yGreen=4) | (xGreen=3&yGreen=5) | (xGreen=3&yGreen=6) | (xGreen=3&yGreen=7) | (xGreen=3&yGreen=8) | (xGreen=3&yGreen=9) | (xGreen=3&yGreen=10) | (xGreen=3&yGreen=11);
label AgentOnGreen = (xAgent=9&yAgent=1) | (xAgent=9&yAgent=2) | (xAgent=9&yAgent=3) | (xAgent=9&yAgent=4) | (xAgent=9&yAgent=5) | (xAgent=9&yAgent=6) | (xAgent=9&yAgent=7) | (xAgent=9&yAgent=8) | (xAgent=9&yAgent=9) | (xAgent=9&yAgent=10) | (xAgent=9&yAgent=11) | (xAgent=10&yAgent=1) | (xAgent=10&yAgent=11) | (xAgent=11&yAgent=1) | (xAgent=11&yAgent=2) | (xAgent=11&yAgent=3) | (xAgent=11&yAgent=4) | (xAgent=11&yAgent=5) | (xAgent=11&yAgent=6) | (xAgent=11&yAgent=7) | (xAgent=11&yAgent=8) | (xAgent=11&yAgent=9) | (xAgent=11&yAgent=10) | (xAgent=11&yAgent=11);
label BlueOnGreen = (xBlue=9&yBlue=1) | (xBlue=9&yBlue=2) | (xBlue=9&yBlue=3) | (xBlue=9&yBlue=4) | (xBlue=9&yBlue=5) | (xBlue=9&yBlue=6) | (xBlue=9&yBlue=7) | (xBlue=9&yBlue=8) | (xBlue=9&yBlue=9) | (xBlue=9&yBlue=10) | (xBlue=9&yBlue=11) | (xBlue=10&yBlue=1) | (xBlue=10&yBlue=11) | (xBlue=11&yBlue=1) | (xBlue=11&yBlue=2) | (xBlue=11&yBlue=3) | (xBlue=11&yBlue=4) | (xBlue=11&yBlue=5) | (xBlue=11&yBlue=6) | (xBlue=11&yBlue=7) | (xBlue=11&yBlue=8) | (xBlue=11&yBlue=9) | (xBlue=11&yBlue=10) | (xBlue=11&yBlue=11);
label GreenOnGreen = (xGreen=9&yGreen=1) | (xGreen=9&yGreen=2) | (xGreen=9&yGreen=3) | (xGreen=9&yGreen=4) | (xGreen=9&yGreen=5) | (xGreen=9&yGreen=6) | (xGreen=9&yGreen=7) | (xGreen=9&yGreen=8) | (xGreen=9&yGreen=9) | (xGreen=9&yGreen=10) | (xGreen=9&yGreen=11) | (xGreen=10&yGreen=1) | (xGreen=10&yGreen=11) | (xGreen=11&yGreen=1) | (xGreen=11&yGreen=2) | (xGreen=11&yGreen=3) | (xGreen=11&yGreen=4) | (xGreen=11&yGreen=5) | (xGreen=11&yGreen=6) | (xGreen=11&yGreen=7) | (xGreen=11&yGreen=8) | (xGreen=11&yGreen=9) | (xGreen=11&yGreen=10) | (xGreen=11&yGreen=11);
label AgentOnRed = (xAgent=1&yAgent=4) | (xAgent=1&yAgent=5);
label BlueOnRed = (xBlue=1&yBlue=4) | (xBlue=1&yBlue=5);
label GreenOnRed = (xGreen=1&yGreen=4) | (xGreen=1&yGreen=5);
formula AgentCannotMoveNorth = (xAgent=1&yAgent=2) | (xAgent=1&yAgent=3) | (xAgent=1&yAgent=4) | (xAgent=1&yAgent=5) | (xAgent=1&yAgent=6) | (xAgent=1&yAgent=7) | (xAgent=1&yAgent=8) | (xAgent=1&yAgent=9) | (xAgent=1&yAgent=10) | (xAgent=1&yAgent=11) | (xAgent=3&yAgent=2) | (xAgent=3&yAgent=3) | (xAgent=3&yAgent=4) | (xAgent=3&yAgent=5) | (xAgent=3&yAgent=6) | (xAgent=3&yAgent=7) | (xAgent=3&yAgent=8) | (xAgent=3&yAgent=9) | (xAgent=3&yAgent=10) | (xAgent=11&yAgent=2) | (xAgent=11&yAgent=3) | (xAgent=11&yAgent=4) | (xAgent=11&yAgent=5) | (xAgent=11&yAgent=6) | (xAgent=11&yAgent=7) | (xAgent=11&yAgent=8) | (xAgent=11&yAgent=9) | (xAgent=11&yAgent=10) | (xAgent=1&yAgent=1);
formula AgentCannotMoveEast = (xAgent=1&yAgent=11) | (xAgent=2&yAgent=1) | (xAgent=2&yAgent=11) | (xAgent=3&yAgent=11) | (xAgent=4&yAgent=11) | (xAgent=5&yAgent=11) | (xAgent=6&yAgent=11) | (xAgent=8&yAgent=11) | (xAgent=9&yAgent=11) | (xAgent=10&yAgent=1) | (xAgent=10&yAgent=11) | (xAgent=11&yAgent=11) | (xAgent=7&yAgent=11);
formula AgentCannotMoveSouth = (xAgent=1&yAgent=2) | (xAgent=1&yAgent=3) | (xAgent=1&yAgent=4) | (xAgent=1&yAgent=5) | (xAgent=1&yAgent=6) | (xAgent=1&yAgent=7) | (xAgent=1&yAgent=8) | (xAgent=1&yAgent=9) | (xAgent=1&yAgent=10) | (xAgent=9&yAgent=2) | (xAgent=9&yAgent=3) | (xAgent=9&yAgent=4) | (xAgent=9&yAgent=5) | (xAgent=9&yAgent=6) | (xAgent=9&yAgent=7) | (xAgent=9&yAgent=8) | (xAgent=9&yAgent=9) | (xAgent=9&yAgent=10) | (xAgent=11&yAgent=1) | (xAgent=11&yAgent=2) | (xAgent=11&yAgent=3) | (xAgent=11&yAgent=4) | (xAgent=11&yAgent=5) | (xAgent=11&yAgent=6) | (xAgent=11&yAgent=7) | (xAgent=11&yAgent=8) | (xAgent=11&yAgent=9) | (xAgent=11&yAgent=10) | (xAgent=11&yAgent=11);
formula AgentCannotMoveWest = (xAgent=2&yAgent=1) | (xAgent=2&yAgent=11) | (xAgent=3&yAgent=1) | (xAgent=5&yAgent=1) | (xAgent=6&yAgent=1) | (xAgent=7&yAgent=1) | (xAgent=8&yAgent=1) | (xAgent=9&yAgent=1) | (xAgent=10&yAgent=1) | (xAgent=10&yAgent=11) | (xAgent=11&yAgent=1) | (xAgent=1&yAgent=1) | (xAgent=4&yAgent=1);
formula AgentIsOnSlippery = false;
label AgentGoal = false;
formula BlueCannotMoveNorth = (xBlue=1&yBlue=2) | (xBlue=1&yBlue=3) | (xBlue=1&yBlue=4) | (xBlue=1&yBlue=5) | (xBlue=1&yBlue=6) | (xBlue=1&yBlue=7) | (xBlue=1&yBlue=8) | (xBlue=1&yBlue=9) | (xBlue=1&yBlue=10) | (xBlue=1&yBlue=11) | (xBlue=3&yBlue=2) | (xBlue=3&yBlue=3) | (xBlue=3&yBlue=4) | (xBlue=3&yBlue=5) | (xBlue=3&yBlue=6) | (xBlue=3&yBlue=7) | (xBlue=3&yBlue=8) | (xBlue=3&yBlue=9) | (xBlue=3&yBlue=10) | (xBlue=11&yBlue=2) | (xBlue=11&yBlue=3) | (xBlue=11&yBlue=4) | (xBlue=11&yBlue=5) | (xBlue=11&yBlue=6) | (xBlue=11&yBlue=7) | (xBlue=11&yBlue=8) | (xBlue=11&yBlue=9) | (xBlue=11&yBlue=10) | (xBlue=1&yBlue=1);
formula BlueCannotMoveEast = (xBlue=1&yBlue=11) | (xBlue=2&yBlue=1) | (xBlue=2&yBlue=11) | (xBlue=3&yBlue=11) | (xBlue=4&yBlue=11) | (xBlue=5&yBlue=11) | (xBlue=6&yBlue=11) | (xBlue=8&yBlue=11) | (xBlue=9&yBlue=11) | (xBlue=10&yBlue=1) | (xBlue=10&yBlue=11) | (xBlue=11&yBlue=11) | (xBlue=7&yBlue=11);
formula BlueCannotMoveSouth = (xBlue=1&yBlue=2) | (xBlue=1&yBlue=3) | (xBlue=1&yBlue=4) | (xBlue=1&yBlue=5) | (xBlue=1&yBlue=6) | (xBlue=1&yBlue=7) | (xBlue=1&yBlue=8) | (xBlue=1&yBlue=9) | (xBlue=1&yBlue=10) | (xBlue=9&yBlue=2) | (xBlue=9&yBlue=3) | (xBlue=9&yBlue=4) | (xBlue=9&yBlue=5) | (xBlue=9&yBlue=6) | (xBlue=9&yBlue=7) | (xBlue=9&yBlue=8) | (xBlue=9&yBlue=9) | (xBlue=9&yBlue=10) | (xBlue=11&yBlue=1) | (xBlue=11&yBlue=2) | (xBlue=11&yBlue=3) | (xBlue=11&yBlue=4) | (xBlue=11&yBlue=5) | (xBlue=11&yBlue=6) | (xBlue=11&yBlue=7) | (xBlue=11&yBlue=8) | (xBlue=11&yBlue=9) | (xBlue=11&yBlue=10) | (xBlue=11&yBlue=11);
formula BlueCannotMoveWest = (xBlue=2&yBlue=1) | (xBlue=2&yBlue=11) | (xBlue=3&yBlue=1) | (xBlue=5&yBlue=1) | (xBlue=6&yBlue=1) | (xBlue=7&yBlue=1) | (xBlue=8&yBlue=1) | (xBlue=9&yBlue=1) | (xBlue=10&yBlue=1) | (xBlue=10&yBlue=11) | (xBlue=11&yBlue=1) | (xBlue=1&yBlue=1) | (xBlue=4&yBlue=1);
formula BlueIsOnSlippery = false;
label BlueGoal = false;
formula GreenCannotMoveNorth = (xGreen=1&yGreen=2) | (xGreen=1&yGreen=3) | (xGreen=1&yGreen=4) | (xGreen=1&yGreen=5) | (xGreen=1&yGreen=6) | (xGreen=1&yGreen=7) | (xGreen=1&yGreen=8) | (xGreen=1&yGreen=9) | (xGreen=1&yGreen=10) | (xGreen=1&yGreen=11) | (xGreen=3&yGreen=2) | (xGreen=3&yGreen=3) | (xGreen=3&yGreen=4) | (xGreen=3&yGreen=5) | (xGreen=3&yGreen=6) | (xGreen=3&yGreen=7) | (xGreen=3&yGreen=8) | (xGreen=3&yGreen=9) | (xGreen=3&yGreen=10) | (xGreen=11&yGreen=2) | (xGreen=11&yGreen=3) | (xGreen=11&yGreen=4) | (xGreen=11&yGreen=5) | (xGreen=11&yGreen=6) | (xGreen=11&yGreen=7) | (xGreen=11&yGreen=8) | (xGreen=11&yGreen=9) | (xGreen=11&yGreen=10) | (xGreen=1&yGreen=1);
formula GreenCannotMoveEast = (xGreen=1&yGreen=11) | (xGreen=2&yGreen=1) | (xGreen=2&yGreen=11) | (xGreen=3&yGreen=11) | (xGreen=4&yGreen=11) | (xGreen=5&yGreen=11) | (xGreen=6&yGreen=11) | (xGreen=8&yGreen=11) | (xGreen=9&yGreen=11) | (xGreen=10&yGreen=1) | (xGreen=10&yGreen=11) | (xGreen=11&yGreen=11) | (xGreen=7&yGreen=11);
formula GreenCannotMoveSouth = (xGreen=1&yGreen=2) | (xGreen=1&yGreen=3) | (xGreen=1&yGreen=4) | (xGreen=1&yGreen=5) | (xGreen=1&yGreen=6) | (xGreen=1&yGreen=7) | (xGreen=1&yGreen=8) | (xGreen=1&yGreen=9) | (xGreen=1&yGreen=10) | (xGreen=9&yGreen=2) | (xGreen=9&yGreen=3) | (xGreen=9&yGreen=4) | (xGreen=9&yGreen=5) | (xGreen=9&yGreen=6) | (xGreen=9&yGreen=7) | (xGreen=9&yGreen=8) | (xGreen=9&yGreen=9) | (xGreen=9&yGreen=10) | (xGreen=11&yGreen=1) | (xGreen=11&yGreen=2) | (xGreen=11&yGreen=3) | (xGreen=11&yGreen=4) | (xGreen=11&yGreen=5) | (xGreen=11&yGreen=6) | (xGreen=11&yGreen=7) | (xGreen=11&yGreen=8) | (xGreen=11&yGreen=9) | (xGreen=11&yGreen=10) | (xGreen=11&yGreen=11);
formula GreenCannotMoveWest = (xGreen=2&yGreen=1) | (xGreen=2&yGreen=11) | (xGreen=3&yGreen=1) | (xGreen=5&yGreen=1) | (xGreen=6&yGreen=1) | (xGreen=7&yGreen=1) | (xGreen=8&yGreen=1) | (xGreen=9&yGreen=1) | (xGreen=10&yGreen=1) | (xGreen=10&yGreen=11) | (xGreen=11&yGreen=1) | (xGreen=1&yGreen=1) | (xGreen=4&yGreen=1);
formula GreenIsOnSlippery = false;
label GreenGoal = false;
label crash = (xAgent=xBlue)&(yAgent=yBlue) | (xAgent=xGreen)&(yAgent=yGreen);
module Agent
xAgent : [1..12] init 1;
yAgent : [1..12] init 1;
viewAgent : [0..3] init 1;
[Agent_turn_right] move=0 & true -> (viewAgent'=mod(viewAgent + 1, 4)) & (move'=1) ;
[Agent_turn_left] move=0 & viewAgent>0 -> (viewAgent'=viewAgent - 1) & (move'=1) ;
[Agent_turn_left] move=0 & viewAgent=0 -> (viewAgent'=3) & (move'=1) ;
[Agent_move_north] move=0 & viewAgent=3 & !AgentIsOnSlippery & !AgentCannotMoveNorth -> (xAgent'=xAgent-1) & (move'=1) ;
[Agent_move_east] move=0 & viewAgent=0 & !AgentIsOnSlippery & !AgentCannotMoveEast -> (yAgent'=yAgent+1) & (move'=1) ;
[Agent_move_south] move=0 & viewAgent=1 & !AgentIsOnSlippery & !AgentCannotMoveSouth -> (xAgent'=xAgent+1) & (move'=1) ;
[Agent_move_west] move=0 & viewAgent=2 & !AgentIsOnSlippery & !AgentCannotMoveWest -> (yAgent'=yAgent-1) & (move'=1) ;
endmodule
module Blue
xBlue : [1..12] init 7;
yBlue : [1..12] init 11;
viewBlue : [0..3] init 1;
[Blue_turn_right] move=1 & true -> (viewBlue'=mod(viewBlue + 1, 4)) & (move'=2) ;
[Blue_turn_left] move=1 & viewBlue>0 -> (viewBlue'=viewBlue - 1) & (move'=2) ;
[Blue_turn_left] move=1 & viewBlue=0 -> (viewBlue'=3) & (move'=2) ;
[Blue_move_north] move=1 & viewBlue=3 & !BlueIsOnSlippery & !BlueCannotMoveNorth -> (xBlue'=xBlue-1) & (move'=2) ;
[Blue_move_east] move=1 & viewBlue=0 & !BlueIsOnSlippery & !BlueCannotMoveEast -> (yBlue'=yBlue+1) & (move'=2) ;
[Blue_move_south] move=1 & viewBlue=1 & !BlueIsOnSlippery & !BlueCannotMoveSouth -> (xBlue'=xBlue+1) & (move'=2) ;
[Blue_move_west] move=1 & viewBlue=2 & !BlueIsOnSlippery & !BlueCannotMoveWest -> (yBlue'=yBlue-1) & (move'=2) ;
endmodule
module Green
xGreen : [1..12] init 4;
yGreen : [1..12] init 1;
viewGreen : [0..3] init 1;
[Green_turn_right] move=2 & true -> (viewGreen'=mod(viewGreen + 1, 4)) & (move'=0) ;
[Green_turn_left] move=2 & viewGreen>0 -> (viewGreen'=viewGreen - 1) & (move'=0) ;
[Green_turn_left] move=2 & viewGreen=0 -> (viewGreen'=3) & (move'=0) ;
[Green_move_north] move=2 & viewGreen=3 & !GreenIsOnSlippery & !GreenCannotMoveNorth -> (xGreen'=xGreen-1) & (move'=0) ;
[Green_move_east] move=2 & viewGreen=0 & !GreenIsOnSlippery & !GreenCannotMoveEast -> (yGreen'=yGreen+1) & (move'=0) ;
[Green_move_south] move=2 & viewGreen=1 & !GreenIsOnSlippery & !GreenCannotMoveSouth -> (xGreen'=xGreen+1) & (move'=0) ;
[Green_move_west] move=2 & viewGreen=2 & !GreenIsOnSlippery & !GreenCannotMoveWest -> (yGreen'=yGreen-1) & (move'=0) ;
endmodule

100
Minigrid2PRISM/both.prism

@ -0,0 +1,100 @@
smg
player Agent
[Agent_move_north], [Agent_move_east], [Agent_move_south], [Agent_move_west], [Agent_turn_left], [Agent_turn_right]
endplayer
player Blue
[Blue_move_north], [Blue_move_east], [Blue_move_south], [Blue_move_west], [Blue_move_north_10], [Blue_move_east_10], [Blue_move_south_10], [Blue_move_west_10], [Blue_turns]
endplayer
player Green
[Green_move_north], [Green_move_east], [Green_move_south], [Green_move_west], [Green_move_north_10], [Green_move_east_10], [Green_move_south_10], [Green_move_west_10], [Green_turns]
endplayer
global move : [0..2] init 0;
label AgentOnBlue = (xAgent=1&yAgent=1) | (xAgent=1&yAgent=2) | (xAgent=1&yAgent=3) | (xAgent=1&yAgent=6) | (xAgent=1&yAgent=7) | (xAgent=1&yAgent=8) | (xAgent=1&yAgent=9) | (xAgent=1&yAgent=10) | (xAgent=1&yAgent=11) | (xAgent=2&yAgent=1) | (xAgent=2&yAgent=11) | (xAgent=3&yAgent=1) | (xAgent=3&yAgent=2) | (xAgent=3&yAgent=3) | (xAgent=3&yAgent=4) | (xAgent=3&yAgent=5) | (xAgent=3&yAgent=6) | (xAgent=3&yAgent=7) | (xAgent=3&yAgent=8) | (xAgent=3&yAgent=9) | (xAgent=3&yAgent=10) | (xAgent=3&yAgent=11);
label BlueOnBlue = (xBlue=1&yBlue=1) | (xBlue=1&yBlue=2) | (xBlue=1&yBlue=3) | (xBlue=1&yBlue=6) | (xBlue=1&yBlue=7) | (xBlue=1&yBlue=8) | (xBlue=1&yBlue=9) | (xBlue=1&yBlue=10) | (xBlue=1&yBlue=11) | (xBlue=2&yBlue=1) | (xBlue=2&yBlue=11) | (xBlue=3&yBlue=1) | (xBlue=3&yBlue=2) | (xBlue=3&yBlue=3) | (xBlue=3&yBlue=4) | (xBlue=3&yBlue=5) | (xBlue=3&yBlue=6) | (xBlue=3&yBlue=7) | (xBlue=3&yBlue=8) | (xBlue=3&yBlue=9) | (xBlue=3&yBlue=10) | (xBlue=3&yBlue=11);
label GreenOnBlue = (xGreen=1&yGreen=1) | (xGreen=1&yGreen=2) | (xGreen=1&yGreen=3) | (xGreen=1&yGreen=6) | (xGreen=1&yGreen=7) | (xGreen=1&yGreen=8) | (xGreen=1&yGreen=9) | (xGreen=1&yGreen=10) | (xGreen=1&yGreen=11) | (xGreen=2&yGreen=1) | (xGreen=2&yGreen=11) | (xGreen=3&yGreen=1) | (xGreen=3&yGreen=2) | (xGreen=3&yGreen=3) | (xGreen=3&yGreen=4) | (xGreen=3&yGreen=5) | (xGreen=3&yGreen=6) | (xGreen=3&yGreen=7) | (xGreen=3&yGreen=8) | (xGreen=3&yGreen=9) | (xGreen=3&yGreen=10) | (xGreen=3&yGreen=11);
label AgentOnGreen = (xAgent=9&yAgent=1) | (xAgent=9&yAgent=2) | (xAgent=9&yAgent=3) | (xAgent=9&yAgent=4) | (xAgent=9&yAgent=5) | (xAgent=9&yAgent=6) | (xAgent=9&yAgent=7) | (xAgent=9&yAgent=8) | (xAgent=9&yAgent=9) | (xAgent=9&yAgent=10) | (xAgent=9&yAgent=11) | (xAgent=10&yAgent=1) | (xAgent=10&yAgent=11) | (xAgent=11&yAgent=1) | (xAgent=11&yAgent=2) | (xAgent=11&yAgent=3) | (xAgent=11&yAgent=4) | (xAgent=11&yAgent=5) | (xAgent=11&yAgent=6) | (xAgent=11&yAgent=7) | (xAgent=11&yAgent=8) | (xAgent=11&yAgent=9) | (xAgent=11&yAgent=10) | (xAgent=11&yAgent=11);
label BlueOnGreen = (xBlue=9&yBlue=1) | (xBlue=9&yBlue=2) | (xBlue=9&yBlue=3) | (xBlue=9&yBlue=4) | (xBlue=9&yBlue=5) | (xBlue=9&yBlue=6) | (xBlue=9&yBlue=7) | (xBlue=9&yBlue=8) | (xBlue=9&yBlue=9) | (xBlue=9&yBlue=10) | (xBlue=9&yBlue=11) | (xBlue=10&yBlue=1) | (xBlue=10&yBlue=11) | (xBlue=11&yBlue=1) | (xBlue=11&yBlue=2) | (xBlue=11&yBlue=3) | (xBlue=11&yBlue=4) | (xBlue=11&yBlue=5) | (xBlue=11&yBlue=6) | (xBlue=11&yBlue=7) | (xBlue=11&yBlue=8) | (xBlue=11&yBlue=9) | (xBlue=11&yBlue=10) | (xBlue=11&yBlue=11);
label GreenOnGreen = (xGreen=9&yGreen=1) | (xGreen=9&yGreen=2) | (xGreen=9&yGreen=3) | (xGreen=9&yGreen=4) | (xGreen=9&yGreen=5) | (xGreen=9&yGreen=6) | (xGreen=9&yGreen=7) | (xGreen=9&yGreen=8) | (xGreen=9&yGreen=9) | (xGreen=9&yGreen=10) | (xGreen=9&yGreen=11) | (xGreen=10&yGreen=1) | (xGreen=10&yGreen=11) | (xGreen=11&yGreen=1) | (xGreen=11&yGreen=2) | (xGreen=11&yGreen=3) | (xGreen=11&yGreen=4) | (xGreen=11&yGreen=5) | (xGreen=11&yGreen=6) | (xGreen=11&yGreen=7) | (xGreen=11&yGreen=8) | (xGreen=11&yGreen=9) | (xGreen=11&yGreen=10) | (xGreen=11&yGreen=11);
label AgentOnRed = (xAgent=1&yAgent=4) | (xAgent=1&yAgent=5);
label BlueOnRed = (xBlue=1&yBlue=4) | (xBlue=1&yBlue=5);
label GreenOnRed = (xGreen=1&yGreen=4) | (xGreen=1&yGreen=5);
formula AgentCannotMoveNorth = (xAgent=1&yAgent=2) | (xAgent=1&yAgent=3) | (xAgent=1&yAgent=4) | (xAgent=1&yAgent=5) | (xAgent=1&yAgent=6) | (xAgent=1&yAgent=7) | (xAgent=1&yAgent=8) | (xAgent=1&yAgent=9) | (xAgent=1&yAgent=10) | (xAgent=1&yAgent=11) | (xAgent=3&yAgent=2) | (xAgent=3&yAgent=3) | (xAgent=3&yAgent=4) | (xAgent=3&yAgent=5) | (xAgent=3&yAgent=6) | (xAgent=3&yAgent=7) | (xAgent=3&yAgent=8) | (xAgent=3&yAgent=9) | (xAgent=3&yAgent=10) | (xAgent=11&yAgent=2) | (xAgent=11&yAgent=3) | (xAgent=11&yAgent=4) | (xAgent=11&yAgent=5) | (xAgent=11&yAgent=6) | (xAgent=11&yAgent=7) | (xAgent=11&yAgent=8) | (xAgent=11&yAgent=9) | (xAgent=11&yAgent=10) | (xAgent=1&yAgent=1);
formula AgentCannotMoveEast = (xAgent=1&yAgent=11) | (xAgent=2&yAgent=1) | (xAgent=2&yAgent=11) | (xAgent=3&yAgent=11) | (xAgent=4&yAgent=11) | (xAgent=5&yAgent=11) | (xAgent=6&yAgent=11) | (xAgent=8&yAgent=11) | (xAgent=9&yAgent=11) | (xAgent=10&yAgent=1) | (xAgent=10&yAgent=11) | (xAgent=11&yAgent=11) | (xAgent=7&yAgent=11);
formula AgentCannotMoveSouth = (xAgent=1&yAgent=2) | (xAgent=1&yAgent=3) | (xAgent=1&yAgent=4) | (xAgent=1&yAgent=5) | (xAgent=1&yAgent=6) | (xAgent=1&yAgent=7) | (xAgent=1&yAgent=8) | (xAgent=1&yAgent=9) | (xAgent=1&yAgent=10) | (xAgent=9&yAgent=2) | (xAgent=9&yAgent=3) | (xAgent=9&yAgent=4) | (xAgent=9&yAgent=5) | (xAgent=9&yAgent=6) | (xAgent=9&yAgent=7) | (xAgent=9&yAgent=8) | (xAgent=9&yAgent=9) | (xAgent=9&yAgent=10) | (xAgent=11&yAgent=1) | (xAgent=11&yAgent=2) | (xAgent=11&yAgent=3) | (xAgent=11&yAgent=4) | (xAgent=11&yAgent=5) | (xAgent=11&yAgent=6) | (xAgent=11&yAgent=7) | (xAgent=11&yAgent=8) | (xAgent=11&yAgent=9) | (xAgent=11&yAgent=10) | (xAgent=11&yAgent=11);
formula AgentCannotMoveWest = (xAgent=2&yAgent=1) | (xAgent=2&yAgent=11) | (xAgent=3&yAgent=1) | (xAgent=5&yAgent=1) | (xAgent=6&yAgent=1) | (xAgent=7&yAgent=1) | (xAgent=8&yAgent=1) | (xAgent=9&yAgent=1) | (xAgent=10&yAgent=1) | (xAgent=10&yAgent=11) | (xAgent=11&yAgent=1) | (xAgent=1&yAgent=1) | (xAgent=4&yAgent=1);
formula AgentIsOnSlippery = false;
label AgentGoal = false;
formula BlueCannotMoveNorth = (xBlue=1&yBlue=2) | (xBlue=1&yBlue=3) | (xBlue=1&yBlue=4) | (xBlue=1&yBlue=5) | (xBlue=1&yBlue=6) | (xBlue=1&yBlue=7) | (xBlue=1&yBlue=8) | (xBlue=1&yBlue=9) | (xBlue=1&yBlue=10) | (xBlue=1&yBlue=11) | (xBlue=3&yBlue=2) | (xBlue=3&yBlue=3) | (xBlue=3&yBlue=4) | (xBlue=3&yBlue=5) | (xBlue=3&yBlue=6) | (xBlue=3&yBlue=7) | (xBlue=3&yBlue=8) | (xBlue=3&yBlue=9) | (xBlue=3&yBlue=10) | (xBlue=11&yBlue=2) | (xBlue=11&yBlue=3) | (xBlue=11&yBlue=4) | (xBlue=11&yBlue=5) | (xBlue=11&yBlue=6) | (xBlue=11&yBlue=7) | (xBlue=11&yBlue=8) | (xBlue=11&yBlue=9) | (xBlue=11&yBlue=10) | (xBlue=1&yBlue=1);
formula BlueCannotMoveEast = (xBlue=1&yBlue=11) | (xBlue=2&yBlue=1) | (xBlue=2&yBlue=11) | (xBlue=3&yBlue=11) | (xBlue=4&yBlue=11) | (xBlue=5&yBlue=11) | (xBlue=6&yBlue=11) | (xBlue=8&yBlue=11) | (xBlue=9&yBlue=11) | (xBlue=10&yBlue=1) | (xBlue=10&yBlue=11) | (xBlue=11&yBlue=11) | (xBlue=7&yBlue=11);
formula BlueCannotMoveSouth = (xBlue=1&yBlue=2) | (xBlue=1&yBlue=3) | (xBlue=1&yBlue=4) | (xBlue=1&yBlue=5) | (xBlue=1&yBlue=6) | (xBlue=1&yBlue=7) | (xBlue=1&yBlue=8) | (xBlue=1&yBlue=9) | (xBlue=1&yBlue=10) | (xBlue=9&yBlue=2) | (xBlue=9&yBlue=3) | (xBlue=9&yBlue=4) | (xBlue=9&yBlue=5) | (xBlue=9&yBlue=6) | (xBlue=9&yBlue=7) | (xBlue=9&yBlue=8) | (xBlue=9&yBlue=9) | (xBlue=9&yBlue=10) | (xBlue=11&yBlue=1) | (xBlue=11&yBlue=2) | (xBlue=11&yBlue=3) | (xBlue=11&yBlue=4) | (xBlue=11&yBlue=5) | (xBlue=11&yBlue=6) | (xBlue=11&yBlue=7) | (xBlue=11&yBlue=8) | (xBlue=11&yBlue=9) | (xBlue=11&yBlue=10) | (xBlue=11&yBlue=11);
formula BlueCannotMoveWest = (xBlue=2&yBlue=1) | (xBlue=2&yBlue=11) | (xBlue=3&yBlue=1) | (xBlue=5&yBlue=1) | (xBlue=6&yBlue=1) | (xBlue=7&yBlue=1) | (xBlue=8&yBlue=1) | (xBlue=9&yBlue=1) | (xBlue=10&yBlue=1) | (xBlue=10&yBlue=11) | (xBlue=11&yBlue=1) | (xBlue=1&yBlue=1) | (xBlue=4&yBlue=1);
formula BlueIsOnSlippery = false;
label BlueGoal = false;
formula GreenCannotMoveNorth = (xGreen=1&yGreen=2) | (xGreen=1&yGreen=3) | (xGreen=1&yGreen=4) | (xGreen=1&yGreen=5) | (xGreen=1&yGreen=6) | (xGreen=1&yGreen=7) | (xGreen=1&yGreen=8) | (xGreen=1&yGreen=9) | (xGreen=1&yGreen=10) | (xGreen=1&yGreen=11) | (xGreen=3&yGreen=2) | (xGreen=3&yGreen=3) | (xGreen=3&yGreen=4) | (xGreen=3&yGreen=5) | (xGreen=3&yGreen=6) | (xGreen=3&yGreen=7) | (xGreen=3&yGreen=8) | (xGreen=3&yGreen=9) | (xGreen=3&yGreen=10) | (xGreen=11&yGreen=2) | (xGreen=11&yGreen=3) | (xGreen=11&yGreen=4) | (xGreen=11&yGreen=5) | (xGreen=11&yGreen=6) | (xGreen=11&yGreen=7) | (xGreen=11&yGreen=8) | (xGreen=11&yGreen=9) | (xGreen=11&yGreen=10) | (xGreen=1&yGreen=1);
formula GreenCannotMoveEast = (xGreen=1&yGreen=11) | (xGreen=2&yGreen=1) | (xGreen=2&yGreen=11) | (xGreen=3&yGreen=11) | (xGreen=4&yGreen=11) | (xGreen=5&yGreen=11) | (xGreen=6&yGreen=11) | (xGreen=8&yGreen=11) | (xGreen=9&yGreen=11) | (xGreen=10&yGreen=1) | (xGreen=10&yGreen=11) | (xGreen=11&yGreen=11) | (xGreen=7&yGreen=11);
formula GreenCannotMoveSouth = (xGreen=1&yGreen=2) | (xGreen=1&yGreen=3) | (xGreen=1&yGreen=4) | (xGreen=1&yGreen=5) | (xGreen=1&yGreen=6) | (xGreen=1&yGreen=7) | (xGreen=1&yGreen=8) | (xGreen=1&yGreen=9) | (xGreen=1&yGreen=10) | (xGreen=9&yGreen=2) | (xGreen=9&yGreen=3) | (xGreen=9&yGreen=4) | (xGreen=9&yGreen=5) | (xGreen=9&yGreen=6) | (xGreen=9&yGreen=7) | (xGreen=9&yGreen=8) | (xGreen=9&yGreen=9) | (xGreen=9&yGreen=10) | (xGreen=11&yGreen=1) | (xGreen=11&yGreen=2) | (xGreen=11&yGreen=3) | (xGreen=11&yGreen=4) | (xGreen=11&yGreen=5) | (xGreen=11&yGreen=6) | (xGreen=11&yGreen=7) | (xGreen=11&yGreen=8) | (xGreen=11&yGreen=9) | (xGreen=11&yGreen=10) | (xGreen=11&yGreen=11);
formula GreenCannotMoveWest = (xGreen=2&yGreen=1) | (xGreen=2&yGreen=11) | (xGreen=3&yGreen=1) | (xGreen=5&yGreen=1) | (xGreen=6&yGreen=1) | (xGreen=7&yGreen=1) | (xGreen=8&yGreen=1) | (xGreen=9&yGreen=1) | (xGreen=10&yGreen=1) | (xGreen=10&yGreen=11) | (xGreen=11&yGreen=1) | (xGreen=1&yGreen=1) | (xGreen=4&yGreen=1);
formula GreenIsOnSlippery = false;
label GreenGoal = false;
label crash = (xAgent=xBlue)&(yAgent=yBlue) | (xAgent=xGreen)&(yAgent=yGreen);
module Agent
xAgent : [1..12] init 1;
yAgent : [1..12] init 1;
viewAgent : [0..3] init 1;
[Agent_turn_right] move=0 & true -> (viewAgent'=mod(viewAgent + 1, 4)) & (move'=1) ;
[Agent_turn_left] move=0 & viewAgent>0 -> (viewAgent'=viewAgent - 1) & (move'=1) ;
[Agent_turn_left] move=0 & viewAgent=0 -> (viewAgent'=3) & (move'=1) ;
[Agent_move_north] move=0 & viewAgent=3 & !AgentIsOnSlippery & !AgentCannotMoveNorth -> (xAgent'=xAgent-1) & (move'=1) ;
[Agent_move_east] move=0 & viewAgent=0 & !AgentIsOnSlippery & !AgentCannotMoveEast -> (yAgent'=yAgent+1) & (move'=1) ;
[Agent_move_south] move=0 & viewAgent=1 & !AgentIsOnSlippery & !AgentCannotMoveSouth -> (xAgent'=xAgent+1) & (move'=1) ;
[Agent_move_west] move=0 & viewAgent=2 & !AgentIsOnSlippery & !AgentCannotMoveWest -> (yAgent'=yAgent-1) & (move'=1) ;
endmodule
module Blue
xBlue : [1..12] init 7;
yBlue : [1..12] init 11;
[Blue_turns] move=1 & true -> (xBlue'=xBlue) & (move'=2) ;
[Blue_move_north] move=1 & !BlueIsOnSlippery & !BlueCannotMoveNorth -> (xBlue'=xBlue-1) & (move'=2) ;
[Blue_move_east] move=1 & !BlueIsOnSlippery & !BlueCannotMoveEast -> (yBlue'=yBlue+1) & (move'=2) ;
[Blue_move_south] move=1 & !BlueIsOnSlippery & !BlueCannotMoveSouth -> (xBlue'=xBlue+1) & (move'=2) ;
[Blue_move_west] move=1 & !BlueIsOnSlippery & !BlueCannotMoveWest -> (yBlue'=yBlue-1) & (move'=2) ;
[Blue_move_north_10] move=1 & !BlueIsOnSlippery & !BlueCannotMoveNorth -> 0.100000: (xBlue'=xBlue-1) & (move'=2) + 0.900000: (xBlue'=xBlue) & (move'=2) ;
[Blue_move_east_10] move=1 & !BlueIsOnSlippery & !BlueCannotMoveEast -> 0.100000: (yBlue'=yBlue+1) & (move'=2) + 0.900000: (xBlue'=xBlue) & (move'=2) ;
[Blue_move_south_10] move=1 & !BlueIsOnSlippery & !BlueCannotMoveSouth -> 0.100000: (xBlue'=xBlue+1) & (move'=2) + 0.900000: (xBlue'=xBlue) & (move'=2) ;
[Blue_move_west_10] move=1 & !BlueIsOnSlippery & !BlueCannotMoveWest -> 0.100000: (yBlue'=yBlue-1) & (move'=2) + 0.900000: (xBlue'=xBlue) & (move'=2) ;
endmodule
module Green
xGreen : [1..12] init 4;
yGreen : [1..12] init 1;
[Green_turns] move=2 & true -> (xGreen'=xGreen) & (move'=0) ;
[Green_move_north] move=2 & !GreenIsOnSlippery & !GreenCannotMoveNorth -> (xGreen'=xGreen-1) & (move'=0) ;
[Green_move_east] move=2 & !GreenIsOnSlippery & !GreenCannotMoveEast -> (yGreen'=yGreen+1) & (move'=0) ;
[Green_move_south] move=2 & !GreenIsOnSlippery & !GreenCannotMoveSouth -> (xGreen'=xGreen+1) & (move'=0) ;
[Green_move_west] move=2 & !GreenIsOnSlippery & !GreenCannotMoveWest -> (yGreen'=yGreen-1) & (move'=0) ;
[Green_move_north_10] move=2 & !GreenIsOnSlippery & !GreenCannotMoveNorth -> 0.100000: (xGreen'=xGreen-1) & (move'=0) + 0.900000: (xGreen'=xGreen) & (move'=0) ;
[Green_move_east_10] move=2 & !GreenIsOnSlippery & !GreenCannotMoveEast -> 0.100000: (yGreen'=yGreen+1) & (move'=0) + 0.900000: (xGreen'=xGreen) & (move'=0) ;
[Green_move_south_10] move=2 & !GreenIsOnSlippery & !GreenCannotMoveSouth -> 0.100000: (xGreen'=xGreen+1) & (move'=0) + 0.900000: (xGreen'=xGreen) & (move'=0) ;
[Green_move_west_10] move=2 & !GreenIsOnSlippery & !GreenCannotMoveWest -> 0.100000: (yGreen'=yGreen-1) & (move'=0) + 0.900000: (xGreen'=xGreen) & (move'=0) ;
endmodule

13
Minigrid2PRISM/emptyGrid

@ -0,0 +1,13 @@
WGWGWGWGWGWGWGWGWGWGWGWGWG
WGXR WG
WG WG
WG WG
WG ZGWG
WG WG
WG WG
WG WG
WG WG
WG WG
WG WG
WG ZBWG
WGWGWGWGWGWGWGWGWGWGWGWGWG

96
Minigrid2PRISM/foobar

@ -0,0 +1,96 @@
smg
player Agent
[Agent_move_north], [Agent_move_east], [Agent_move_south], [Agent_move_west], [Agent_turns]
endplayer
player Blue
[Blue_move_north], [Blue_move_east], [Blue_move_south], [Blue_move_west], [Blue_move_north_10], [Blue_move_east_10], [Blue_move_south_10], [Blue_move_west_10], [Blue_move_north_21], [Blue_move_east_21], [Blue_move_south_21], [Blue_move_west_21], [Blue_turns]
endplayer
player Green
[Green_move_north], [Green_move_east], [Green_move_south], [Green_move_west], [Green_turns]
endplayer
global move : [0..2] init 0;
label AgentOnBlue = (xAgent=1&yAgent=1) | (xAgent=1&yAgent=2) | (xAgent=1&yAgent=3) | (xAgent=1&yAgent=6) | (xAgent=1&yAgent=7) | (xAgent=1&yAgent=8) | (xAgent=1&yAgent=9) | (xAgent=1&yAgent=10) | (xAgent=1&yAgent=11) | (xAgent=2&yAgent=1) | (xAgent=2&yAgent=11) | (xAgent=3&yAgent=1) | (xAgent=3&yAgent=2) | (xAgent=3&yAgent=3) | (xAgent=3&yAgent=4) | (xAgent=3&yAgent=5) | (xAgent=3&yAgent=6) | (xAgent=3&yAgent=7) | (xAgent=3&yAgent=8) | (xAgent=3&yAgent=9) | (xAgent=3&yAgent=10) | (xAgent=3&yAgent=11);
label BlueOnBlue = (xBlue=1&yBlue=1) | (xBlue=1&yBlue=2) | (xBlue=1&yBlue=3) | (xBlue=1&yBlue=6) | (xBlue=1&yBlue=7) | (xBlue=1&yBlue=8) | (xBlue=1&yBlue=9) | (xBlue=1&yBlue=10) | (xBlue=1&yBlue=11) | (xBlue=2&yBlue=1) | (xBlue=2&yBlue=11) | (xBlue=3&yBlue=1) | (xBlue=3&yBlue=2) | (xBlue=3&yBlue=3) | (xBlue=3&yBlue=4) | (xBlue=3&yBlue=5) | (xBlue=3&yBlue=6) | (xBlue=3&yBlue=7) | (xBlue=3&yBlue=8) | (xBlue=3&yBlue=9) | (xBlue=3&yBlue=10) | (xBlue=3&yBlue=11);
label GreenOnBlue = (xGreen=1&yGreen=1) | (xGreen=1&yGreen=2) | (xGreen=1&yGreen=3) | (xGreen=1&yGreen=6) | (xGreen=1&yGreen=7) | (xGreen=1&yGreen=8) | (xGreen=1&yGreen=9) | (xGreen=1&yGreen=10) | (xGreen=1&yGreen=11) | (xGreen=2&yGreen=1) | (xGreen=2&yGreen=11) | (xGreen=3&yGreen=1) | (xGreen=3&yGreen=2) | (xGreen=3&yGreen=3) | (xGreen=3&yGreen=4) | (xGreen=3&yGreen=5) | (xGreen=3&yGreen=6) | (xGreen=3&yGreen=7) | (xGreen=3&yGreen=8) | (xGreen=3&yGreen=9) | (xGreen=3&yGreen=10) | (xGreen=3&yGreen=11);
label AgentOnGreen = (xAgent=9&yAgent=1) | (xAgent=9&yAgent=2) | (xAgent=9&yAgent=3) | (xAgent=9&yAgent=4) | (xAgent=9&yAgent=5) | (xAgent=9&yAgent=6) | (xAgent=9&yAgent=7) | (xAgent=9&yAgent=8) | (xAgent=9&yAgent=9) | (xAgent=9&yAgent=10) | (xAgent=9&yAgent=11) | (xAgent=10&yAgent=1) | (xAgent=10&yAgent=11) | (xAgent=11&yAgent=1) | (xAgent=11&yAgent=2) | (xAgent=11&yAgent=3) | (xAgent=11&yAgent=4) | (xAgent=11&yAgent=5) | (xAgent=11&yAgent=6) | (xAgent=11&yAgent=7) | (xAgent=11&yAgent=8) | (xAgent=11&yAgent=9) | (xAgent=11&yAgent=10) | (xAgent=11&yAgent=11);
label BlueOnGreen = (xBlue=9&yBlue=1) | (xBlue=9&yBlue=2) | (xBlue=9&yBlue=3) | (xBlue=9&yBlue=4) | (xBlue=9&yBlue=5) | (xBlue=9&yBlue=6) | (xBlue=9&yBlue=7) | (xBlue=9&yBlue=8) | (xBlue=9&yBlue=9) | (xBlue=9&yBlue=10) | (xBlue=9&yBlue=11) | (xBlue=10&yBlue=1) | (xBlue=10&yBlue=11) | (xBlue=11&yBlue=1) | (xBlue=11&yBlue=2) | (xBlue=11&yBlue=3) | (xBlue=11&yBlue=4) | (xBlue=11&yBlue=5) | (xBlue=11&yBlue=6) | (xBlue=11&yBlue=7) | (xBlue=11&yBlue=8) | (xBlue=11&yBlue=9) | (xBlue=11&yBlue=10) | (xBlue=11&yBlue=11);
label GreenOnGreen = (xGreen=9&yGreen=1) | (xGreen=9&yGreen=2) | (xGreen=9&yGreen=3) | (xGreen=9&yGreen=4) | (xGreen=9&yGreen=5) | (xGreen=9&yGreen=6) | (xGreen=9&yGreen=7) | (xGreen=9&yGreen=8) | (xGreen=9&yGreen=9) | (xGreen=9&yGreen=10) | (xGreen=9&yGreen=11) | (xGreen=10&yGreen=1) | (xGreen=10&yGreen=11) | (xGreen=11&yGreen=1) | (xGreen=11&yGreen=2) | (xGreen=11&yGreen=3) | (xGreen=11&yGreen=4) | (xGreen=11&yGreen=5) | (xGreen=11&yGreen=6) | (xGreen=11&yGreen=7) | (xGreen=11&yGreen=8) | (xGreen=11&yGreen=9) | (xGreen=11&yGreen=10) | (xGreen=11&yGreen=11);
label AgentOnRed = (xAgent=1&yAgent=4) | (xAgent=1&yAgent=5);
label BlueOnRed = (xBlue=1&yBlue=4) | (xBlue=1&yBlue=5);
label GreenOnRed = (xGreen=1&yGreen=4) | (xGreen=1&yGreen=5);
formula AgentCannotMoveNorth = (xAgent=1&yAgent=2) | (xAgent=1&yAgent=3) | (xAgent=1&yAgent=4) | (xAgent=1&yAgent=5) | (xAgent=1&yAgent=6) | (xAgent=1&yAgent=7) | (xAgent=1&yAgent=8) | (xAgent=1&yAgent=9) | (xAgent=1&yAgent=10) | (xAgent=1&yAgent=11) | (xAgent=3&yAgent=2) | (xAgent=3&yAgent=3) | (xAgent=3&yAgent=4) | (xAgent=3&yAgent=5) | (xAgent=3&yAgent=6) | (xAgent=3&yAgent=7) | (xAgent=3&yAgent=8) | (xAgent=3&yAgent=9) | (xAgent=3&yAgent=10) | (xAgent=11&yAgent=2) | (xAgent=11&yAgent=3) | (xAgent=11&yAgent=4) | (xAgent=11&yAgent=5) | (xAgent=11&yAgent=6) | (xAgent=11&yAgent=7) | (xAgent=11&yAgent=8) | (xAgent=11&yAgent=9) | (xAgent=11&yAgent=10) | (xAgent=1&yAgent=1);
formula AgentCannotMoveEast = (xAgent=1&yAgent=11) | (xAgent=2&yAgent=1) | (xAgent=2&yAgent=11) | (xAgent=3&yAgent=11) | (xAgent=4&yAgent=11) | (xAgent=5&yAgent=11) | (xAgent=6&yAgent=11) | (xAgent=8&yAgent=11) | (xAgent=9&yAgent=11) | (xAgent=10&yAgent=1) | (xAgent=10&yAgent=11) | (xAgent=11&yAgent=11) | (xAgent=7&yAgent=11);
formula AgentCannotMoveSouth = (xAgent=1&yAgent=2) | (xAgent=1&yAgent=3) | (xAgent=1&yAgent=4) | (xAgent=1&yAgent=5) | (xAgent=1&yAgent=6) | (xAgent=1&yAgent=7) | (xAgent=1&yAgent=8) | (xAgent=1&yAgent=9) | (xAgent=1&yAgent=10) | (xAgent=9&yAgent=2) | (xAgent=9&yAgent=3) | (xAgent=9&yAgent=4) | (xAgent=9&yAgent=5) | (xAgent=9&yAgent=6) | (xAgent=9&yAgent=7) | (xAgent=9&yAgent=8) | (xAgent=9&yAgent=9) | (xAgent=9&yAgent=10) | (xAgent=11&yAgent=1) | (xAgent=11&yAgent=2) | (xAgent=11&yAgent=3) | (xAgent=11&yAgent=4) | (xAgent=11&yAgent=5) | (xAgent=11&yAgent=6) | (xAgent=11&yAgent=7) | (xAgent=11&yAgent=8) | (xAgent=11&yAgent=9) | (xAgent=11&yAgent=10) | (xAgent=11&yAgent=11);
formula AgentCannotMoveWest = (xAgent=2&yAgent=1) | (xAgent=2&yAgent=11) | (xAgent=3&yAgent=1) | (xAgent=5&yAgent=1) | (xAgent=6&yAgent=1) | (xAgent=7&yAgent=1) | (xAgent=8&yAgent=1) | (xAgent=9&yAgent=1) | (xAgent=10&yAgent=1) | (xAgent=10&yAgent=11) | (xAgent=11&yAgent=1) | (xAgent=1&yAgent=1) | (xAgent=4&yAgent=1);
formula AgentIsOnSlippery = false;
label AgentGoal = false;
formula BlueCannotMoveNorth = (xBlue=1&yBlue=2) | (xBlue=1&yBlue=3) | (xBlue=1&yBlue=4) | (xBlue=1&yBlue=5) | (xBlue=1&yBlue=6) | (xBlue=1&yBlue=7) | (xBlue=1&yBlue=8) | (xBlue=1&yBlue=9) | (xBlue=1&yBlue=10) | (xBlue=1&yBlue=11) | (xBlue=3&yBlue=2) | (xBlue=3&yBlue=3) | (xBlue=3&yBlue=4) | (xBlue=3&yBlue=5) | (xBlue=3&yBlue=6) | (xBlue=3&yBlue=7) | (xBlue=3&yBlue=8) | (xBlue=3&yBlue=9) | (xBlue=3&yBlue=10) | (xBlue=11&yBlue=2) | (xBlue=11&yBlue=3) | (xBlue=11&yBlue=4) | (xBlue=11&yBlue=5) | (xBlue=11&yBlue=6) | (xBlue=11&yBlue=7) | (xBlue=11&yBlue=8) | (xBlue=11&yBlue=9) | (xBlue=11&yBlue=10) | (xBlue=1&yBlue=1);
formula BlueCannotMoveEast = (xBlue=1&yBlue=11) | (xBlue=2&yBlue=1) | (xBlue=2&yBlue=11) | (xBlue=3&yBlue=11) | (xBlue=4&yBlue=11) | (xBlue=5&yBlue=11) | (xBlue=6&yBlue=11) | (xBlue=8&yBlue=11) | (xBlue=9&yBlue=11) | (xBlue=10&yBlue=1) | (xBlue=10&yBlue=11) | (xBlue=11&yBlue=11) | (xBlue=7&yBlue=11);
formula BlueCannotMoveSouth = (xBlue=1&yBlue=2) | (xBlue=1&yBlue=3) | (xBlue=1&yBlue=4) | (xBlue=1&yBlue=5) | (xBlue=1&yBlue=6) | (xBlue=1&yBlue=7) | (xBlue=1&yBlue=8) | (xBlue=1&yBlue=9) | (xBlue=1&yBlue=10) | (xBlue=9&yBlue=2) | (xBlue=9&yBlue=3) | (xBlue=9&yBlue=4) | (xBlue=9&yBlue=5) | (xBlue=9&yBlue=6) | (xBlue=9&yBlue=7) | (xBlue=9&yBlue=8) | (xBlue=9&yBlue=9) | (xBlue=9&yBlue=10) | (xBlue=11&yBlue=1) | (xBlue=11&yBlue=2) | (xBlue=11&yBlue=3) | (xBlue=11&yBlue=4) | (xBlue=11&yBlue=5) | (xBlue=11&yBlue=6) | (xBlue=11&yBlue=7) | (xBlue=11&yBlue=8) | (xBlue=11&yBlue=9) | (xBlue=11&yBlue=10) | (xBlue=11&yBlue=11);
formula BlueCannotMoveWest = (xBlue=2&yBlue=1) | (xBlue=2&yBlue=11) | (xBlue=3&yBlue=1) | (xBlue=5&yBlue=1) | (xBlue=6&yBlue=1) | (xBlue=7&yBlue=1) | (xBlue=8&yBlue=1) | (xBlue=9&yBlue=1) | (xBlue=10&yBlue=1) | (xBlue=10&yBlue=11) | (xBlue=11&yBlue=1) | (xBlue=1&yBlue=1) | (xBlue=4&yBlue=1);
formula BlueIsOnSlippery = false;
label BlueGoal = false;
formula GreenCannotMoveNorth = (xGreen=1&yGreen=2) | (xGreen=1&yGreen=3) | (xGreen=1&yGreen=4) | (xGreen=1&yGreen=5) | (xGreen=1&yGreen=6) | (xGreen=1&yGreen=7) | (xGreen=1&yGreen=8) | (xGreen=1&yGreen=9) | (xGreen=1&yGreen=10) | (xGreen=1&yGreen=11) | (xGreen=3&yGreen=2) | (xGreen=3&yGreen=3) | (xGreen=3&yGreen=4) | (xGreen=3&yGreen=5) | (xGreen=3&yGreen=6) | (xGreen=3&yGreen=7) | (xGreen=3&yGreen=8) | (xGreen=3&yGreen=9) | (xGreen=3&yGreen=10) | (xGreen=11&yGreen=2) | (xGreen=11&yGreen=3) | (xGreen=11&yGreen=4) | (xGreen=11&yGreen=5) | (xGreen=11&yGreen=6) | (xGreen=11&yGreen=7) | (xGreen=11&yGreen=8) | (xGreen=11&yGreen=9) | (xGreen=11&yGreen=10) | (xGreen=1&yGreen=1);
formula GreenCannotMoveEast = (xGreen=1&yGreen=11) | (xGreen=2&yGreen=1) | (xGreen=2&yGreen=11) | (xGreen=3&yGreen=11) | (xGreen=4&yGreen=11) | (xGreen=5&yGreen=11) | (xGreen=6&yGreen=11) | (xGreen=8&yGreen=11) | (xGreen=9&yGreen=11) | (xGreen=10&yGreen=1) | (xGreen=10&yGreen=11) | (xGreen=11&yGreen=11) | (xGreen=7&yGreen=11);
formula GreenCannotMoveSouth = (xGreen=1&yGreen=2) | (xGreen=1&yGreen=3) | (xGreen=1&yGreen=4) | (xGreen=1&yGreen=5) | (xGreen=1&yGreen=6) | (xGreen=1&yGreen=7) | (xGreen=1&yGreen=8) | (xGreen=1&yGreen=9) | (xGreen=1&yGreen=10) | (xGreen=9&yGreen=2) | (xGreen=9&yGreen=3) | (xGreen=9&yGreen=4) | (xGreen=9&yGreen=5) | (xGreen=9&yGreen=6) | (xGreen=9&yGreen=7) | (xGreen=9&yGreen=8) | (xGreen=9&yGreen=9) | (xGreen=9&yGreen=10) | (xGreen=11&yGreen=1) | (xGreen=11&yGreen=2) | (xGreen=11&yGreen=3) | (xGreen=11&yGreen=4) | (xGreen=11&yGreen=5) | (xGreen=11&yGreen=6) | (xGreen=11&yGreen=7) | (xGreen=11&yGreen=8) | (xGreen=11&yGreen=9) | (xGreen=11&yGreen=10) | (xGreen=11&yGreen=11);
formula GreenCannotMoveWest = (xGreen=2&yGreen=1) | (xGreen=2&yGreen=11) | (xGreen=3&yGreen=1) | (xGreen=5&yGreen=1) | (xGreen=6&yGreen=1) | (xGreen=7&yGreen=1) | (xGreen=8&yGreen=1) | (xGreen=9&yGreen=1) | (xGreen=10&yGreen=1) | (xGreen=10&yGreen=11) | (xGreen=11&yGreen=1) | (xGreen=1&yGreen=1) | (xGreen=4&yGreen=1);
formula GreenIsOnSlippery = false;
label GreenGoal = false;
label crash = (xAgent=xBlue)&(yAgent=yBlue) | (xAgent=xGreen)&(yAgent=yGreen);
module Agent
xAgent : [1..12] init 1;
yAgent : [1..12] init 1;
[Agent_turns] move=0 & true -> (xAgent'=xAgent) & (move'=1) ;
[Agent_move_north] move=0 & !AgentIsOnSlippery & !AgentCannotMoveNorth -> (xAgent'=xAgent-1) & (move'=1) ;
[Agent_move_east] move=0 & !AgentIsOnSlippery & !AgentCannotMoveEast -> (yAgent'=yAgent+1) & (move'=1) ;
[Agent_move_south] move=0 & !AgentIsOnSlippery & !AgentCannotMoveSouth -> (xAgent'=xAgent+1) & (move'=1) ;
[Agent_move_west] move=0 & !AgentIsOnSlippery & !AgentCannotMoveWest -> (yAgent'=yAgent-1) & (move'=1) ;
endmodule
module Blue
xBlue : [1..12] init 7;
yBlue : [1..12] init 11;
[Blue_turns] move=1 & true -> (xBlue'=xBlue) & (move'=2) ;
[Blue_move_north] move=1 & !BlueIsOnSlippery & !BlueCannotMoveNorth -> (xBlue'=xBlue-1) & (move'=2) ;
[Blue_move_east] move=1 & !BlueIsOnSlippery & !BlueCannotMoveEast -> (yBlue'=yBlue+1) & (move'=2) ;
[Blue_move_south] move=1 & !BlueIsOnSlippery & !BlueCannotMoveSouth -> (xBlue'=xBlue+1) & (move'=2) ;
[Blue_move_west] move=1 & !BlueIsOnSlippery & !BlueCannotMoveWest -> (yBlue'=yBlue-1) & (move'=2) ;
[Blue_move_north_10] move=1 & !BlueIsOnSlippery & !BlueCannotMoveNorth -> 0.100000: (xBlue'=xBlue-1) & (move'=2) + 0.900000: (xBlue'=xBlue) & (move'=2) ;
[Blue_move_east_10] move=1 & !BlueIsOnSlippery & !BlueCannotMoveEast -> 0.100000: (yBlue'=yBlue+1) & (move'=2) + 0.900000: (xBlue'=xBlue) & (move'=2) ;
[Blue_move_south_10] move=1 & !BlueIsOnSlippery & !BlueCannotMoveSouth -> 0.100000: (xBlue'=xBlue+1) & (move'=2) + 0.900000: (xBlue'=xBlue) & (move'=2) ;
[Blue_move_west_10] move=1 & !BlueIsOnSlippery & !BlueCannotMoveWest -> 0.100000: (yBlue'=yBlue-1) & (move'=2) + 0.900000: (xBlue'=xBlue) & (move'=2) ;
[Blue_move_north_21] move=1 & !BlueIsOnSlippery & !BlueCannotMoveNorth -> 0.210000: (xBlue'=xBlue-1) & (move'=2) + 0.790000: (xBlue'=xBlue) & (move'=2) ;
[Blue_move_east_21] move=1 & !BlueIsOnSlippery & !BlueCannotMoveEast -> 0.210000: (yBlue'=yBlue+1) & (move'=2) + 0.790000: (xBlue'=xBlue) & (move'=2) ;
[Blue_move_south_21] move=1 & !BlueIsOnSlippery & !BlueCannotMoveSouth -> 0.210000: (xBlue'=xBlue+1) & (move'=2) + 0.790000: (xBlue'=xBlue) & (move'=2) ;
[Blue_move_west_21] move=1 & !BlueIsOnSlippery & !BlueCannotMoveWest -> 0.210000: (yBlue'=yBlue-1) & (move'=2) + 0.790000: (xBlue'=xBlue) & (move'=2) ;
endmodule
module Green
xGreen : [1..12] init 4;
yGreen : [1..12] init 1;
[Green_turns] move=2 & true -> (xGreen'=xGreen) & (move'=0) ;
[Green_move_north] move=2 & !GreenIsOnSlippery & !GreenCannotMoveNorth -> (xGreen'=xGreen-1) & (move'=0) ;
[Green_move_east] move=2 & !GreenIsOnSlippery & !GreenCannotMoveEast -> (yGreen'=yGreen+1) & (move'=0) ;
[Green_move_south] move=2 & !GreenIsOnSlippery & !GreenCannotMoveSouth -> (xGreen'=xGreen+1) & (move'=0) ;
[Green_move_west] move=2 & !GreenIsOnSlippery & !GreenCannotMoveWest -> (yGreen'=yGreen-1) & (move'=0) ;
endmodule

27
Minigrid2PRISM/grid

@ -0,0 +1,27 @@
WGWGWGWGWGWGWGWGWGWGWGWGWG
WGXR WG
WG WGWGWGWGWGWGWGWGWG WG
WG SBWG
WGZGSB SBSB SB SB WG
WG SB WG
WG SB WG
WG SB SB SB ZBWG
WG SB WG
WG SB SB SB WG
WG WGWGWGWGWGWGWGWGWG WG
WG GRWG
WGWGWGWGWGWGWGWGWGWGWGWGWG
--------------------------
WGWGWGWGWGWGWGWGWGWGWGWGWG
WG B B B R R B B B B B BWG
WG BWGWGWGWGWGWGWGWGWG BWG
WG B B B B B B B B B B BWG
WG WG
WG WG
WG WG
WG WG
WG WG
WG G G G G G G G G G G GWG
WG GWGWGWGWGWGWGWGWGWG GWG
WG G G G G G G G G G G GWG
WGWGWGWGWGWGWGWGWGWGWGWGWG

65
Minigrid2PRISM/grid.prism

@ -0,0 +1,65 @@
smg
player Agent
[Agent_move_north], [Agent_move_east], [Agent_move_south], [Agent_move_west], [Agent_turn_left], [Agent_turn_right]
endplayer
player Blue
[Blue_move_north], [Blue_move_east], [Blue_move_south], [Blue_move_west], [Blue_turns]
endplayer
global move : [0..1] init 0;
label AgentOnBlue = (xAgent=1&yAgent=1) | (xAgent=1&yAgent=4) | (xAgent=1&yAgent=5) | (xAgent=2&yAgent=1) | (xAgent=2&yAgent=5);
label BlueOnBlue = (xBlue=1&yBlue=1) | (xBlue=1&yBlue=4) | (xBlue=1&yBlue=5) | (xBlue=2&yBlue=1) | (xBlue=2&yBlue=5);
label AgentOnGreen = (xAgent=3&yAgent=1) | (xAgent=3&yAgent=2) | (xAgent=3&yAgent=3) | (xAgent=3&yAgent=4) | (xAgent=3&yAgent=5) | (xAgent=4&yAgent=1) | (xAgent=4&yAgent=5) | (xAgent=5&yAgent=1) | (xAgent=5&yAgent=2) | (xAgent=5&yAgent=3) | (xAgent=5&yAgent=4) | (xAgent=5&yAgent=5);
label BlueOnGreen = (xBlue=3&yBlue=1) | (xBlue=3&yBlue=2) | (xBlue=3&yBlue=3) | (xBlue=3&yBlue=4) | (xBlue=3&yBlue=5) | (xBlue=4&yBlue=1) | (xBlue=4&yBlue=5) | (xBlue=5&yBlue=1) | (xBlue=5&yBlue=2) | (xBlue=5&yBlue=3) | (xBlue=5&yBlue=4) | (xBlue=5&yBlue=5);
label AgentOnRed = (xAgent=1&yAgent=2) | (xAgent=1&yAgent=3);
label BlueOnRed = (xBlue=1&yBlue=2) | (xBlue=1&yBlue=3);
formula AgentCannotMoveNorth = (xAgent=1&yAgent=2) | (xAgent=1&yAgent=3) | (xAgent=1&yAgent=4) | (xAgent=1&yAgent=5) | (xAgent=3&yAgent=2) | (xAgent=3&yAgent=4) | (xAgent=5&yAgent=2) | (xAgent=5&yAgent=4) | (xAgent=3&yAgent=3) | (xAgent=5&yAgent=3) | (xAgent=1&yAgent=1);
formula AgentCannotMoveEast = (xAgent=1&yAgent=5) | (xAgent=2&yAgent=1) | (xAgent=2&yAgent=5) | (xAgent=3&yAgent=5) | (xAgent=4&yAgent=5) | (xAgent=4&yAgent=1) | (xAgent=5&yAgent=5);
formula AgentCannotMoveSouth = (xAgent=1&yAgent=2) | (xAgent=1&yAgent=3) | (xAgent=1&yAgent=4) | (xAgent=3&yAgent=2) | (xAgent=3&yAgent=4) | (xAgent=5&yAgent=1) | (xAgent=5&yAgent=2) | (xAgent=5&yAgent=4) | (xAgent=3&yAgent=3) | (xAgent=5&yAgent=3) | (xAgent=5&yAgent=5);
formula AgentCannotMoveWest = (xAgent=2&yAgent=1) | (xAgent=2&yAgent=5) | (xAgent=3&yAgent=1) | (xAgent=4&yAgent=5) | (xAgent=5&yAgent=1) | (xAgent=1&yAgent=1) | (xAgent=4&yAgent=1);
formula AgentIsOnSlippery = false;
label AgentGoal = false;
formula BlueCannotMoveNorth = (xBlue=1&yBlue=2) | (xBlue=1&yBlue=3) | (xBlue=1&yBlue=4) | (xBlue=1&yBlue=5) | (xBlue=3&yBlue=2) | (xBlue=3&yBlue=4) | (xBlue=5&yBlue=2) | (xBlue=5&yBlue=4) | (xBlue=3&yBlue=3) | (xBlue=5&yBlue=3) | (xBlue=1&yBlue=1);
formula BlueCannotMoveEast = (xBlue=1&yBlue=5) | (xBlue=2&yBlue=1) | (xBlue=2&yBlue=5) | (xBlue=3&yBlue=5) | (xBlue=4&yBlue=5) | (xBlue=4&yBlue=1) | (xBlue=5&yBlue=5);
formula BlueCannotMoveSouth = (xBlue=1&yBlue=2) | (xBlue=1&yBlue=3) | (xBlue=1&yBlue=4) | (xBlue=3&yBlue=2) | (xBlue=3&yBlue=4) | (xBlue=5&yBlue=1) | (xBlue=5&yBlue=2) | (xBlue=5&yBlue=4) | (xBlue=3&yBlue=3) | (xBlue=5&yBlue=3) | (xBlue=5&yBlue=5);
formula BlueCannotMoveWest = (xBlue=2&yBlue=1) | (xBlue=2&yBlue=5) | (xBlue=3&yBlue=1) | (xBlue=4&yBlue=5) | (xBlue=5&yBlue=1) | (xBlue=1&yBlue=1) | (xBlue=4&yBlue=1);
formula BlueIsOnSlippery = false;
label BlueGoal = false;
label crash = (xAgent=xBlue)&(yAgent=yBlue);
module Agent
xAgent : [1..6] init 1;
yAgent : [1..6] init 1;
viewAgent : [0..3] init 1;
[Agent_turn_right] move=0 & true -> (viewAgent'=mod(viewAgent + 1, 4)) & (move'=1) ;
[Agent_turn_left] move=0 & viewAgent>0 -> (viewAgent'=viewAgent - 1) & (move'=1) ;
[Agent_turn_left] move=0 & viewAgent=0 -> (viewAgent'=3) & (move'=1) ;
[Agent_move_north] move=0 & viewAgent=3 & !AgentIsOnSlippery & !AgentCannotMoveNorth -> (xAgent'=xAgent-1) & (move'=1) ;
[Agent_move_east] move=0 & viewAgent=0 & !AgentIsOnSlippery & !AgentCannotMoveEast -> (yAgent'=yAgent+1) & (move'=1) ;
[Agent_move_south] move=0 & viewAgent=1 & !AgentIsOnSlippery & !AgentCannotMoveSouth -> (xAgent'=xAgent+1) & (move'=1) ;
[Agent_move_west] move=0 & viewAgent=2 & !AgentIsOnSlippery & !AgentCannotMoveWest -> (yAgent'=yAgent-1) & (move'=1) ;
endmodule
module Blue
xBlue : [1..6] init 5;
yBlue : [1..6] init 5;
[Blue_turns] move=1 & true -> (xBlue'=xBlue) & (move'=0) ;
[Blue_move_north] move=1 & !BlueIsOnSlippery & !BlueCannotMoveNorth -> (xBlue'=xBlue-1) & (move'=0) ;
[Blue_move_east] move=1 & !BlueIsOnSlippery & !BlueCannotMoveEast -> (yBlue'=yBlue+1) & (move'=0) ;
[Blue_move_south] move=1 & !BlueIsOnSlippery & !BlueCannotMoveSouth -> (xBlue'=xBlue+1) & (move'=0) ;
[Blue_move_west] move=1 & !BlueIsOnSlippery & !BlueCannotMoveWest -> (yBlue'=yBlue-1) & (move'=0) ;
endmodule

19
Minigrid2PRISM/gridLava

@ -0,0 +1,19 @@
WGWGWGWGWGWGWGWGWG
WG WG
WG LR WG
WG LR WG
WG LR WG
WG LR WG
WG LR WG
WGXRLR GGWG
WGWGWGWGWGWGWGWGWG
------------------
WGWGWGWGWGWGWGWGWG
WG WG
WG WG
WG WG
WG WG
WG WG
WG WG
WG WG
WGWGWGWGWGWGWGWGWG

35
Minigrid2PRISM/gridLava.prism

@ -0,0 +1,35 @@
smg
player Agent
[Agent_move_north], [Agent_move_east], [Agent_move_south], [Agent_move_west], [Agent_turn_left], [Agent_turn_right]
endplayer
global move : [0..0] init 0;
formula AgentCannotMoveNorth = (xAgent=1&yAgent=1) | (xAgent=1&yAgent=2) | (xAgent=1&yAgent=3) | (xAgent=1&yAgent=4) | (xAgent=1&yAgent=5) | (xAgent=1&yAgent=6) | (xAgent=1&yAgent=7);
formula AgentCannotMoveEast = (xAgent=1&yAgent=7) | (xAgent=2&yAgent=1) | (xAgent=2&yAgent=7) | (xAgent=3&yAgent=1) | (xAgent=3&yAgent=7) | (xAgent=4&yAgent=1) | (xAgent=4&yAgent=7) | (xAgent=5&yAgent=1) | (xAgent=5&yAgent=7) | (xAgent=6&yAgent=1) | (xAgent=6&yAgent=7) | (xAgent=7&yAgent=7) | (xAgent=7&yAgent=1);
formula AgentCannotMoveSouth = (xAgent=1&yAgent=2) | (xAgent=7&yAgent=3) | (xAgent=7&yAgent=4) | (xAgent=7&yAgent=5) | (xAgent=7&yAgent=6) | (xAgent=7&yAgent=7) | (xAgent=7&yAgent=1);
formula AgentCannotMoveWest = (xAgent=1&yAgent=1) | (xAgent=2&yAgent=1) | (xAgent=2&yAgent=3) | (xAgent=3&yAgent=1) | (xAgent=3&yAgent=3) | (xAgent=4&yAgent=1) | (xAgent=4&yAgent=3) | (xAgent=5&yAgent=1) | (xAgent=5&yAgent=3) | (xAgent=6&yAgent=1) | (xAgent=6&yAgent=3) | (xAgent=7&yAgent=3) | (xAgent=7&yAgent=1);
formula AgentIsOnSlippery = false;
label AgentGoal = (xAgent=7&yAgent=7);
label crash = ;
module Agent
xAgent : [1..8] init 7;
yAgent : [1..8] init 1;
viewAgent : [0..3] init 1;
[Agent_turn_right] move=0 & true -> (viewAgent'=mod(viewAgent + 1, 4)) & (move'=0) ;
[Agent_turn_left] move=0 & viewAgent>0 -> (viewAgent'=viewAgent - 1) & (move'=0) ;
[Agent_turn_left] move=0 & viewAgent=0 -> (viewAgent'=3) & (move'=0) ;
[Agent_move_north] move=0 & viewAgent=3 & !AgentIsOnSlippery & !AgentCannotMoveNorth -> (xAgent'=xAgent-1) & (move'=0) ;
[Agent_move_east] move=0 & viewAgent=0 & !AgentIsOnSlippery & !AgentCannotMoveEast -> (yAgent'=yAgent+1) & (move'=0) ;
[Agent_move_south] move=0 & viewAgent=1 & !AgentIsOnSlippery & !AgentCannotMoveSouth -> (xAgent'=xAgent+1) & (move'=0) ;
[Agent_move_west] move=0 & viewAgent=2 & !AgentIsOnSlippery & !AgentCannotMoveWest -> (yAgent'=yAgent-1) & (move'=0) ;
endmodule

15
Minigrid2PRISM/gridSave

@ -0,0 +1,15 @@
WGWGWGWGWGWGWG
WGXR WG
WG WGWGWG WG
WG BB WG
WGZGWGWGWG WG
WG BR ZBWG
WGWGWGWGWGWGWG
--------------
WGWGWGWGWGWGWG
WG B R R B BWG
WG BWGWGWG BWG
WG G G G G GWG
WG GWGWGWG GWG
WG G G G G GWG
WGWGWGWGWGWGWG

166
Minigrid2PRISM/main.cpp

@ -0,0 +1,166 @@
#include "util/OptionParser.h"
#include "util/MinigridGrammar.h"
#include "util/Grid.h"
#include <iostream>
#include <fstream>
#include <filesystem>
#include <sstream>
std::vector<std::string> parseCommaSeparatedString(std::string const& str) {
std::vector<std::string> result;
std::stringstream stream(str);
while(stream.good()) {
std::string substr;
getline(stream, substr, ',');
substr.at(0) = std::toupper(substr.at(0));
result.push_back(substr);
}
return result;
}
struct printer {
typedef boost::spirit::utf8_string string;
void element(string const& tag, string const& value, int depth) const {
for (int i = 0; i < (depth*4); ++i) std::cout << ' ';
std::cout << "tag: " << tag;
if (value != "") std::cout << ", value: " << value;
std::cout << std::endl;
}
};
void print_info(boost::spirit::info const& what) {
using boost::spirit::basic_info_walker;
printer pr;
basic_info_walker<printer> walker(pr, what.tag, 0);
boost::apply_visitor(walker, what.value);
}
int main(int argc, char* argv[]) {
popl::OptionParser optionParser("Allowed options");
auto helpOption = optionParser.add<popl::Switch>("h", "help", "Print this help message.");
auto inputFilename = optionParser.add<popl::Value<std::string>>("i", "input-file", "Filename of the input file.");
auto outputFilename = optionParser.add<popl::Value<std::string>>("o", "output-file", "Filename for the output file.");
auto agentsToBeConsidered = optionParser.add<popl::Value<std::string>, popl::Attribute::optional>("a", "agents", "Which parsed agents should be considered in the output. WIP.");
auto viewForAgents = optionParser.add<popl::Value<std::string>, popl::Attribute::optional>("v", "view", "Agents for which the 'view'('direction') variable should be included. WIP.");
auto probabilisticBehaviourAgents = optionParser.add<popl::Value<std::string>, popl::Attribute::optional>("p", "prob-beh", "Agents for which we want to include probabilistic actions");
auto probabilities = optionParser.add<popl::Value<std::string>, popl::Attribute::optional>("q", "probs", "The probabilities for which probabilistic actions should be added. WIP");
try {
optionParser.parse(argc, argv);
if(helpOption->count() > 0) {
std::cout << optionParser << std::endl;
return EXIT_SUCCESS;
}
} catch (const popl::invalid_option &e) {
return io::printPoplException(e);
} catch (const std::exception &e) {
std::cerr << "Exception: " << e.what() << "\n";
return EXIT_FAILURE;
}
GridOptions gridOptions = { {}, {} };
if(agentsToBeConsidered->is_set()) {
gridOptions.agentsToBeConsidered = parseCommaSeparatedString(agentsToBeConsidered->value(0));
}
if(viewForAgents->is_set()) {
gridOptions.agentsWithView = parseCommaSeparatedString(viewForAgents->value(0));
}
if(probabilisticBehaviourAgents->is_set()) {
gridOptions.agentsWithProbabilisticBehaviour = parseCommaSeparatedString(probabilisticBehaviourAgents->value(0));
for(auto const& a : gridOptions.agentsWithProbabilisticBehaviour) {
std::cout << a << std::endl;
}
if(probabilities->is_set()) {
std::vector<std::string> parsedStrings = parseCommaSeparatedString(probabilities->value(0));
std::transform(parsedStrings.begin(), parsedStrings.end(), std::back_inserter(gridOptions.probabilitiesForActions), [](const std::string& string) {
return std::stof(string);
});
for(auto const& a : gridOptions.probabilitiesForActions) {
std::cout << a << std::endl;
}
} else {
throw std::logic_error{ "When adding agents with probabilistic behaviour, you also need to specify a list of probabilities via --probs." };
}
}
std::fstream file {outputFilename->value(0), file.trunc | file.out};
std::fstream infile {inputFilename->value(0), infile.in};
std::string line, content, background, rewards;
std::cout << "\n";
bool parsingBackground = false;
bool parsingStateRewards = false;
while (std::getline(infile, line) && !line.empty()) {
if(line.at(0) == '-' && line.at(line.size() - 1) == '-' && parsingBackground) {
parsingStateRewards = true;
parsingBackground = false;
continue;
} else if(line.at(0) == '-' && line.at(line.size() - 1) == '-') {
parsingBackground = true;
continue;
}
if(!parsingBackground && !parsingStateRewards) {
std::cout << "Reading :\t" << line << "\n";
content += line + "\n";
} else if (parsingBackground) {
std::cout << "Background:\t" << line << "\n";
background += line + "\n";
} else if(parsingStateRewards) {
rewards += line + "\n";
}
}
std::cout << "\n";
pos_iterator_t contentFirst(content.begin());
pos_iterator_t contentIter = contentFirst;
pos_iterator_t contentLast(content.end());
MinigridParser<pos_iterator_t> contentParser(contentFirst);
pos_iterator_t backgroundFirst(background.begin());
pos_iterator_t backgroundIter = backgroundFirst;
pos_iterator_t backgroundLast(background.end());
MinigridParser<pos_iterator_t> backgroundParser(backgroundFirst);
cells contentCells;
cells backgroundCells;
std::map<coordinates, float> stateRewards;
try {
bool ok = phrase_parse(contentIter, contentLast, contentParser, qi::space, contentCells);
// TODO if(background is not empty) {
ok &= phrase_parse(backgroundIter, backgroundLast, backgroundParser, qi::space, backgroundCells);
// TODO }
boost::escaped_list_separator<char> seps('\\', ';', '\n');
Tokenizer csvParser(rewards, seps);
for(auto iter = csvParser.begin(); iter != csvParser.end(); ++iter) {
int x = std::stoi(*iter);
int y = std::stoi(*(++iter));
float reward = std::stof(*(++iter));
stateRewards[std::make_pair(x,y)] = reward;
}
if(ok) {
Grid grid(contentCells, backgroundCells, gridOptions, stateRewards);
//grid.printToPrism(std::cout, prism::ModelType::MDP);
grid.printToPrism(file, prism::ModelType::MDP);
}
} catch(qi::expectation_failure<pos_iterator_t> const& e) {
std::cout << "expected: "; print_info(e.what_);
std::cout << "got: \"" << std::string(e.first, e.last) << '"' << std::endl;
std::cout << "Expectation failure: " << e.what() << " at '" << std::string(e.first,e.last) << "'\n";
} catch(const std::exception& e) {
std::cerr << "Exception '" << typeid(e).name() << "' caught:" << std::endl;
std::cerr << "\t" << e.what() << std::endl;
std::exit(EXIT_FAILURE);
}
return 0;
}

88
Minigrid2PRISM/noview.prism

@ -0,0 +1,88 @@
smg
player Agent
[Agent_move_north], [Agent_move_east], [Agent_move_south], [Agent_move_west], [Agent_turns]
endplayer
player Blue
[Blue_move_north], [Blue_move_east], [Blue_move_south], [Blue_move_west], [Blue_turns]
endplayer
player Green
[Green_move_north], [Green_move_east], [Green_move_south], [Green_move_west], [Green_turns]
endplayer
global move : [0..2] init 0;
label AgentOnBlue = (xAgent=1&yAgent=1) | (xAgent=1&yAgent=2) | (xAgent=1&yAgent=3) | (xAgent=1&yAgent=6) | (xAgent=1&yAgent=7) | (xAgent=1&yAgent=8) | (xAgent=1&yAgent=9) | (xAgent=1&yAgent=10) | (xAgent=1&yAgent=11) | (xAgent=2&yAgent=1) | (xAgent=2&yAgent=11) | (xAgent=3&yAgent=1) | (xAgent=3&yAgent=2) | (xAgent=3&yAgent=3) | (xAgent=3&yAgent=4) | (xAgent=3&yAgent=5) | (xAgent=3&yAgent=6) | (xAgent=3&yAgent=7) | (xAgent=3&yAgent=8) | (xAgent=3&yAgent=9) | (xAgent=3&yAgent=10) | (xAgent=3&yAgent=11);
label BlueOnBlue = (xBlue=1&yBlue=1) | (xBlue=1&yBlue=2) | (xBlue=1&yBlue=3) | (xBlue=1&yBlue=6) | (xBlue=1&yBlue=7) | (xBlue=1&yBlue=8) | (xBlue=1&yBlue=9) | (xBlue=1&yBlue=10) | (xBlue=1&yBlue=11) | (xBlue=2&yBlue=1) | (xBlue=2&yBlue=11) | (xBlue=3&yBlue=1) | (xBlue=3&yBlue=2) | (xBlue=3&yBlue=3) | (xBlue=3&yBlue=4) | (xBlue=3&yBlue=5) | (xBlue=3&yBlue=6) | (xBlue=3&yBlue=7) | (xBlue=3&yBlue=8) | (xBlue=3&yBlue=9) | (xBlue=3&yBlue=10) | (xBlue=3&yBlue=11);
label GreenOnBlue = (xGreen=1&yGreen=1) | (xGreen=1&yGreen=2) | (xGreen=1&yGreen=3) | (xGreen=1&yGreen=6) | (xGreen=1&yGreen=7) | (xGreen=1&yGreen=8) | (xGreen=1&yGreen=9) | (xGreen=1&yGreen=10) | (xGreen=1&yGreen=11) | (xGreen=2&yGreen=1) | (xGreen=2&yGreen=11) | (xGreen=3&yGreen=1) | (xGreen=3&yGreen=2) | (xGreen=3&yGreen=3) | (xGreen=3&yGreen=4) | (xGreen=3&yGreen=5) | (xGreen=3&yGreen=6) | (xGreen=3&yGreen=7) | (xGreen=3&yGreen=8) | (xGreen=3&yGreen=9) | (xGreen=3&yGreen=10) | (xGreen=3&yGreen=11);
label AgentOnGreen = (xAgent=9&yAgent=1) | (xAgent=9&yAgent=2) | (xAgent=9&yAgent=3) | (xAgent=9&yAgent=4) | (xAgent=9&yAgent=5) | (xAgent=9&yAgent=6) | (xAgent=9&yAgent=7) | (xAgent=9&yAgent=8) | (xAgent=9&yAgent=9) | (xAgent=9&yAgent=10) | (xAgent=9&yAgent=11) | (xAgent=10&yAgent=1) | (xAgent=10&yAgent=11) | (xAgent=11&yAgent=1) | (xAgent=11&yAgent=2) | (xAgent=11&yAgent=3) | (xAgent=11&yAgent=4) | (xAgent=11&yAgent=5) | (xAgent=11&yAgent=6) | (xAgent=11&yAgent=7) | (xAgent=11&yAgent=8) | (xAgent=11&yAgent=9) | (xAgent=11&yAgent=10) | (xAgent=11&yAgent=11);
label BlueOnGreen = (xBlue=9&yBlue=1) | (xBlue=9&yBlue=2) | (xBlue=9&yBlue=3) | (xBlue=9&yBlue=4) | (xBlue=9&yBlue=5) | (xBlue=9&yBlue=6) | (xBlue=9&yBlue=7) | (xBlue=9&yBlue=8) | (xBlue=9&yBlue=9) | (xBlue=9&yBlue=10) | (xBlue=9&yBlue=11) | (xBlue=10&yBlue=1) | (xBlue=10&yBlue=11) | (xBlue=11&yBlue=1) | (xBlue=11&yBlue=2) | (xBlue=11&yBlue=3) | (xBlue=11&yBlue=4) | (xBlue=11&yBlue=5) | (xBlue=11&yBlue=6) | (xBlue=11&yBlue=7) | (xBlue=11&yBlue=8) | (xBlue=11&yBlue=9) | (xBlue=11&yBlue=10) | (xBlue=11&yBlue=11);
label GreenOnGreen = (xGreen=9&yGreen=1) | (xGreen=9&yGreen=2) | (xGreen=9&yGreen=3) | (xGreen=9&yGreen=4) | (xGreen=9&yGreen=5) | (xGreen=9&yGreen=6) | (xGreen=9&yGreen=7) | (xGreen=9&yGreen=8) | (xGreen=9&yGreen=9) | (xGreen=9&yGreen=10) | (xGreen=9&yGreen=11) | (xGreen=10&yGreen=1) | (xGreen=10&yGreen=11) | (xGreen=11&yGreen=1) | (xGreen=11&yGreen=2) | (xGreen=11&yGreen=3) | (xGreen=11&yGreen=4) | (xGreen=11&yGreen=5) | (xGreen=11&yGreen=6) | (xGreen=11&yGreen=7) | (xGreen=11&yGreen=8) | (xGreen=11&yGreen=9) | (xGreen=11&yGreen=10) | (xGreen=11&yGreen=11);
label AgentOnRed = (xAgent=1&yAgent=4) | (xAgent=1&yAgent=5);
label BlueOnRed = (xBlue=1&yBlue=4) | (xBlue=1&yBlue=5);
label GreenOnRed = (xGreen=1&yGreen=4) | (xGreen=1&yGreen=5);
formula AgentCannotMoveNorth = (xAgent=1&yAgent=2) | (xAgent=1&yAgent=3) | (xAgent=1&yAgent=4) | (xAgent=1&yAgent=5) | (xAgent=1&yAgent=6) | (xAgent=1&yAgent=7) | (xAgent=1&yAgent=8) | (xAgent=1&yAgent=9) | (xAgent=1&yAgent=10) | (xAgent=1&yAgent=11) | (xAgent=3&yAgent=2) | (xAgent=3&yAgent=3) | (xAgent=3&yAgent=4) | (xAgent=3&yAgent=5) | (xAgent=3&yAgent=6) | (xAgent=3&yAgent=7) | (xAgent=3&yAgent=8) | (xAgent=3&yAgent=9) | (xAgent=3&yAgent=10) | (xAgent=11&yAgent=2) | (xAgent=11&yAgent=3) | (xAgent=11&yAgent=4) | (xAgent=11&yAgent=5) | (xAgent=11&yAgent=6) | (xAgent=11&yAgent=7) | (xAgent=11&yAgent=8) | (xAgent=11&yAgent=9) | (xAgent=11&yAgent=10) | (xAgent=1&yAgent=1);
formula AgentCannotMoveEast = (xAgent=1&yAgent=11) | (xAgent=2&yAgent=1) | (xAgent=2&yAgent=11) | (xAgent=3&yAgent=11) | (xAgent=4&yAgent=11) | (xAgent=5&yAgent=11) | (xAgent=6&yAgent=11) | (xAgent=8&yAgent=11) | (xAgent=9&yAgent=11) | (xAgent=10&yAgent=1) | (xAgent=10&yAgent=11) | (xAgent=11&yAgent=11) | (xAgent=7&yAgent=11);
formula AgentCannotMoveSouth = (xAgent=1&yAgent=2) | (xAgent=1&yAgent=3) | (xAgent=1&yAgent=4) | (xAgent=1&yAgent=5) | (xAgent=1&yAgent=6) | (xAgent=1&yAgent=7) | (xAgent=1&yAgent=8) | (xAgent=1&yAgent=9) | (xAgent=1&yAgent=10) | (xAgent=9&yAgent=2) | (xAgent=9&yAgent=3) | (xAgent=9&yAgent=4) | (xAgent=9&yAgent=5) | (xAgent=9&yAgent=6) | (xAgent=9&yAgent=7) | (xAgent=9&yAgent=8) | (xAgent=9&yAgent=9) | (xAgent=9&yAgent=10) | (xAgent=11&yAgent=1) | (xAgent=11&yAgent=2) | (xAgent=11&yAgent=3) | (xAgent=11&yAgent=4) | (xAgent=11&yAgent=5) | (xAgent=11&yAgent=6) | (xAgent=11&yAgent=7) | (xAgent=11&yAgent=8) | (xAgent=11&yAgent=9) | (xAgent=11&yAgent=10) | (xAgent=11&yAgent=11);
formula AgentCannotMoveWest = (xAgent=2&yAgent=1) | (xAgent=2&yAgent=11) | (xAgent=3&yAgent=1) | (xAgent=5&yAgent=1) | (xAgent=6&yAgent=1) | (xAgent=7&yAgent=1) | (xAgent=8&yAgent=1) | (xAgent=9&yAgent=1) | (xAgent=10&yAgent=1) | (xAgent=10&yAgent=11) | (xAgent=11&yAgent=1) | (xAgent=1&yAgent=1) | (xAgent=4&yAgent=1);
formula AgentIsOnSlippery = false;
label AgentGoal = false;
formula BlueCannotMoveNorth = (xBlue=1&yBlue=2) | (xBlue=1&yBlue=3) | (xBlue=1&yBlue=4) | (xBlue=1&yBlue=5) | (xBlue=1&yBlue=6) | (xBlue=1&yBlue=7) | (xBlue=1&yBlue=8) | (xBlue=1&yBlue=9) | (xBlue=1&yBlue=10) | (xBlue=1&yBlue=11) | (xBlue=3&yBlue=2) | (xBlue=3&yBlue=3) | (xBlue=3&yBlue=4) | (xBlue=3&yBlue=5) | (xBlue=3&yBlue=6) | (xBlue=3&yBlue=7) | (xBlue=3&yBlue=8) | (xBlue=3&yBlue=9) | (xBlue=3&yBlue=10) | (xBlue=11&yBlue=2) | (xBlue=11&yBlue=3) | (xBlue=11&yBlue=4) | (xBlue=11&yBlue=5) | (xBlue=11&yBlue=6) | (xBlue=11&yBlue=7) | (xBlue=11&yBlue=8) | (xBlue=11&yBlue=9) | (xBlue=11&yBlue=10) | (xBlue=1&yBlue=1);
formula BlueCannotMoveEast = (xBlue=1&yBlue=11) | (xBlue=2&yBlue=1) | (xBlue=2&yBlue=11) | (xBlue=3&yBlue=11) | (xBlue=4&yBlue=11) | (xBlue=5&yBlue=11) | (xBlue=6&yBlue=11) | (xBlue=8&yBlue=11) | (xBlue=9&yBlue=11) | (xBlue=10&yBlue=1) | (xBlue=10&yBlue=11) | (xBlue=11&yBlue=11) | (xBlue=7&yBlue=11);
formula BlueCannotMoveSouth = (xBlue=1&yBlue=2) | (xBlue=1&yBlue=3) | (xBlue=1&yBlue=4) | (xBlue=1&yBlue=5) | (xBlue=1&yBlue=6) | (xBlue=1&yBlue=7) | (xBlue=1&yBlue=8) | (xBlue=1&yBlue=9) | (xBlue=1&yBlue=10) | (xBlue=9&yBlue=2) | (xBlue=9&yBlue=3) | (xBlue=9&yBlue=4) | (xBlue=9&yBlue=5) | (xBlue=9&yBlue=6) | (xBlue=9&yBlue=7) | (xBlue=9&yBlue=8) | (xBlue=9&yBlue=9) | (xBlue=9&yBlue=10) | (xBlue=11&yBlue=1) | (xBlue=11&yBlue=2) | (xBlue=11&yBlue=3) | (xBlue=11&yBlue=4) | (xBlue=11&yBlue=5) | (xBlue=11&yBlue=6) | (xBlue=11&yBlue=7) | (xBlue=11&yBlue=8) | (xBlue=11&yBlue=9) | (xBlue=11&yBlue=10) | (xBlue=11&yBlue=11);
formula BlueCannotMoveWest = (xBlue=2&yBlue=1) | (xBlue=2&yBlue=11) | (xBlue=3&yBlue=1) | (xBlue=5&yBlue=1) | (xBlue=6&yBlue=1) | (xBlue=7&yBlue=1) | (xBlue=8&yBlue=1) | (xBlue=9&yBlue=1) | (xBlue=10&yBlue=1) | (xBlue=10&yBlue=11) | (xBlue=11&yBlue=1) | (xBlue=1&yBlue=1) | (xBlue=4&yBlue=1);
formula BlueIsOnSlippery = false;
label BlueGoal = false;
formula GreenCannotMoveNorth = (xGreen=1&yGreen=2) | (xGreen=1&yGreen=3) | (xGreen=1&yGreen=4) | (xGreen=1&yGreen=5) | (xGreen=1&yGreen=6) | (xGreen=1&yGreen=7) | (xGreen=1&yGreen=8) | (xGreen=1&yGreen=9) | (xGreen=1&yGreen=10) | (xGreen=1&yGreen=11) | (xGreen=3&yGreen=2) | (xGreen=3&yGreen=3) | (xGreen=3&yGreen=4) | (xGreen=3&yGreen=5) | (xGreen=3&yGreen=6) | (xGreen=3&yGreen=7) | (xGreen=3&yGreen=8) | (xGreen=3&yGreen=9) | (xGreen=3&yGreen=10) | (xGreen=11&yGreen=2) | (xGreen=11&yGreen=3) | (xGreen=11&yGreen=4) | (xGreen=11&yGreen=5) | (xGreen=11&yGreen=6) | (xGreen=11&yGreen=7) | (xGreen=11&yGreen=8) | (xGreen=11&yGreen=9) | (xGreen=11&yGreen=10) | (xGreen=1&yGreen=1);
formula GreenCannotMoveEast = (xGreen=1&yGreen=11) | (xGreen=2&yGreen=1) | (xGreen=2&yGreen=11) | (xGreen=3&yGreen=11) | (xGreen=4&yGreen=11) | (xGreen=5&yGreen=11) | (xGreen=6&yGreen=11) | (xGreen=8&yGreen=11) | (xGreen=9&yGreen=11) | (xGreen=10&yGreen=1) | (xGreen=10&yGreen=11) | (xGreen=11&yGreen=11) | (xGreen=7&yGreen=11);
formula GreenCannotMoveSouth = (xGreen=1&yGreen=2) | (xGreen=1&yGreen=3) | (xGreen=1&yGreen=4) | (xGreen=1&yGreen=5) | (xGreen=1&yGreen=6) | (xGreen=1&yGreen=7) | (xGreen=1&yGreen=8) | (xGreen=1&yGreen=9) | (xGreen=1&yGreen=10) | (xGreen=9&yGreen=2) | (xGreen=9&yGreen=3) | (xGreen=9&yGreen=4) | (xGreen=9&yGreen=5) | (xGreen=9&yGreen=6) | (xGreen=9&yGreen=7) | (xGreen=9&yGreen=8) | (xGreen=9&yGreen=9) | (xGreen=9&yGreen=10) | (xGreen=11&yGreen=1) | (xGreen=11&yGreen=2) | (xGreen=11&yGreen=3) | (xGreen=11&yGreen=4) | (xGreen=11&yGreen=5) | (xGreen=11&yGreen=6) | (xGreen=11&yGreen=7) | (xGreen=11&yGreen=8) | (xGreen=11&yGreen=9) | (xGreen=11&yGreen=10) | (xGreen=11&yGreen=11);
formula GreenCannotMoveWest = (xGreen=2&yGreen=1) | (xGreen=2&yGreen=11) | (xGreen=3&yGreen=1) | (xGreen=5&yGreen=1) | (xGreen=6&yGreen=1) | (xGreen=7&yGreen=1) | (xGreen=8&yGreen=1) | (xGreen=9&yGreen=1) | (xGreen=10&yGreen=1) | (xGreen=10&yGreen=11) | (xGreen=11&yGreen=1) | (xGreen=1&yGreen=1) | (xGreen=4&yGreen=1);
formula GreenIsOnSlippery = false;
label GreenGoal = false;
label crash = (xAgent=xBlue)&(yAgent=yBlue) | (xAgent=xGreen)&(yAgent=yGreen);
module Agent
xAgent : [1..12] init 1;
yAgent : [1..12] init 1;
[Agent_turns] move=0 & true -> (xAgent'=xAgent) & (move'=1) ;
[Agent_move_north] move=0 & !AgentIsOnSlippery & !AgentCannotMoveNorth -> (xAgent'=xAgent-1) & (move'=1) ;
[Agent_move_east] move=0 & !AgentIsOnSlippery & !AgentCannotMoveEast -> (yAgent'=yAgent+1) & (move'=1) ;
[Agent_move_south] move=0 & !AgentIsOnSlippery & !AgentCannotMoveSouth -> (xAgent'=xAgent+1) & (move'=1) ;
[Agent_move_west] move=0 & !AgentIsOnSlippery & !AgentCannotMoveWest -> (yAgent'=yAgent-1) & (move'=1) ;
endmodule
module Blue
xBlue : [1..12] init 7;
yBlue : [1..12] init 11;
[Blue_turns] move=1 & true -> (xBlue'=xBlue) & (move'=2) ;
[Blue_move_north] move=1 & !BlueIsOnSlippery & !BlueCannotMoveNorth -> (xBlue'=xBlue-1) & (move'=2) ;
[Blue_move_east] move=1 & !BlueIsOnSlippery & !BlueCannotMoveEast -> (yBlue'=yBlue+1) & (move'=2) ;
[Blue_move_south] move=1 & !BlueIsOnSlippery & !BlueCannotMoveSouth -> (xBlue'=xBlue+1) & (move'=2) ;
[Blue_move_west] move=1 & !BlueIsOnSlippery & !BlueCannotMoveWest -> (yBlue'=yBlue-1) & (move'=2) ;
endmodule
module Green
xGreen : [1..12] init 4;
yGreen : [1..12] init 1;
[Green_turns] move=2 & true -> (xGreen'=xGreen) & (move'=0) ;
[Green_move_north] move=2 & !GreenIsOnSlippery & !GreenCannotMoveNorth -> (xGreen'=xGreen-1) & (move'=0) ;
[Green_move_east] move=2 & !GreenIsOnSlippery & !GreenCannotMoveEast -> (yGreen'=yGreen+1) & (move'=0) ;
[Green_move_south] move=2 & !GreenIsOnSlippery & !GreenCannotMoveSouth -> (xGreen'=xGreen+1) & (move'=0) ;
[Green_move_west] move=2 & !GreenIsOnSlippery & !GreenCannotMoveWest -> (yGreen'=yGreen-1) & (move'=0) ;
endmodule

20
Minigrid2PRISM/prop

@ -0,0 +1,20 @@
<eventually1 , PreSafety, gamma=0.8> Pmax=? [ F<1 "picked_up_blue_key" ];
<eventually2 , PreSafety, gamma=0.8> Pmax=? [ F<2 "picked_up_blue_key" ];
<eventually3 , PreSafety, gamma=0.8> Pmax=? [ F<3 "picked_up_blue_key" ];
<eventually4 , PreSafety, gamma=0.8> Pmax=? [ F<4 "picked_up_blue_key" ];
<eventually5 , PreSafety, gamma=0.8> Pmax=? [ F<5 "picked_up_blue_key" ];
<eventually6 , PreSafety, gamma=0.8> Pmax=? [ F<6 "picked_up_blue_key" ];
<eventually7 , PreSafety, gamma=0.8> Pmax=? [ F<7 "picked_up_blue_key" ];
<eventually8 , PreSafety, gamma=0.8> Pmax=? [ F<8 "picked_up_blue_key" ];
<eventually9 , PreSafety, gamma=0.8> Pmax=? [ F<9 "picked_up_blue_key" ];
<eventually10, PreSafety, gamma=0.8> Pmax=? [ F<10 "picked_up_blue_key" ];
<eventually11, PreSafety, gamma=0.8> Pmax=? [ F<11 "picked_up_blue_key" ];
<eventually12, PreSafety, gamma=0.8> Pmax=? [ F<12 "picked_up_blue_key" ];
<eventually13, PreSafety, gamma=0.8> Pmax=? [ F<13 "picked_up_blue_key" ];
<eventually14, PreSafety, gamma=0.8> Pmax=? [ F<14 "picked_up_blue_key" ];
<eventually15, PreSafety, gamma=0.8> Pmax=? [ F<15 "picked_up_blue_key" ];
<eventually16, PreSafety, gamma=0.8> Pmax=? [ F<16 "picked_up_blue_key" ];
<eventually17, PreSafety, gamma=0.8> Pmax=? [ F<17 "picked_up_blue_key" ];
<eventually18, PreSafety, gamma=0.8> Pmax=? [ F<18 "picked_up_blue_key" ];
<eventually19, PreSafety, gamma=0.8> Pmax=? [ F<19 "picked_up_blue_key" ];
<eventually20, PreSafety, gamma=0.8> Pmax=? [ F<20 "picked_up_blue_key" ];

2
Minigrid2PRISM/property.prism

@ -0,0 +1,2 @@
concat(<Test, PreSafety, lambda=0.89> <<Blue>> Pmax=? [ G !"BlueOnBlue" ], <Test, PreSafety, lambda=0.89> <<Agent>> Pmax=? [G<10 !"crash" ] );
//<Test, PreSafety, lambda=0.89> <<one>> Pmax=? [G !"crash" ];

11
Minigrid2PRISM/smallerGrid

@ -0,0 +1,11 @@
WGWGWGWGWGWGWG
WGXR WG
WG WGWGWG WG
WG WG
WGZG WG
WG BBBG WG
WG BR ZBWG
WG WG
WG WGWGWG WG
WG WG
WGWGWGWGWGWGWG

486
Minigrid2PRISM/tags

@ -0,0 +1,486 @@
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.9~svn20110310 //
ARCHITECTURE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 432;" d file:
ARCHITECTURE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 435;" d file:
ARCHITECTURE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 438;" d file:
ARCHITECTURE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 441;" d file:
ARCHITECTURE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 445;" d file:
ARCHITECTURE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 447;" d file:
ARCHITECTURE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 449;" d file:
ARCHITECTURE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 453;" d file:
ARCHITECTURE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 456;" d file:
ARCHITECTURE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 459;" d file:
ARCHITECTURE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 464;" d file:
ARCHITECTURE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 467;" d file:
ARCHITECTURE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 470;" d file:
ARCHITECTURE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 475;" d file:
ARCHITECTURE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 478;" d file:
ARCHITECTURE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 481;" d file:
ARCHITECTURE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 484;" d file:
ARCHITECTURE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 487;" d file:
ARCHITECTURE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 490;" d file:
ARCHITECTURE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 493;" d file:
ARCHITECTURE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 496;" d file:
ARCHITECTURE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 499;" d file:
ARCHITECTURE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 502;" d file:
ARCHITECTURE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 507;" d file:
ARCHITECTURE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 510;" d file:
ARCHITECTURE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 513;" d file:
ARCHITECTURE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 516;" d file:
ARCHITECTURE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 519;" d file:
ARCHITECTURE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 522;" d file:
ARCHITECTURE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 525;" d file:
Adversary util/cell.h /^ Adversary = 'Z'$/;" m class:Type
Agent util/cell.h /^ Agent = 'X',$/;" m class:Type
AgentName util/PrismPrinter.h /^typedef std::string AgentName;$/;" t
AgentNameAndPosition util/PrismPrinter.h /^typedef std::pair<std::string, coordinates> AgentNameAndPosition;$/;" t
AgentNameAndPositionMap util/PrismPrinter.h /^typedef std::map<AgentNameAndPosition::first_type, AgentNameAndPosition::second_type> AgentNameAndPositionMap;$/;" t
Argument util/popl.hpp /^enum class Argument$/;" c namespace:popl
Attribute util/popl.hpp /^enum class Attribute$/;" c namespace:popl
Ball util/cell.h /^ Ball = 'A',$/;" m class:Type
BashCompletionOptionPrinter util/popl.hpp /^class BashCompletionOptionPrinter : public OptionPrinter$/;" c class:popl::Attribute
BashCompletionOptionPrinter util/popl.hpp /^inline BashCompletionOptionPrinter::BashCompletionOptionPrinter(const OptionParser* option_parser, std::string program_name)$/;" f class:popl::Attribute::BashCompletionOptionPrinter
Blue util/cell.h /^ Blue = 'B',$/;" m class:Type::Color
Box util/cell.h /^ Box = 'B',$/;" m class:Type
CMAKE_BINARY_DIR build/Makefile /^CMAKE_BINARY_DIR = \/home\/spranger\/research\/Minigrid2PRISM\/build$/;" m
CMAKE_COMMAND build/Makefile /^CMAKE_COMMAND = \/usr\/bin\/cmake$/;" m
CMAKE_SOURCE_DIR build/Makefile /^CMAKE_SOURCE_DIR = \/home\/spranger\/research\/Minigrid2PRISM$/;" m
COMPILER_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 108;" d file:
COMPILER_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 115;" d file:
COMPILER_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 122;" d file:
COMPILER_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 129;" d file:
COMPILER_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 137;" d file:
COMPILER_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 13;" d file:
COMPILER_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 144;" d file:
COMPILER_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 151;" d file:
COMPILER_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 159;" d file:
COMPILER_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 164;" d file:
COMPILER_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 171;" d file:
COMPILER_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 174;" d file:
COMPILER_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 183;" d file:
COMPILER_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 186;" d file:
COMPILER_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 19;" d file:
COMPILER_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 201;" d file:
COMPILER_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 216;" d file:
COMPILER_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 223;" d file:
COMPILER_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 237;" d file:
COMPILER_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 251;" d file:
COMPILER_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 269;" d file:
COMPILER_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 278;" d file:
COMPILER_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 296;" d file:
COMPILER_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 299;" d file:
COMPILER_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 56;" d file:
COMPILER_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 64;" d file:
COMPILER_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 70;" d file:
COMPILER_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 76;" d file:
COMPILER_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 85;" d file:
COMPILER_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 94;" d file:
COMPILER_VERSION_INTERNAL build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 220;" d file:
COMPILER_VERSION_INTERNAL build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 283;" d file:
COMPILER_VERSION_INTERNAL build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 288;" d file:
COMPILER_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 102;" d file:
COMPILER_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 110;" d file:
COMPILER_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 117;" d file:
COMPILER_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 124;" d file:
COMPILER_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 130;" d file:
COMPILER_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 139;" d file:
COMPILER_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 146;" d file:
COMPILER_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 152;" d file:
COMPILER_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 15;" d file:
COMPILER_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 160;" d file:
COMPILER_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 166;" d file:
COMPILER_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 177;" d file:
COMPILER_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 189;" d file:
COMPILER_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 194;" d file:
COMPILER_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 205;" d file:
COMPILER_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 217;" d file:
COMPILER_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 227;" d file:
COMPILER_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 239;" d file:
COMPILER_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 241;" d file:
COMPILER_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 253;" d file:
COMPILER_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 272;" d file:
COMPILER_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 27;" d file:
COMPILER_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 280;" d file:
COMPILER_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 285;" d file:
COMPILER_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 57;" d file:
COMPILER_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 65;" d file:
COMPILER_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 72;" d file:
COMPILER_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 78;" d file:
COMPILER_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 87;" d file:
COMPILER_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 97;" d file:
COMPILER_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 103;" d file:
COMPILER_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 111;" d file:
COMPILER_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 118;" d file:
COMPILER_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 125;" d file:
COMPILER_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 131;" d file:
COMPILER_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 140;" d file:
COMPILER_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 147;" d file:
COMPILER_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 153;" d file:
COMPILER_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 161;" d file:
COMPILER_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 167;" d file:
COMPILER_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 16;" d file:
COMPILER_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 178;" d file:
COMPILER_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 190;" d file:
COMPILER_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 195;" d file:
COMPILER_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 206;" d file:
COMPILER_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 218;" d file:
COMPILER_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 228;" d file:
COMPILER_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 244;" d file:
COMPILER_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 254;" d file:
COMPILER_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 273;" d file:
COMPILER_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 281;" d file:
COMPILER_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 286;" d file:
COMPILER_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 28;" d file:
COMPILER_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 58;" d file:
COMPILER_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 66;" d file:
COMPILER_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 73;" d file:
COMPILER_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 79;" d file:
COMPILER_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 88;" d file:
COMPILER_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 98;" d file:
COMPILER_VERSION_PATCH build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 104;" d file:
COMPILER_VERSION_PATCH build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 112;" d file:
COMPILER_VERSION_PATCH build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 119;" d file:
COMPILER_VERSION_PATCH build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 126;" d file:
COMPILER_VERSION_PATCH build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 132;" d file:
COMPILER_VERSION_PATCH build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 141;" d file:
COMPILER_VERSION_PATCH build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 148;" d file:
COMPILER_VERSION_PATCH build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 155;" d file:
COMPILER_VERSION_PATCH build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 168;" d file:
COMPILER_VERSION_PATCH build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 179;" d file:
COMPILER_VERSION_PATCH build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 191;" d file:
COMPILER_VERSION_PATCH build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 196;" d file:
COMPILER_VERSION_PATCH build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 207;" d file:
COMPILER_VERSION_PATCH build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 219;" d file:
COMPILER_VERSION_PATCH build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 229;" d file:
COMPILER_VERSION_PATCH build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 247;" d file:
COMPILER_VERSION_PATCH build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 258;" d file:
COMPILER_VERSION_PATCH build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 261;" d file:
COMPILER_VERSION_PATCH build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 274;" d file:
COMPILER_VERSION_PATCH build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 282;" d file:
COMPILER_VERSION_PATCH build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 287;" d file:
COMPILER_VERSION_PATCH build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 30;" d file:
COMPILER_VERSION_PATCH build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 32;" d file:
COMPILER_VERSION_PATCH build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 60;" d file:
COMPILER_VERSION_PATCH build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 67;" d file:
COMPILER_VERSION_PATCH build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 81;" d file:
COMPILER_VERSION_PATCH build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 90;" d file:
COMPILER_VERSION_PATCH build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 99;" d file:
COMPILER_VERSION_TWEAK build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 133;" d file:
COMPILER_VERSION_TWEAK build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 213;" d file:
COMPILER_VERSION_TWEAK build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 265;" d file:
COMPILER_VERSION_TWEAK build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 36;" d file:
CXX_STD build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 608;" d file:
CXX_STD build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 610;" d file:
CXX_STD build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 613;" d file:
CXX_STD build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 616;" d file:
CXX_STD build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 618;" d file:
Color util/cell.h /^enum class Color : char {$/;" c class:Type
ConsoleOptionPrinter util/popl.hpp /^class ConsoleOptionPrinter : public OptionPrinter$/;" c class:popl::Attribute
ConsoleOptionPrinter util/popl.hpp /^inline ConsoleOptionPrinter::ConsoleOptionPrinter(const OptionParser* option_parser) : OptionPrinter(option_parser)$/;" f class:popl::Attribute::ConsoleOptionPrinter
DEC build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 529;" d file:
Door util/cell.h /^ Door = 'D',$/;" m class:Type
EQUALS build/Makefile /^EQUALS = =$/;" m
Error util/popl.hpp /^ enum class Error$/;" c class:popl::Attribute::invalid_option
Floor util/cell.h /^ Floor = ' ',$/;" m class:Type
Goal util/cell.h /^ Goal = 'G',$/;" m class:Type
Green util/cell.h /^ Green = 'G',$/;" m class:Type::Color
Grid util/Grid.cpp /^Grid::Grid(cells gridCells, cells background) : allGridCells(gridCells), background(background) {$/;" f class:Grid
Grid util/Grid.h /^class Grid {$/;" c
GroffOptionPrinter util/popl.hpp /^class GroffOptionPrinter : public OptionPrinter$/;" c class:popl::Attribute
GroffOptionPrinter util/popl.hpp /^inline GroffOptionPrinter::GroffOptionPrinter(const OptionParser* option_parser) : OptionPrinter(option_parser)$/;" f class:popl::Attribute::GroffOptionPrinter
HEX build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 540;" d file:
INPUT_ERROR util/OptionParser.h 7;" d
INPUT_OK util/OptionParser.h 8;" d
Implicit util/popl.hpp /^class Implicit : public Value<T>$/;" c class:popl::Attribute
Implicit util/popl.hpp /^inline Implicit<T>::Implicit(const std::string& short_name, const std::string& long_name, const std::string& description, const T& implicit_val, T* assign_to)$/;" f class:popl::Attribute::Implicit
Key util/cell.h /^ Key = 'K',$/;" m class:Type
Lava util/cell.h /^ Lava = 'V',$/;" m class:Type
LockedDoor util/cell.h /^ LockedDoor = 'L',$/;" m class:Type
MDP util/PrismPrinter.h /^ MDP, SMG$/;" m class:prism::ModelType
MinigridParser util/MinigridGrammar.h /^ struct MinigridParser : qi::grammar<It, row()>$/;" s
MinigridParser util/MinigridGrammar.h /^ MinigridParser(It first) : MinigridParser::base_type(row_), annotate(first)$/;" f struct:MinigridParser
ModelType util/PrismPrinter.h /^ enum class ModelType {$/;" c namespace:prism
NOMINMAX util/popl.hpp 24;" d
None util/cell.h /^ None = ' '$/;" m class:Type::Color
Option util/popl.hpp /^class Option$/;" c class:popl::Attribute
Option util/popl.hpp /^inline Option::Option(const std::string& short_name, const std::string& long_name, std::string description)$/;" f class:popl::Attribute::Option
OptionName util/popl.hpp /^enum class OptionName$/;" c class:popl::Attribute
OptionParser util/popl.hpp /^class OptionParser$/;" c class:popl::Attribute
OptionParser util/popl.hpp /^inline OptionParser::OptionParser(std::string description) : description_(std::move(description))$/;" f class:popl::Attribute::OptionParser
OptionPrinter util/popl.hpp /^ explicit OptionPrinter(const OptionParser* option_parser) : option_parser_(option_parser)$/;" f class:popl::Attribute::OptionPrinter
OptionPrinter util/popl.hpp /^class OptionPrinter$/;" c class:popl::Attribute
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 324;" d file:
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 327;" d file:
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 330;" d file:
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 333;" d file:
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 336;" d file:
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 339;" d file:
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 342;" d file:
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 345;" d file:
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 348;" d file:
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 351;" d file:
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 354;" d file:
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 357;" d file:
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 360;" d file:
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 363;" d file:
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 366;" d file:
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 369;" d file:
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 372;" d file:
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 375;" d file:
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 378;" d file:
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 381;" d file:
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 384;" d file:
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 387;" d file:
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 390;" d file:
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 393;" d file:
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 397;" d file:
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 400;" d file:
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 403;" d file:
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 406;" d file:
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 409;" d file:
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 414;" d file:
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 417;" d file:
PLATFORM_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 421;" d file:
POPL_HPP util/popl.hpp 21;" d
POPL_VERSION util/popl.hpp 44;" d
PrismModulesPrinter util/PrismModulesPrinter.cpp /^ PrismModulesPrinter::PrismModulesPrinter(const ModelType &modelType, const size_t &numberOfPlayer, const bool addViewVariable)$/;" f class:prism::PrismModulesPrinter
PrismModulesPrinter util/PrismModulesPrinter.h /^ class PrismModulesPrinter {$/;" c namespace:prism
Purple util/cell.h /^ Purple = 'P',$/;" m class:Type::Color
RM build/Makefile /^RM = \/usr\/bin\/cmake -E remove -f$/;" m
Red util/cell.h /^ Red = 'R',$/;" m class:Type::Color
SHELL build/Makefile /^SHELL = \/bin\/sh$/;" m
SIMULATE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 203;" d file:
SIMULATE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 21;" d file:
SIMULATE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 225;" d file:
SIMULATE_ID build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 24;" d file:
SIMULATE_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 210;" d file:
SIMULATE_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 232;" d file:
SIMULATE_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 40;" d file:
SIMULATE_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 44;" d file:
SIMULATE_VERSION_MAJOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 46;" d file:
SIMULATE_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 211;" d file:
SIMULATE_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 233;" d file:
SIMULATE_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 41;" d file:
SIMULATE_VERSION_MINOR build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 49;" d file:
SIMULATE_VERSION_PATCH build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 52;" d file:
STRINGIFY build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 320;" d file:
STRINGIFY_HELPER build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp 319;" d file:
SUFFIXES build/Makefile /^SUFFIXES =$/;" m
Slippery util/cell.h /^ Slippery = 'S',$/;" m class:Type
Switch util/popl.hpp /^class Switch : public Value<bool>$/;" c class:popl::Attribute
Switch util/popl.hpp /^inline Switch::Switch(const std::string& short_name, const std::string& long_name, const std::string& description, bool* assign_to)$/;" f class:popl::Attribute::Switch
Type util/cell.h /^enum class Type : char {$/;" c
Value util/popl.hpp /^class Value : public Option$/;" c class:popl::Attribute
Value util/popl.hpp /^inline Value<T>::Value(const std::string& short_name, const std::string& long_name, const std::string& description)$/;" f class:popl::Attribute::Value
Value util/popl.hpp /^inline Value<T>::Value(const std::string& short_name, const std::string& long_name, const std::string& description, const T& default_val, T* assign_to)$/;" f class:popl::Attribute::Value
Wall util/cell.h /^ Wall = 'W',$/;" m class:Type
Yellow util/cell.h /^ Yellow = 'Y',$/;" m class:Type::Color
add util/popl.hpp /^inline std::shared_ptr<T> OptionParser::add(Ts&&... params)$/;" f class:popl::Attribute::OptionParser
addViewVariable util/PrismModulesPrinter.h /^ bool const addViewVariable = false;$/;" m class:prism::PrismModulesPrinter
add_value util/popl.hpp /^inline void Value<T>::add_value(const T& value)$/;" f class:popl::Attribute::Value
advanced util/popl.hpp /^ advanced = 4,$/;" m class:popl::Attribute
adversaries util/Grid.h /^ cells adversaries;$/;" m class:Grid
agent util/Grid.h /^ cell agent;$/;" m class:Grid
agentNameAndPositionMap util/Grid.h /^ AgentNameAndPositionMap agentNameAndPositionMap;$/;" m class:Grid
allColors util/cell.h /^constexpr std::initializer_list<Color> allColors = {Color::Red, Color::Green, Color::Blue, Color::Purple, Color::Yellow};$/;" m class:Type::Color
allGridCells util/Grid.h /^ cells allGridCells;$/;" m class:Grid
annotate util/MinigridGrammar.h /^ phoenix::function<annotation_f<It>> annotate;$/;" m struct:MinigridParser
annotation_f util/MinigridGrammar.h /^ annotation_f(It first) : first(first) {}$/;" f struct:annotation_f
annotation_f util/MinigridGrammar.h /^struct annotation_f {$/;" s
argument_type util/popl.hpp /^inline Argument Implicit<T>::argument_type() const$/;" f class:popl::Attribute::Implicit
argument_type util/popl.hpp /^inline Argument Switch::argument_type() const$/;" f class:popl::Attribute::Switch
argument_type util/popl.hpp /^inline Argument Value<T>::argument_type() const$/;" f class:popl::Attribute::Value
assign_to util/popl.hpp /^inline void Value<T>::assign_to(T* var)$/;" f class:popl::Attribute::Value
assign_to_ util/popl.hpp /^ T* assign_to_;$/;" m class:popl::Attribute::Value
attribute util/popl.hpp /^inline Attribute Option::attribute() const$/;" f class:popl::Attribute::Option
attribute_ util/popl.hpp /^ Attribute attribute_;$/;" m class:popl::Attribute::Option
background util/Grid.h /^ cells background;$/;" m class:Grid
backgroundTiles util/Grid.h /^ std::map<Color, cells> backgroundTiles;$/;" m class:Grid
boxes util/Grid.h /^ cells boxes;$/;" m class:Grid
cell util/cell.h /^class cell {$/;" c class:Type::Color
cell_ util/MinigridGrammar.h /^ qi::rule<It, cell()> cell_;$/;" m struct:MinigridParser
cells util/MinigridGrammar.h /^typedef std::vector<cell> cells;$/;" t
checkOption util/OptionParser.cpp /^ int checkOption(const int input_filename_count) {$/;" f namespace:io
clear util/popl.hpp /^inline void Value<T>::clear()$/;" f class:popl::Attribute::Value
color util/cell.h /^ Color color;$/;" m class:Type::Color::cell
color_ util/MinigridGrammar.h /^ qi::symbols<char, Color> color_;$/;" m struct:MinigridParser
column util/cell.h /^ int column;$/;" m class:Type::Color::cell
coordinates util/cell.h /^typedef std::pair<int, int> coordinates;$/;" t
count util/popl.hpp /^inline size_t Value<T>::count() const$/;" f class:popl::Attribute::Value
default_ util/popl.hpp /^ std::unique_ptr<T> default_;$/;" m class:popl::Attribute::Value
description util/popl.hpp /^inline std::string Option::description() const$/;" f class:popl::Attribute::Option
description util/popl.hpp /^inline std::string OptionParser::description() const$/;" f class:popl::Attribute::OptionParser
description_ util/popl.hpp /^ std::string description_;$/;" m class:popl::Attribute::Option
description_ util/popl.hpp /^ std::string description_;$/;" m class:popl::Attribute::OptionParser
do_annotate util/MinigridGrammar.h /^ static void do_annotate(...) { std::cerr << "(not having LocationInfo)\\n"; }$/;" f struct:annotation_f
do_annotate util/MinigridGrammar.h /^ void static do_annotate(cell& c, It f, It l, It first) {$/;" f struct:annotation_f
element main.cpp /^ void element(string const& tag, string const& value, int depth) const {$/;" f struct:printer
error util/popl.hpp /^ Error error() const$/;" f class:popl::Attribute::invalid_option
error_ util/popl.hpp /^ Error error_;$/;" m class:popl::Attribute::invalid_option
expert util/popl.hpp /^ expert = 5$/;" m class:popl::Attribute
find_option util/popl.hpp /^inline Option_ptr OptionParser::find_option(char short_name) const$/;" f class:popl::Attribute::OptionParser
find_option util/popl.hpp /^inline Option_ptr OptionParser::find_option(const std::string& long_name) const$/;" f class:popl::Attribute::OptionParser
first util/MinigridGrammar.h /^ It const first;$/;" m struct:annotation_f
floor util/Grid.h /^ cells floor;$/;" m class:Grid
getColor util/cell.cpp /^std::string cell::getColor() const {$/;" f class:cell
getColor util/cell.cpp /^std::string getColor(Color color) {$/;" f
getCoordinates util/cell.cpp /^coordinates cell::getCoordinates() const {$/;" f class:cell
getEast util/cell.cpp /^cell cell::getEast(const std::vector<cell> &grid) const {$/;" f class:cell
getEast util/cell.h /^ coordinates getEast() const { return std::make_pair(row, column + 1); }$/;" f class:Type::Color::cell
getGridCells util/Grid.cpp /^cells Grid::getGridCells() {$/;" f class:Grid
getNorth util/cell.cpp /^cell cell::getNorth(const std::vector<cell> &grid) const {$/;" f class:cell
getNorth util/cell.h /^ coordinates getNorth() const { return std::make_pair(row - 1, column); }$/;" f class:Type::Color::cell
getSouth util/cell.cpp /^cell cell::getSouth(const std::vector<cell> &grid) const {$/;" f class:cell
getSouth util/cell.h /^ coordinates getSouth() const { return std::make_pair(row + 1, column); }$/;" f class:Type::Color::cell
getWest util/cell.cpp /^cell cell::getWest(const std::vector<cell> &grid) const {$/;" f class:cell
getWest util/cell.h /^ coordinates getWest() const { return std::make_pair(row, column - 1); }$/;" f class:Type::Color::cell
get_default util/popl.hpp /^inline T Value<T>::get_default() const$/;" f class:popl::Attribute::Value
get_default util/popl.hpp /^inline bool Value<T>::get_default(std::ostream& out) const$/;" f class:popl::Attribute::Value
get_option util/popl.hpp /^inline std::shared_ptr<T> OptionParser::get_option(char short_name) const$/;" f class:popl::Attribute::OptionParser
get_option util/popl.hpp /^inline std::shared_ptr<T> OptionParser::get_option(const std::string& long_name) const$/;" f class:popl::Attribute::OptionParser
goals util/Grid.h /^ cells goals;$/;" m class:Grid
has_default util/popl.hpp /^inline bool Value<T>::has_default() const$/;" f class:popl::Attribute::Value
help util/popl.hpp /^inline std::string OptionParser::help(const Attribute& max_attribute) const$/;" f class:popl::Attribute::OptionParser
hidden util/popl.hpp /^ hidden = 1,$/;" m class:popl::Attribute
inactive util/popl.hpp /^ inactive = 0,$/;" m class:popl::Attribute
info_arch build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp /^char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]";$/;" v
info_compiler build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp /^char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";$/;" v
info_cray build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp /^char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]";$/;" v
info_language_dialect_default build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp /^const char* info_language_dialect_default = "INFO" ":" "dialect_default["$/;" v
info_platform build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp /^char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]";$/;" v
info_simulate build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp /^char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]";$/;" v
info_simulate_version build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp /^char const info_simulate_version[] = {$/;" v
info_version build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp /^char const info_version[] = {$/;" v
info_version_internal build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp /^char const info_version_internal[] = {$/;" v
invalid_argument util/popl.hpp /^ invalid_argument,$/;" m class:popl::Attribute::invalid_option::Error
invalid_option util/popl.hpp /^ invalid_option(const Option* option, invalid_option::Error error, OptionName what_name, std::string value, const std::string& text)$/;" f class:popl::Attribute::invalid_option
invalid_option util/popl.hpp /^ invalid_option(const Option* option, invalid_option::Error error, const std::string& text)$/;" f class:popl::Attribute::invalid_option
invalid_option util/popl.hpp /^class invalid_option : public std::invalid_argument$/;" c class:popl::Attribute
io util/OptionParser.cpp /^namespace io {$/;" n file:
io util/OptionParser.h /^namespace io {$/;" n
isBlocked util/Grid.cpp /^bool Grid::isBlocked(coordinates p) {$/;" f class:Grid
isBox util/Grid.cpp /^bool Grid::isBox(coordinates p) {$/;" f class:Grid
isGame util/PrismModulesPrinter.cpp /^ bool PrismModulesPrinter::isGame() const {$/;" f class:prism::PrismModulesPrinter
isKey util/Grid.cpp /^bool Grid::isKey(coordinates p) {$/;" f class:Grid
isLockedDoor util/Grid.cpp /^bool Grid::isLockedDoor(coordinates p) {$/;" f class:Grid
isWall util/Grid.cpp /^bool Grid::isWall(coordinates p) {$/;" f class:Grid
is_set util/popl.hpp /^inline bool Value<T>::is_set() const$/;" f class:popl::Attribute::Value
keys util/Grid.h /^ cells keys;$/;" m class:Grid
lockedDoors util/Grid.h /^ cells lockedDoors;$/;" m class:Grid
long_name util/popl.hpp /^inline std::string Option::long_name() const$/;" f class:popl::Attribute::Option
long_name_ util/popl.hpp /^ std::string long_name_;$/;" m class:popl::Attribute::Option
main build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp /^int main(int argc, char* argv[])$/;" f
main main.cpp /^int main() {$/;" f
maxBoundaries util/Grid.h /^ coordinates maxBoundaries;$/;" m class:Grid
missing_argument util/popl.hpp /^ missing_argument,$/;" m class:popl::Attribute::invalid_option::Error
modelType util/PrismModulesPrinter.h /^ ModelType const& modelType;$/;" m class:prism::PrismModulesPrinter
moveGuard util/PrismModulesPrinter.cpp /^ std::string PrismModulesPrinter::moveGuard(const size_t &agentIndex) {$/;" f class:prism::PrismModulesPrinter
moveUpdate util/PrismModulesPrinter.cpp /^ std::string PrismModulesPrinter::moveUpdate(const size_t &agentIndex) {$/;" f class:prism::PrismModulesPrinter
name util/popl.hpp /^inline std::string Option::name(OptionName what_name, bool with_hypen) const$/;" f class:popl::Attribute::Option
no util/popl.hpp /^ no = 0, \/\/ option never takes an argument$/;" m class:popl::Argument
non_option_args util/popl.hpp /^inline const std::vector<std::string>& OptionParser::non_option_args() const$/;" f class:popl::Attribute::OptionParser
non_option_args_ util/popl.hpp /^ std::vector<std::string> non_option_args_;$/;" m class:popl::Attribute::OptionParser
numberOfPlayer util/PrismModulesPrinter.h /^ const size_t numberOfPlayer;$/;" m class:prism::PrismModulesPrinter
operator () util/MinigridGrammar.h /^ void operator()(Val& v, First f, Last l) const {$/;" f struct:annotation_f
operator << util/Grid.cpp /^std::ostream& operator<<(std::ostream& os, const Grid& grid) {$/;" f
operator << util/cell.cpp /^std::ostream &operator<<(std::ostream &os, const cell &c) {$/;" f
operator << util/popl.hpp /^static inline std::ostream& operator<<(std::ostream& out, const OptionParser& op)$/;" f class:popl::Attribute
option util/popl.hpp /^ const Option* option() const$/;" f class:popl::Attribute::invalid_option
option_ util/popl.hpp /^ const Option* option_;$/;" m class:popl::Attribute::invalid_option
option_parser_ util/popl.hpp /^ const OptionParser* option_parser_;$/;" m class:popl::Attribute::OptionPrinter
optional util/popl.hpp /^ optional = 3,$/;" m class:popl::Attribute
options util/popl.hpp /^inline const std::vector<Option_ptr>& OptionParser::options() const$/;" f class:popl::Attribute::OptionParser
options_ util/popl.hpp /^ std::vector<Option_ptr> options_;$/;" m class:popl::Attribute::OptionParser
override util/popl.hpp /^ Argument argument_type() const override;$/;" m class:popl::Attribute::Implicit
override util/popl.hpp /^ Argument argument_type() const override;$/;" m class:popl::Attribute::Switch
override util/popl.hpp /^ Argument argument_type() const override;$/;" m class:popl::Attribute::Value
override util/popl.hpp /^ bool get_default(std::ostream& out) const override;$/;" m class:popl::Attribute::Value
override util/popl.hpp /^ bool is_set() const override;$/;" m class:popl::Attribute::Value
override util/popl.hpp /^ size_t count() const override;$/;" m class:popl::Attribute::Value
override util/popl.hpp /^ std::string print(const Attribute& max_attribute = Attribute::optional) const override;$/;" m class:popl::Attribute::BashCompletionOptionPrinter
override util/popl.hpp /^ std::string print(const Attribute& max_attribute = Attribute::optional) const override;$/;" m class:popl::Attribute::ConsoleOptionPrinter
override util/popl.hpp /^ std::string print(const Attribute& max_attribute = Attribute::optional) const override;$/;" m class:popl::Attribute::GroffOptionPrinter
override util/popl.hpp /^ void clear() override;$/;" m class:popl::Attribute::Value
override util/popl.hpp /^ void parse(OptionName what_name, const char* value) override;$/;" m class:popl::Attribute::Implicit
override util/popl.hpp /^ void parse(OptionName what_name, const char* value) override;$/;" m class:popl::Attribute::Switch
override util/popl.hpp /^ void parse(OptionName what_name, const char* value) override;$/;" m class:popl::Attribute::Value
override util/popl.hpp /^ ~BashCompletionOptionPrinter() override = default;$/;" m class:popl::Attribute::BashCompletionOptionPrinter
override util/popl.hpp /^ ~ConsoleOptionPrinter() override = default;$/;" m class:popl::Attribute::ConsoleOptionPrinter
override util/popl.hpp /^ ~GroffOptionPrinter() override = default;$/;" m class:popl::Attribute::GroffOptionPrinter
parse util/popl.hpp /^inline void Implicit<T>::parse(OptionName what_name, const char* value)$/;" f class:popl::Attribute::Implicit
parse util/popl.hpp /^inline void OptionParser::parse(const std::string& ini_filename)$/;" f class:popl::Attribute::OptionParser
parse util/popl.hpp /^inline void OptionParser::parse(int argc, const char* const argv[])$/;" f class:popl::Attribute::OptionParser
parse util/popl.hpp /^inline void Switch::parse(OptionName \/*what_name*\/, const char* \/*value*\/)$/;" f class:popl::Attribute::Switch
parse util/popl.hpp /^inline void Value<T>::parse(OptionName what_name, const char* value)$/;" f class:popl::Attribute::Value
parse util/popl.hpp /^inline void Value<bool>::parse(OptionName \/*what_name*\/, const char* value)$/;" f class:popl::Attribute::Value
parse util/popl.hpp /^inline void Value<std::string>::parse(OptionName what_name, const char* value)$/;" f class:popl::Attribute::Value
popl util/popl.hpp /^namespace popl$/;" n
pos_iterator_t util/MinigridGrammar.h /^typedef boost::spirit::line_pos_iterator<std::string::const_iterator> pos_iterator_t;$/;" t
print util/popl.hpp /^inline std::string BashCompletionOptionPrinter::print(const Attribute& \/*max_attribute*\/) const$/;" f class:popl::Attribute::BashCompletionOptionPrinter
print util/popl.hpp /^inline std::string ConsoleOptionPrinter::print(const Attribute& max_attribute) const$/;" f class:popl::Attribute::ConsoleOptionPrinter
print util/popl.hpp /^inline std::string GroffOptionPrinter::print(const Attribute& max_attribute) const$/;" f class:popl::Attribute::GroffOptionPrinter
printActionsForKeys util/PrismModulesPrinter.cpp /^ std::ostream& PrismModulesPrinter::printActionsForKeys(std::ostream &os, cells keys) {$/;" f class:prism::PrismModulesPrinter
printBackgroundLabels util/PrismModulesPrinter.cpp /^ std::ostream& PrismModulesPrinter::printBackgroundLabels(std::ostream &os, const AgentName &agentName, const std::pair<Color, cells> &backgroundTiles) {$/;" f class:prism::PrismModulesPrinter
printBooleansForKeys util/PrismModulesPrinter.cpp /^ std::ostream& PrismModulesPrinter::printBooleansForKeys(std::ostream &os, const cells &keys) {$/;" f class:prism::PrismModulesPrinter
printCrashLabel util/PrismModulesPrinter.cpp /^ std::ostream& PrismModulesPrinter::printCrashLabel(std::ostream &os, const std::vector<AgentName> agentNames) {$/;" f class:prism::PrismModulesPrinter
printEndmodule util/PrismModulesPrinter.cpp /^ std::ostream& PrismModulesPrinter::printEndmodule(std::ostream &os) {$/;" f class:prism::PrismModulesPrinter
printFormulas util/PrismModulesPrinter.cpp /^ std::ostream& PrismModulesPrinter::printFormulas(std::ostream& os,$/;" f class:prism::PrismModulesPrinter
printGlobalMoveVariable util/PrismModulesPrinter.cpp /^ std::ostream& PrismModulesPrinter::printGlobalMoveVariable(std::ostream &os, const size_t &numberOfPlayer) {$/;" f class:prism::PrismModulesPrinter
printGoalLabel util/PrismModulesPrinter.cpp /^ std::ostream& PrismModulesPrinter::printGoalLabel(std::ostream& os, const AgentName &agentName, const cells &goals) {$/;" f class:prism::PrismModulesPrinter
printIsOnSlipperyFormula util/PrismModulesPrinter.cpp /^ std::ostream& PrismModulesPrinter::printIsOnSlipperyFormula(std::ostream& os, const AgentName &agentName, const cells &slippery) {$/;" f class:prism::PrismModulesPrinter
printKeysLabels util/PrismModulesPrinter.cpp /^ std::ostream& PrismModulesPrinter::printKeysLabels(std::ostream& os, const AgentName &agentName, const cells &keys) {$/;" f class:prism::PrismModulesPrinter
printModel util/PrismModulesPrinter.cpp /^ std::ostream& PrismModulesPrinter::printModel(std::ostream &os, const ModelType &modelType) {$/;" f class:prism::PrismModulesPrinter
printModule util/PrismModulesPrinter.cpp /^ std::ostream& PrismModulesPrinter::printModule(std::ostream &os, const AgentName &agentName, const size_t &agentIndex, const coordinates &boundaries, const coordinates& initialPosition, const cells &keys) {$/;" f class:prism::PrismModulesPrinter
printPlayerStruct util/PrismModulesPrinter.cpp /^ std::ostream& PrismModulesPrinter::printPlayerStruct(std::ostream &os, const AgentName &agentName) {$/;" f class:prism::PrismModulesPrinter
printPoplException util/OptionParser.cpp /^ int printPoplException(const popl::invalid_option &e) {$/;" f namespace:io
printRestrictionFormula util/PrismModulesPrinter.cpp /^ std::ostream& PrismModulesPrinter::printRestrictionFormula(std::ostream& os, const AgentName &agentName, const std::string &direction, const cells &cells) {$/;" f class:prism::PrismModulesPrinter
printSlipperyMoveEast util/PrismModulesPrinter.cpp /^ std::ostream& PrismModulesPrinter::printSlipperyMoveEast(std::ostream &os, const coordinates &c, const bool &blockedNorthEast, const bool &blockedSouthEast) {$/;" f class:prism::PrismModulesPrinter
printSlipperyMoveNorth util/PrismModulesPrinter.cpp /^ std::ostream& PrismModulesPrinter::printSlipperyMoveNorth(std::ostream &os, const coordinates &c, const bool &blockedNorthEast, const bool &blockedNorthWest) {$/;" f class:prism::PrismModulesPrinter
printSlipperyMoveSouth util/PrismModulesPrinter.cpp /^ std::ostream& PrismModulesPrinter::printSlipperyMoveSouth(std::ostream &os, const coordinates &c, const bool &blockedSouthEast, const bool &blockedSouthWest) {$/;" f class:prism::PrismModulesPrinter
printSlipperyMoveWest util/PrismModulesPrinter.cpp /^ std::ostream& PrismModulesPrinter::printSlipperyMoveWest(std::ostream &os, const coordinates &c, const bool &blockedNorthWest, const bool &blockedSouthWest) {$/;" f class:prism::PrismModulesPrinter
printToPrism util/Grid.cpp /^void Grid::printToPrism(std::ostream& os, const prism::ModelType& modelType) {$/;" f class:Grid
print_info main.cpp /^void print_info(boost::spirit::info const& what) {$/;" f
printer main.cpp /^struct printer {$/;" s file:
prism util/PrismModulesPrinter.cpp /^namespace prism {$/;" n file:
prism util/PrismModulesPrinter.h /^namespace prism {$/;" n
prism util/PrismPrinter.h /^namespace prism {$/;" n
program_name_ util/popl.hpp /^ std::string program_name_;$/;" m class:popl::Attribute::BashCompletionOptionPrinter
qnxnto build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp /^char const* qnxnto = "INFO" ":" "qnxnto[]";$/;" v
required util/popl.hpp /^ required = 2,$/;" m class:popl::Attribute
required util/popl.hpp /^ required, \/\/ option always requires an argument$/;" m class:popl::Argument
reset util/popl.hpp /^inline void OptionParser::reset()$/;" f class:popl::Attribute::OptionParser
result_type util/MinigridGrammar.h /^ typedef void result_type;$/;" t struct:annotation_f
row util/MinigridGrammar.h /^typedef std::vector<cell> row;$/;" t
row util/cell.h /^ int row;$/;" m class:Type::Color::cell
row_ util/MinigridGrammar.h /^ qi::rule<It, row()> row_;$/;" m struct:MinigridParser
set_attribute util/popl.hpp /^inline void Option::set_attribute(const Attribute& attribute)$/;" f class:popl::Attribute::Option
set_default util/popl.hpp /^inline void Value<T>::set_default(const T& value)$/;" f class:popl::Attribute::Value
set_value util/popl.hpp /^inline void Value<T>::set_value(const T& value)$/;" f class:popl::Attribute::Value
short_name util/popl.hpp /^ short_name,$/;" m class:popl::Attribute::OptionName
short_name util/popl.hpp /^inline char Option::short_name() const$/;" f class:popl::Attribute::Option
short_name_ util/popl.hpp /^ std::string short_name_;$/;" m class:popl::Attribute::Option
slippery util/Grid.h /^ cells slippery;$/;" m class:Grid
string main.cpp /^ typedef boost::spirit::utf8_string string;$/;" t struct:printer file:
to_string util/popl.hpp /^inline std::string ConsoleOptionPrinter::to_string(Option_ptr option) const$/;" f class:popl::Attribute::ConsoleOptionPrinter
to_string util/popl.hpp /^inline std::string GroffOptionPrinter::to_string(Option_ptr option) const$/;" f class:popl::Attribute::GroffOptionPrinter
too_many_arguments util/popl.hpp /^ too_many_arguments,$/;" m class:popl::Attribute::invalid_option::Error
type util/cell.h /^ Type type;$/;" m class:Type::Color::cell
type_ util/MinigridGrammar.h /^ qi::symbols<char, Type> type_;$/;" m struct:MinigridParser
unknown_options util/popl.hpp /^inline const std::vector<std::string>& OptionParser::unknown_options() const$/;" f class:popl::Attribute::OptionParser
unknown_options_ util/popl.hpp /^ std::vector<std::string> unknown_options_;$/;" m class:popl::Attribute::OptionParser
unspecified util/popl.hpp /^ unspecified,$/;" m class:popl::Attribute::OptionName
update_reference util/popl.hpp /^inline void Value<T>::update_reference()$/;" f class:popl::Attribute::Value
value util/popl.hpp /^ std::string value() const$/;" f class:popl::Attribute::invalid_option
value util/popl.hpp /^ void set_default(const bool& value) = delete;$/;" m class:popl::Attribute::Switch
value util/popl.hpp /^inline T Value<T>::value(size_t idx) const$/;" f class:popl::Attribute::Value
value_ util/popl.hpp /^ std::string value_;$/;" m class:popl::Attribute::invalid_option
value_or util/popl.hpp /^inline T Value<T>::value_or(const T& default_value, size_t idx) const$/;" f class:popl::Attribute::Value
values_ util/popl.hpp /^ std::vector<T> values_;$/;" m class:popl::Attribute::Value
viewVariable util/PrismModulesPrinter.cpp /^ std::string PrismModulesPrinter::viewVariable(const AgentName &agentName, const size_t &agentDirection) {$/;" f class:prism::PrismModulesPrinter
walls util/Grid.h /^ cells walls;$/;" m class:Grid
what_name util/popl.hpp /^ OptionName what_name() const$/;" f class:popl::Attribute::invalid_option
what_name_ util/popl.hpp /^ OptionName what_name_;$/;" m class:popl::Attribute::invalid_option

303
Minigrid2PRISM/test.prism

@ -0,0 +1,303 @@
//
// WGWGWGWGWGWGWGWGWGWGWGWGWG
// WGXR WG
// WG WGWGWGWGWGWGWGWGWG WG
// WG SBWG
// WGZGSB SBSB SB SB WG
// WG SB WG
// WG SB WG
// WG SB SB SB ZBWG
// WG SB WG
// WG SB SB SB WG
// WG WGWGWGWGWGWGWGWGWG WG
// WG GRWG
// WGWGWGWGWGWGWGWGWGWGWGWGWG
//
// A string representation of a farama minigrid (https://minigrid.farama.org/) with
// an agent (XR) and adversaries (ZG, ZB).
//
// The agent has to move to its goal (GR) while avoiding the adversaries. The agent experiences a stochastic update on a slippery tile (SB).
smg
global move : [0..2] init 0;
label AgentOnBlue = (xAgent=1&yAgent=1) | (xAgent=1&yAgent=2) | (xAgent=1&yAgent=3) | (xAgent=1&yAgent=6) | (xAgent=1&yAgent=7) | (xAgent=1&yAgent=8) | (xAgent=1&yAgent=9) | (xAgent=1&yAgent=10) | (xAgent=1&yAgent=11) | (xAgent=2&yAgent=1) | (xAgent=2&yAgent=11) | (xAgent=3&yAgent=1) | (xAgent=3&yAgent=2) | (xAgent=3&yAgent=3) | (xAgent=3&yAgent=4) | (xAgent=3&yAgent=5) | (xAgent=3&yAgent=6) | (xAgent=3&yAgent=7) | (xAgent=3&yAgent=8) | (xAgent=3&yAgent=9) | (xAgent=3&yAgent=10) | (xAgent=3&yAgent=11);
label BlueOnBlue = (xBlue=1&yBlue=1) | (xBlue=1&yBlue=2) | (xBlue=1&yBlue=3) | (xBlue=1&yBlue=6) | (xBlue=1&yBlue=7) | (xBlue=1&yBlue=8) | (xBlue=1&yBlue=9) | (xBlue=1&yBlue=10) | (xBlue=1&yBlue=11) | (xBlue=2&yBlue=1) | (xBlue=2&yBlue=11) | (xBlue=3&yBlue=1) | (xBlue=3&yBlue=2) | (xBlue=3&yBlue=3) | (xBlue=3&yBlue=4) | (xBlue=3&yBlue=5) | (xBlue=3&yBlue=6) | (xBlue=3&yBlue=7) | (xBlue=3&yBlue=8) | (xBlue=3&yBlue=9) | (xBlue=3&yBlue=10) | (xBlue=3&yBlue=11);
label GreenOnBlue = (xGreen=1&yGreen=1) | (xGreen=1&yGreen=2) | (xGreen=1&yGreen=3) | (xGreen=1&yGreen=6) | (xGreen=1&yGreen=7) | (xGreen=1&yGreen=8) | (xGreen=1&yGreen=9) | (xGreen=1&yGreen=10) | (xGreen=1&yGreen=11) | (xGreen=2&yGreen=1) | (xGreen=2&yGreen=11) | (xGreen=3&yGreen=1) | (xGreen=3&yGreen=2) | (xGreen=3&yGreen=3) | (xGreen=3&yGreen=4) | (xGreen=3&yGreen=5) | (xGreen=3&yGreen=6) | (xGreen=3&yGreen=7) | (xGreen=3&yGreen=8) | (xGreen=3&yGreen=9) | (xGreen=3&yGreen=10) | (xGreen=3&yGreen=11);
label AgentOnGreen = (xAgent=9&yAgent=1) | (xAgent=9&yAgent=2) | (xAgent=9&yAgent=3) | (xAgent=9&yAgent=4) | (xAgent=9&yAgent=5) | (xAgent=9&yAgent=6) | (xAgent=9&yAgent=7) | (xAgent=9&yAgent=8) | (xAgent=9&yAgent=9) | (xAgent=9&yAgent=10) | (xAgent=9&yAgent=11) | (xAgent=10&yAgent=1) | (xAgent=10&yAgent=11) | (xAgent=11&yAgent=1) | (xAgent=11&yAgent=2) | (xAgent=11&yAgent=3) | (xAgent=11&yAgent=4) | (xAgent=11&yAgent=5) | (xAgent=11&yAgent=6) | (xAgent=11&yAgent=7) | (xAgent=11&yAgent=8) | (xAgent=11&yAgent=9) | (xAgent=11&yAgent=10) | (xAgent=11&yAgent=11);
label BlueOnGreen = (xBlue=9&yBlue=1) | (xBlue=9&yBlue=2) | (xBlue=9&yBlue=3) | (xBlue=9&yBlue=4) | (xBlue=9&yBlue=5) | (xBlue=9&yBlue=6) | (xBlue=9&yBlue=7) | (xBlue=9&yBlue=8) | (xBlue=9&yBlue=9) | (xBlue=9&yBlue=10) | (xBlue=9&yBlue=11) | (xBlue=10&yBlue=1) | (xBlue=10&yBlue=11) | (xBlue=11&yBlue=1) | (xBlue=11&yBlue=2) | (xBlue=11&yBlue=3) | (xBlue=11&yBlue=4) | (xBlue=11&yBlue=5) | (xBlue=11&yBlue=6) | (xBlue=11&yBlue=7) | (xBlue=11&yBlue=8) | (xBlue=11&yBlue=9) | (xBlue=11&yBlue=10) | (xBlue=11&yBlue=11);
label GreenOnGreen = (xGreen=9&yGreen=1) | (xGreen=9&yGreen=2) | (xGreen=9&yGreen=3) | (xGreen=9&yGreen=4) | (xGreen=9&yGreen=5) | (xGreen=9&yGreen=6) | (xGreen=9&yGreen=7) | (xGreen=9&yGreen=8) | (xGreen=9&yGreen=9) | (xGreen=9&yGreen=10) | (xGreen=9&yGreen=11) | (xGreen=10&yGreen=1) | (xGreen=10&yGreen=11) | (xGreen=11&yGreen=1) | (xGreen=11&yGreen=2) | (xGreen=11&yGreen=3) | (xGreen=11&yGreen=4) | (xGreen=11&yGreen=5) | (xGreen=11&yGreen=6) | (xGreen=11&yGreen=7) | (xGreen=11&yGreen=8) | (xGreen=11&yGreen=9) | (xGreen=11&yGreen=10) | (xGreen=11&yGreen=11);
label AgentOnRed = (xAgent=1&yAgent=4) | (xAgent=1&yAgent=5);
label BlueOnRed = (xBlue=1&yBlue=4) | (xBlue=1&yBlue=5);
label GreenOnRed = (xGreen=1&yGreen=4) | (xGreen=1&yGreen=5);
formula AgentCannotMoveNorth = (xAgent=1&yAgent=2) | (xAgent=1&yAgent=3) | (xAgent=1&yAgent=4) | (xAgent=1&yAgent=5) | (xAgent=1&yAgent=6) | (xAgent=1&yAgent=7) | (xAgent=1&yAgent=8) | (xAgent=1&yAgent=9) | (xAgent=1&yAgent=10) | (xAgent=1&yAgent=11) | (xAgent=3&yAgent=2) | (xAgent=3&yAgent=3) | (xAgent=3&yAgent=4) | (xAgent=3&yAgent=5) | (xAgent=3&yAgent=6) | (xAgent=3&yAgent=7) | (xAgent=3&yAgent=8) | (xAgent=3&yAgent=9) | (xAgent=3&yAgent=10) | (xAgent=11&yAgent=2) | (xAgent=11&yAgent=3) | (xAgent=11&yAgent=4) | (xAgent=11&yAgent=5) | (xAgent=11&yAgent=6) | (xAgent=11&yAgent=7) | (xAgent=11&yAgent=8) | (xAgent=11&yAgent=9) | (xAgent=11&yAgent=10) | (xAgent=1&yAgent=1);
formula AgentCannotMoveEast = (xAgent=1&yAgent=11) | (xAgent=2&yAgent=1) | (xAgent=2&yAgent=11) | (xAgent=4&yAgent=11) | (xAgent=5&yAgent=11) | (xAgent=6&yAgent=11) | (xAgent=8&yAgent=11) | (xAgent=9&yAgent=11) | (xAgent=10&yAgent=1) | (xAgent=10&yAgent=11) | (xAgent=11&yAgent=11) | (xAgent=7&yAgent=11);
formula AgentCannotMoveSouth = (xAgent=1&yAgent=2) | (xAgent=1&yAgent=3) | (xAgent=1&yAgent=4) | (xAgent=1&yAgent=5) | (xAgent=1&yAgent=6) | (xAgent=1&yAgent=7) | (xAgent=1&yAgent=8) | (xAgent=1&yAgent=9) | (xAgent=1&yAgent=10) | (xAgent=9&yAgent=2) | (xAgent=9&yAgent=3) | (xAgent=9&yAgent=5) | (xAgent=9&yAgent=6) | (xAgent=9&yAgent=8) | (xAgent=9&yAgent=9) | (xAgent=11&yAgent=1) | (xAgent=11&yAgent=2) | (xAgent=11&yAgent=3) | (xAgent=11&yAgent=4) | (xAgent=11&yAgent=5) | (xAgent=11&yAgent=6) | (xAgent=11&yAgent=7) | (xAgent=11&yAgent=8) | (xAgent=11&yAgent=9) | (xAgent=11&yAgent=10) | (xAgent=11&yAgent=11);
formula AgentCannotMoveWest = (xAgent=2&yAgent=1) | (xAgent=2&yAgent=11) | (xAgent=3&yAgent=1) | (xAgent=5&yAgent=1) | (xAgent=6&yAgent=1) | (xAgent=7&yAgent=1) | (xAgent=8&yAgent=1) | (xAgent=9&yAgent=1) | (xAgent=10&yAgent=1) | (xAgent=10&yAgent=11) | (xAgent=11&yAgent=1) | (xAgent=1&yAgent=1) | (xAgent=4&yAgent=1);
formula AgentIsOnSlippery = (xAgent=3&yAgent=11) | (xAgent=4&yAgent=2) | (xAgent=4&yAgent=4) | (xAgent=4&yAgent=5) | (xAgent=4&yAgent=7) | (xAgent=4&yAgent=9) | (xAgent=5&yAgent=10) | (xAgent=6&yAgent=4) | (xAgent=7&yAgent=3) | (xAgent=7&yAgent=6) | (xAgent=7&yAgent=9) | (xAgent=8&yAgent=2) | (xAgent=9&yAgent=4) | (xAgent=9&yAgent=7) | (xAgent=9&yAgent=10);
label AgentGoal = (xAgent=11&yAgent=11);
formula BlueCannotMoveNorth = (xBlue=1&yBlue=2) | (xBlue=1&yBlue=3) | (xBlue=1&yBlue=4) | (xBlue=1&yBlue=5) | (xBlue=1&yBlue=6) | (xBlue=1&yBlue=7) | (xBlue=1&yBlue=8) | (xBlue=1&yBlue=9) | (xBlue=1&yBlue=10) | (xBlue=1&yBlue=11) | (xBlue=3&yBlue=2) | (xBlue=3&yBlue=3) | (xBlue=3&yBlue=4) | (xBlue=3&yBlue=5) | (xBlue=3&yBlue=6) | (xBlue=3&yBlue=7) | (xBlue=3&yBlue=8) | (xBlue=3&yBlue=9) | (xBlue=3&yBlue=10) | (xBlue=11&yBlue=2) | (xBlue=11&yBlue=3) | (xBlue=11&yBlue=4) | (xBlue=11&yBlue=5) | (xBlue=11&yBlue=6) | (xBlue=11&yBlue=7) | (xBlue=11&yBlue=8) | (xBlue=11&yBlue=9) | (xBlue=11&yBlue=10) | (xBlue=1&yBlue=1);
formula BlueCannotMoveEast = (xBlue=1&yBlue=11) | (xBlue=2&yBlue=1) | (xBlue=2&yBlue=11) | (xBlue=4&yBlue=11) | (xBlue=5&yBlue=11) | (xBlue=6&yBlue=11) | (xBlue=8&yBlue=11) | (xBlue=9&yBlue=11) | (xBlue=10&yBlue=1) | (xBlue=10&yBlue=11) | (xBlue=11&yBlue=11) | (xBlue=7&yBlue=11);
formula BlueCannotMoveSouth = (xBlue=1&yBlue=2) | (xBlue=1&yBlue=3) | (xBlue=1&yBlue=4) | (xBlue=1&yBlue=5) | (xBlue=1&yBlue=6) | (xBlue=1&yBlue=7) | (xBlue=1&yBlue=8) | (xBlue=1&yBlue=9) | (xBlue=1&yBlue=10) | (xBlue=9&yBlue=2) | (xBlue=9&yBlue=3) | (xBlue=9&yBlue=5) | (xBlue=9&yBlue=6) | (xBlue=9&yBlue=8) | (xBlue=9&yBlue=9) | (xBlue=11&yBlue=1) | (xBlue=11&yBlue=2) | (xBlue=11&yBlue=3) | (xBlue=11&yBlue=4) | (xBlue=11&yBlue=5) | (xBlue=11&yBlue=6) | (xBlue=11&yBlue=7) | (xBlue=11&yBlue=8) | (xBlue=11&yBlue=9) | (xBlue=11&yBlue=10) | (xBlue=11&yBlue=11);
formula BlueCannotMoveWest = (xBlue=2&yBlue=1) | (xBlue=2&yBlue=11) | (xBlue=3&yBlue=1) | (xBlue=5&yBlue=1) | (xBlue=6&yBlue=1) | (xBlue=7&yBlue=1) | (xBlue=8&yBlue=1) | (xBlue=9&yBlue=1) | (xBlue=10&yBlue=1) | (xBlue=10&yBlue=11) | (xBlue=11&yBlue=1) | (xBlue=1&yBlue=1) | (xBlue=4&yBlue=1);
formula BlueIsOnSlippery = (xBlue=3&yBlue=11) | (xBlue=4&yBlue=2) | (xBlue=4&yBlue=4) | (xBlue=4&yBlue=5) | (xBlue=4&yBlue=7) | (xBlue=4&yBlue=9) | (xBlue=5&yBlue=10) | (xBlue=6&yBlue=4) | (xBlue=7&yBlue=3) | (xBlue=7&yBlue=6) | (xBlue=7&yBlue=9) | (xBlue=8&yBlue=2) | (xBlue=9&yBlue=4) | (xBlue=9&yBlue=7) | (xBlue=9&yBlue=10);
label BlueGoal = (xBlue=11&yBlue=11);
formula GreenCannotMoveNorth = (xGreen=1&yGreen=2) | (xGreen=1&yGreen=3) | (xGreen=1&yGreen=4) | (xGreen=1&yGreen=5) | (xGreen=1&yGreen=6) | (xGreen=1&yGreen=7) | (xGreen=1&yGreen=8) | (xGreen=1&yGreen=9) | (xGreen=1&yGreen=10) | (xGreen=1&yGreen=11) | (xGreen=3&yGreen=2) | (xGreen=3&yGreen=3) | (xGreen=3&yGreen=4) | (xGreen=3&yGreen=5) | (xGreen=3&yGreen=6) | (xGreen=3&yGreen=7) | (xGreen=3&yGreen=8) | (xGreen=3&yGreen=9) | (xGreen=3&yGreen=10) | (xGreen=11&yGreen=2) | (xGreen=11&yGreen=3) | (xGreen=11&yGreen=4) | (xGreen=11&yGreen=5) | (xGreen=11&yGreen=6) | (xGreen=11&yGreen=7) | (xGreen=11&yGreen=8) | (xGreen=11&yGreen=9) | (xGreen=11&yGreen=10) | (xGreen=1&yGreen=1);
formula GreenCannotMoveEast = (xGreen=1&yGreen=11) | (xGreen=2&yGreen=1) | (xGreen=2&yGreen=11) | (xGreen=4&yGreen=11) | (xGreen=5&yGreen=11) | (xGreen=6&yGreen=11) | (xGreen=8&yGreen=11) | (xGreen=9&yGreen=11) | (xGreen=10&yGreen=1) | (xGreen=10&yGreen=11) | (xGreen=11&yGreen=11) | (xGreen=7&yGreen=11);
formula GreenCannotMoveSouth = (xGreen=1&yGreen=2) | (xGreen=1&yGreen=3) | (xGreen=1&yGreen=4) | (xGreen=1&yGreen=5) | (xGreen=1&yGreen=6) | (xGreen=1&yGreen=7) | (xGreen=1&yGreen=8) | (xGreen=1&yGreen=9) | (xGreen=1&yGreen=10) | (xGreen=9&yGreen=2) | (xGreen=9&yGreen=3) | (xGreen=9&yGreen=5) | (xGreen=9&yGreen=6) | (xGreen=9&yGreen=8) | (xGreen=9&yGreen=9) | (xGreen=11&yGreen=1) | (xGreen=11&yGreen=2) | (xGreen=11&yGreen=3) | (xGreen=11&yGreen=4) | (xGreen=11&yGreen=5) | (xGreen=11&yGreen=6) | (xGreen=11&yGreen=7) | (xGreen=11&yGreen=8) | (xGreen=11&yGreen=9) | (xGreen=11&yGreen=10) | (xGreen=11&yGreen=11);
formula GreenCannotMoveWest = (xGreen=2&yGreen=1) | (xGreen=2&yGreen=11) | (xGreen=3&yGreen=1) | (xGreen=5&yGreen=1) | (xGreen=6&yGreen=1) | (xGreen=7&yGreen=1) | (xGreen=8&yGreen=1) | (xGreen=9&yGreen=1) | (xGreen=10&yGreen=1) | (xGreen=10&yGreen=11) | (xGreen=11&yGreen=1) | (xGreen=1&yGreen=1) | (xGreen=4&yGreen=1);
formula GreenIsOnSlippery = (xGreen=3&yGreen=11) | (xGreen=4&yGreen=2) | (xGreen=4&yGreen=4) | (xGreen=4&yGreen=5) | (xGreen=4&yGreen=7) | (xGreen=4&yGreen=9) | (xGreen=5&yGreen=10) | (xGreen=6&yGreen=4) | (xGreen=7&yGreen=3) | (xGreen=7&yGreen=6) | (xGreen=7&yGreen=9) | (xGreen=8&yGreen=2) | (xGreen=9&yGreen=4) | (xGreen=9&yGreen=7) | (xGreen=9&yGreen=10);
label GreenGoal = (xGreen=11&yGreen=11);
label crash = (xAgent=xBlue)&(yAgent=yBlue) | (xAgent=xGreen)&(yAgent=yGreen);
formula crashHappened = (xAgent=xBlue)&(yAgent=yBlue) | (xAgent=xGreen)&(yAgent=yGreen);
module Agent
xAgent : [1..12] init 1;
yAgent : [1..12] init 1;
viewAgent : [0..3] init 1;
[Agent_turn_right] !crashHappened & move=0 & true -> (viewAgent'=mod(viewAgent + 1, 4)) & (move'=1) ;
[Agent_turn_left] !crashHappened & move=0 & viewAgent>0 -> (viewAgent'=viewAgent - 1) & (move'=1) ;
[Agent_turn_left] !crashHappened & move=0 & viewAgent=0 -> (viewAgent'=3) & (move'=1) ;
[Agent_move_north] !crashHappened & move=0 & viewAgent=3 & !AgentIsOnSlippery & !AgentCannotMoveNorth -> (xAgent'=xAgent-1) & (move'=1) ;
[Agent_move_east] !crashHappened & move=0 & viewAgent=0 & !AgentIsOnSlippery & !AgentCannotMoveEast -> (yAgent'=yAgent+1) & (move'=1) ;
[Agent_move_south] !crashHappened & move=0 & viewAgent=1 & !AgentIsOnSlippery & !AgentCannotMoveSouth -> (xAgent'=xAgent+1) & (move'=1) ;
[Agent_move_west] !crashHappened & move=0 & viewAgent=2 & !AgentIsOnSlippery & !AgentCannotMoveWest -> (yAgent'=yAgent-1) & (move'=1) ;
[Agentslip_north] !crashHappened & move=0 & viewAgent=3 & xAgent=3 & yAgent=11 -> 3/3 : (xAgent'=xAgent-1) & (move'=1) ;
[Agentslip_east] !crashHappened & move=0 & viewAgent=0 & xAgent=3 & yAgent=11 -> 3/3 : (yAgent'=yAgent+1) & (move'=1) ;
[Agentslip_south] !crashHappened & move=0 & viewAgent=1 & xAgent=3 & yAgent=11 -> 2/3 : (xAgent'=xAgent+1) + 1/3: (xAgent'=xAgent+1) & (yAgent'=yAgent-1) & (move'=1) ;
[Agentslip_west] !crashHappened & move=0 & viewAgent=2 & xAgent=3 & yAgent=11 -> 2/3 : (yAgent'=yAgent-1) + 1/3: (yAgent'=yAgent-1) & (xAgent'=xAgent+1) & (move'=1) ;
[Agentslip_north] !crashHappened & move=0 & viewAgent=3 & xAgent=4 & yAgent=2 -> 1/3 : (xAgent'=xAgent-1) + 1/3: (xAgent'=xAgent-1) & (yAgent'=yAgent-1) + 1/3: (xAgent'=xAgent-1) & (yAgent'=yAgent+1) & (move'=1) ;
[Agentslip_east] !crashHappened & move=0 & viewAgent=0 & xAgent=4 & yAgent=2 -> 1/3 : (yAgent'=yAgent+1) + 1/3: (yAgent'=yAgent+1) & (xAgent'=xAgent+1) + 1/3: (yAgent'=yAgent+1) & (xAgent'=xAgent-1) & (move'=1) ;
[Agentslip_south] !crashHappened & move=0 & viewAgent=1 & xAgent=4 & yAgent=2 -> 1/3 : (xAgent'=xAgent+1) + 1/3: (xAgent'=xAgent+1) & (yAgent'=yAgent-1) + 1/3: (xAgent'=xAgent+1) & (yAgent'=yAgent+1) & (move'=1) ;
[Agentslip_west] !crashHappened & move=0 & viewAgent=2 & xAgent=4 & yAgent=2 -> 1/3 : (yAgent'=yAgent-1) + 1/3: (yAgent'=yAgent-1) & (xAgent'=xAgent-1) + 1/3: (yAgent'=yAgent-1) & (xAgent'=xAgent+1) & (move'=1) ;
[Agentslip_north] !crashHappened & move=0 & viewAgent=3 & xAgent=4 & yAgent=4 -> 1/3 : (xAgent'=xAgent-1) + 1/3: (xAgent'=xAgent-1) & (yAgent'=yAgent-1) + 1/3: (xAgent'=xAgent-1) & (yAgent'=yAgent+1) & (move'=1) ;
[Agentslip_east] !crashHappened & move=0 & viewAgent=0 & xAgent=4 & yAgent=4 -> 1/3 : (yAgent'=yAgent+1) + 1/3: (yAgent'=yAgent+1) & (xAgent'=xAgent+1) + 1/3: (yAgent'=yAgent+1) & (xAgent'=xAgent-1) & (move'=1) ;
[Agentslip_south] !crashHappened & move=0 & viewAgent=1 & xAgent=4 & yAgent=4 -> 1/3 : (xAgent'=xAgent+1) + 1/3: (xAgent'=xAgent+1) & (yAgent'=yAgent-1) + 1/3: (xAgent'=xAgent+1) & (yAgent'=yAgent+1) & (move'=1) ;
[Agentslip_west] !crashHappened & move=0 & viewAgent=2 & xAgent=4 & yAgent=4 -> 1/3 : (yAgent'=yAgent-1) + 1/3: (yAgent'=yAgent-1) & (xAgent'=xAgent-1) + 1/3: (yAgent'=yAgent-1) & (xAgent'=xAgent+1) & (move'=1) ;
[Agentslip_north] !crashHappened & move=0 & viewAgent=3 & xAgent=4 & yAgent=5 -> 1/3 : (xAgent'=xAgent-1) + 1/3: (xAgent'=xAgent-1) & (yAgent'=yAgent-1) + 1/3: (xAgent'=xAgent-1) & (yAgent'=yAgent+1) & (move'=1) ;
[Agentslip_east] !crashHappened & move=0 & viewAgent=0 & xAgent=4 & yAgent=5 -> 1/3 : (yAgent'=yAgent+1) + 1/3: (yAgent'=yAgent+1) & (xAgent'=xAgent+1) + 1/3: (yAgent'=yAgent+1) & (xAgent'=xAgent-1) & (move'=1) ;
[Agentslip_south] !crashHappened & move=0 & viewAgent=1 & xAgent=4 & yAgent=5 -> 1/3 : (xAgent'=xAgent+1) + 1/3: (xAgent'=xAgent+1) & (yAgent'=yAgent-1) + 1/3: (xAgent'=xAgent+1) & (yAgent'=yAgent+1) & (move'=1) ;
[Agentslip_west] !crashHappened & move=0 & viewAgent=2 & xAgent=4 & yAgent=5 -> 1/3 : (yAgent'=yAgent-1) + 1/3: (yAgent'=yAgent-1) & (xAgent'=xAgent-1) + 1/3: (yAgent'=yAgent-1) & (xAgent'=xAgent+1) & (move'=1) ;
[Agentslip_north] !crashHappened & move=0 & viewAgent=3 & xAgent=4 & yAgent=7 -> 1/3 : (xAgent'=xAgent-1) + 1/3: (xAgent'=xAgent-1) & (yAgent'=yAgent-1) + 1/3: (xAgent'=xAgent-1) & (yAgent'=yAgent+1) & (move'=1) ;
[Agentslip_east] !crashHappened & move=0 & viewAgent=0 & xAgent=4 & yAgent=7 -> 1/3 : (yAgent'=yAgent+1) + 1/3: (yAgent'=yAgent+1) & (xAgent'=xAgent+1) + 1/3: (yAgent'=yAgent+1) & (xAgent'=xAgent-1) & (move'=1) ;
[Agentslip_south] !crashHappened & move=0 & viewAgent=1 & xAgent=4 & yAgent=7 -> 1/3 : (xAgent'=xAgent+1) + 1/3: (xAgent'=xAgent+1) & (yAgent'=yAgent-1) + 1/3: (xAgent'=xAgent+1) & (yAgent'=yAgent+1) & (move'=1) ;
[Agentslip_west] !crashHappened & move=0 & viewAgent=2 & xAgent=4 & yAgent=7 -> 1/3 : (yAgent'=yAgent-1) + 1/3: (yAgent'=yAgent-1) & (xAgent'=xAgent-1) + 1/3: (yAgent'=yAgent-1) & (xAgent'=xAgent+1) & (move'=1) ;
[Agentslip_north] !crashHappened & move=0 & viewAgent=3 & xAgent=4 & yAgent=9 -> 1/3 : (xAgent'=xAgent-1) + 1/3: (xAgent'=xAgent-1) & (yAgent'=yAgent-1) + 1/3: (xAgent'=xAgent-1) & (yAgent'=yAgent+1) & (move'=1) ;
[Agentslip_east] !crashHappened & move=0 & viewAgent=0 & xAgent=4 & yAgent=9 -> 1/3 : (yAgent'=yAgent+1) + 1/3: (yAgent'=yAgent+1) & (xAgent'=xAgent+1) + 1/3: (yAgent'=yAgent+1) & (xAgent'=xAgent-1) & (move'=1) ;
[Agentslip_south] !crashHappened & move=0 & viewAgent=1 & xAgent=4 & yAgent=9 -> 1/3 : (xAgent'=xAgent+1) + 1/3: (xAgent'=xAgent+1) & (yAgent'=yAgent-1) + 1/3: (xAgent'=xAgent+1) & (yAgent'=yAgent+1) & (move'=1) ;
[Agentslip_west] !crashHappened & move=0 & viewAgent=2 & xAgent=4 & yAgent=9 -> 1/3 : (yAgent'=yAgent-1) + 1/3: (yAgent'=yAgent-1) & (xAgent'=xAgent-1) + 1/3: (yAgent'=yAgent-1) & (xAgent'=xAgent+1) & (move'=1) ;
[Agentslip_north] !crashHappened & move=0 & viewAgent=3 & xAgent=5 & yAgent=10 -> 1/3 : (xAgent'=xAgent-1) + 1/3: (xAgent'=xAgent-1) & (yAgent'=yAgent-1) + 1/3: (xAgent'=xAgent-1) & (yAgent'=yAgent+1) & (move'=1) ;
[Agentslip_east] !crashHappened & move=0 & viewAgent=0 & xAgent=5 & yAgent=10 -> 1/3 : (yAgent'=yAgent+1) + 1/3: (yAgent'=yAgent+1) & (xAgent'=xAgent+1) + 1/3: (yAgent'=yAgent+1) & (xAgent'=xAgent-1) & (move'=1) ;
[Agentslip_south] !crashHappened & move=0 & viewAgent=1 & xAgent=5 & yAgent=10 -> 1/3 : (xAgent'=xAgent+1) + 1/3: (xAgent'=xAgent+1) & (yAgent'=yAgent-1) + 1/3: (xAgent'=xAgent+1) & (yAgent'=yAgent+1) & (move'=1) ;
[Agentslip_west] !crashHappened & move=0 & viewAgent=2 & xAgent=5 & yAgent=10 -> 1/3 : (yAgent'=yAgent-1) + 1/3: (yAgent'=yAgent-1) & (xAgent'=xAgent-1) + 1/3: (yAgent'=yAgent-1) & (xAgent'=xAgent+1) & (move'=1) ;
[Agentslip_north] !crashHappened & move=0 & viewAgent=3 & xAgent=6 & yAgent=4 -> 1/3 : (xAgent'=xAgent-1) + 1/3: (xAgent'=xAgent-1) & (yAgent'=yAgent-1) + 1/3: (xAgent'=xAgent-1) & (yAgent'=yAgent+1) & (move'=1) ;
[Agentslip_east] !crashHappened & move=0 & viewAgent=0 & xAgent=6 & yAgent=4 -> 1/3 : (yAgent'=yAgent+1) + 1/3: (yAgent'=yAgent+1) & (xAgent'=xAgent+1) + 1/3: (yAgent'=yAgent+1) & (xAgent'=xAgent-1) & (move'=1) ;
[Agentslip_south] !crashHappened & move=0 & viewAgent=1 & xAgent=6 & yAgent=4 -> 1/3 : (xAgent'=xAgent+1) + 1/3: (xAgent'=xAgent+1) & (yAgent'=yAgent-1) + 1/3: (xAgent'=xAgent+1) & (yAgent'=yAgent+1) & (move'=1) ;
[Agentslip_west] !crashHappened & move=0 & viewAgent=2 & xAgent=6 & yAgent=4 -> 1/3 : (yAgent'=yAgent-1) + 1/3: (yAgent'=yAgent-1) & (xAgent'=xAgent-1) + 1/3: (yAgent'=yAgent-1) & (xAgent'=xAgent+1) & (move'=1) ;
[Agentslip_north] !crashHappened & move=0 & viewAgent=3 & xAgent=7 & yAgent=3 -> 1/3 : (xAgent'=xAgent-1) + 1/3: (xAgent'=xAgent-1) & (yAgent'=yAgent-1) + 1/3: (xAgent'=xAgent-1) & (yAgent'=yAgent+1) & (move'=1) ;
[Agentslip_east] !crashHappened & move=0 & viewAgent=0 & xAgent=7 & yAgent=3 -> 1/3 : (yAgent'=yAgent+1) + 1/3: (yAgent'=yAgent+1) & (xAgent'=xAgent+1) + 1/3: (yAgent'=yAgent+1) & (xAgent'=xAgent-1) & (move'=1) ;
[Agentslip_south] !crashHappened & move=0 & viewAgent=1 & xAgent=7 & yAgent=3 -> 1/3 : (xAgent'=xAgent+1) + 1/3: (xAgent'=xAgent+1) & (yAgent'=yAgent-1) + 1/3: (xAgent'=xAgent+1) & (yAgent'=yAgent+1) & (move'=1) ;
[Agentslip_west] !crashHappened & move=0 & viewAgent=2 & xAgent=7 & yAgent=3 -> 1/3 : (yAgent'=yAgent-1) + 1/3: (yAgent'=yAgent-1) & (xAgent'=xAgent-1) + 1/3: (yAgent'=yAgent-1) & (xAgent'=xAgent+1) & (move'=1) ;
[Agentslip_north] !crashHappened & move=0 & viewAgent=3 & xAgent=7 & yAgent=6 -> 1/3 : (xAgent'=xAgent-1) + 1/3: (xAgent'=xAgent-1) & (yAgent'=yAgent-1) + 1/3: (xAgent'=xAgent-1) & (yAgent'=yAgent+1) & (move'=1) ;
[Agentslip_east] !crashHappened & move=0 & viewAgent=0 & xAgent=7 & yAgent=6 -> 1/3 : (yAgent'=yAgent+1) + 1/3: (yAgent'=yAgent+1) & (xAgent'=xAgent+1) + 1/3: (yAgent'=yAgent+1) & (xAgent'=xAgent-1) & (move'=1) ;
[Agentslip_south] !crashHappened & move=0 & viewAgent=1 & xAgent=7 & yAgent=6 -> 1/3 : (xAgent'=xAgent+1) + 1/3: (xAgent'=xAgent+1) & (yAgent'=yAgent-1) + 1/3: (xAgent'=xAgent+1) & (yAgent'=yAgent+1) & (move'=1) ;
[Agentslip_west] !crashHappened & move=0 & viewAgent=2 & xAgent=7 & yAgent=6 -> 1/3 : (yAgent'=yAgent-1) + 1/3: (yAgent'=yAgent-1) & (xAgent'=xAgent-1) + 1/3: (yAgent'=yAgent-1) & (xAgent'=xAgent+1) & (move'=1) ;
[Agentslip_north] !crashHappened & move=0 & viewAgent=3 & xAgent=7 & yAgent=9 -> 1/3 : (xAgent'=xAgent-1) + 1/3: (xAgent'=xAgent-1) & (yAgent'=yAgent-1) + 1/3: (xAgent'=xAgent-1) & (yAgent'=yAgent+1) & (move'=1) ;
[Agentslip_east] !crashHappened & move=0 & viewAgent=0 & xAgent=7 & yAgent=9 -> 1/3 : (yAgent'=yAgent+1) + 1/3: (yAgent'=yAgent+1) & (xAgent'=xAgent+1) + 1/3: (yAgent'=yAgent+1) & (xAgent'=xAgent-1) & (move'=1) ;
[Agentslip_south] !crashHappened & move=0 & viewAgent=1 & xAgent=7 & yAgent=9 -> 1/3 : (xAgent'=xAgent+1) + 1/3: (xAgent'=xAgent+1) & (yAgent'=yAgent-1) + 1/3: (xAgent'=xAgent+1) & (yAgent'=yAgent+1) & (move'=1) ;
[Agentslip_west] !crashHappened & move=0 & viewAgent=2 & xAgent=7 & yAgent=9 -> 1/3 : (yAgent'=yAgent-1) + 1/3: (yAgent'=yAgent-1) & (xAgent'=xAgent-1) + 1/3: (yAgent'=yAgent-1) & (xAgent'=xAgent+1) & (move'=1) ;
[Agentslip_north] !crashHappened & move=0 & viewAgent=3 & xAgent=8 & yAgent=2 -> 1/3 : (xAgent'=xAgent-1) + 1/3: (xAgent'=xAgent-1) & (yAgent'=yAgent-1) + 1/3: (xAgent'=xAgent-1) & (yAgent'=yAgent+1) & (move'=1) ;
[Agentslip_east] !crashHappened & move=0 & viewAgent=0 & xAgent=8 & yAgent=2 -> 1/3 : (yAgent'=yAgent+1) + 1/3: (yAgent'=yAgent+1) & (xAgent'=xAgent+1) + 1/3: (yAgent'=yAgent+1) & (xAgent'=xAgent-1) & (move'=1) ;
[Agentslip_south] !crashHappened & move=0 & viewAgent=1 & xAgent=8 & yAgent=2 -> 1/3 : (xAgent'=xAgent+1) + 1/3: (xAgent'=xAgent+1) & (yAgent'=yAgent-1) + 1/3: (xAgent'=xAgent+1) & (yAgent'=yAgent+1) & (move'=1) ;
[Agentslip_west] !crashHappened & move=0 & viewAgent=2 & xAgent=8 & yAgent=2 -> 1/3 : (yAgent'=yAgent-1) + 1/3: (yAgent'=yAgent-1) & (xAgent'=xAgent-1) + 1/3: (yAgent'=yAgent-1) & (xAgent'=xAgent+1) & (move'=1) ;
[Agentslip_north] !crashHappened & move=0 & viewAgent=3 & xAgent=9 & yAgent=4 -> 1/3 : (xAgent'=xAgent-1) + 1/3: (xAgent'=xAgent-1) & (yAgent'=yAgent-1) + 1/3: (xAgent'=xAgent-1) & (yAgent'=yAgent+1) & (move'=1) ;
[Agentslip_east] !crashHappened & move=0 & viewAgent=0 & xAgent=9 & yAgent=4 -> 2/3 : (yAgent'=yAgent+1) + 1/3: (yAgent'=yAgent+1) & (xAgent'=xAgent-1) & (move'=1) ;
[Agentslip_south] !crashHappened & move=0 & viewAgent=1 & xAgent=9 & yAgent=4 -> 3/3 : (xAgent'=xAgent+1) & (move'=1) ;
[Agentslip_west] !crashHappened & move=0 & viewAgent=2 & xAgent=9 & yAgent=4 -> 2/3 : (yAgent'=yAgent-1) + 1/3: (yAgent'=yAgent-1) & (xAgent'=xAgent-1) & (move'=1) ;
[Agentslip_north] !crashHappened & move=0 & viewAgent=3 & xAgent=9 & yAgent=7 -> 1/3 : (xAgent'=xAgent-1) + 1/3: (xAgent'=xAgent-1) & (yAgent'=yAgent-1) + 1/3: (xAgent'=xAgent-1) & (yAgent'=yAgent+1) & (move'=1) ;
[Agentslip_east] !crashHappened & move=0 & viewAgent=0 & xAgent=9 & yAgent=7 -> 2/3 : (yAgent'=yAgent+1) + 1/3: (yAgent'=yAgent+1) & (xAgent'=xAgent-1) & (move'=1) ;
[Agentslip_south] !crashHappened & move=0 & viewAgent=1 & xAgent=9 & yAgent=7 -> 3/3 : (xAgent'=xAgent+1) & (move'=1) ;
[Agentslip_west] !crashHappened & move=0 & viewAgent=2 & xAgent=9 & yAgent=7 -> 2/3 : (yAgent'=yAgent-1) + 1/3: (yAgent'=yAgent-1) & (xAgent'=xAgent-1) & (move'=1) ;
[Agentslip_north] !crashHappened & move=0 & viewAgent=3 & xAgent=9 & yAgent=10 -> 1/3 : (xAgent'=xAgent-1) + 1/3: (xAgent'=xAgent-1) & (yAgent'=yAgent-1) + 1/3: (xAgent'=xAgent-1) & (yAgent'=yAgent+1) & (move'=1) ;
[Agentslip_east] !crashHappened & move=0 & viewAgent=0 & xAgent=9 & yAgent=10 -> 1/3 : (yAgent'=yAgent+1) + 1/3: (yAgent'=yAgent+1) & (xAgent'=xAgent+1) + 1/3: (yAgent'=yAgent+1) & (xAgent'=xAgent-1) & (move'=1) ;
[Agentslip_south] !crashHappened & move=0 & viewAgent=1 & xAgent=9 & yAgent=10 -> 2/3 : (xAgent'=xAgent+1) + 1/3: (xAgent'=xAgent+1) & (yAgent'=yAgent+1) & (move'=1) ;
[Agentslip_west] !crashHappened & move=0 & viewAgent=2 & xAgent=9 & yAgent=10 -> 2/3 : (yAgent'=yAgent-1) + 1/3: (yAgent'=yAgent-1) & (xAgent'=xAgent-1) & (move'=1) ;
[crashed] move=0 & crashHappened -> true;
endmodule
player Agent
[Agent_move_north], [Agent_move_east], [Agent_move_south], [Agent_move_west], [Agent_turn_left], [Agent_turn_right], [Agentslip_east] , [Agentslip_north], [Agentslip_south], [Agentslip_west], [crashed]
endplayer
module Blue
xBlue : [1..12] init 7;
yBlue : [1..12] init 11;
viewBlue : [0..3] init 1;
[Blue_turn_right] move=1 & true -> (viewBlue'=mod(viewBlue + 1, 4)) & (move'=2) ;
[Blue_turn_left] move=1 & viewBlue>0 -> (viewBlue'=viewBlue - 1) & (move'=2) ;
[Blue_turn_left] move=1 & viewBlue=0 -> (viewBlue'=3) & (move'=2) ;
[Blue_move_north] move=1 & viewBlue=3 & !BlueIsOnSlippery & !BlueCannotMoveNorth -> (xBlue'=xBlue-1) & (move'=2) ;
[Blue_move_east] move=1 & viewBlue=0 & !BlueIsOnSlippery & !BlueCannotMoveEast -> (yBlue'=yBlue+1) & (move'=2) ;
[Blue_move_south] move=1 & viewBlue=1 & !BlueIsOnSlippery & !BlueCannotMoveSouth -> (xBlue'=xBlue+1) & (move'=2) ;
[Blue_move_west] move=1 & viewBlue=2 & !BlueIsOnSlippery & !BlueCannotMoveWest -> (yBlue'=yBlue-1) & (move'=2) ;
[Blueslip_north] move=1 & viewBlue=3 & xBlue=3 & yBlue=11 -> 3/3 : (xBlue'=xBlue-1) & (move'=2) ;
[Blueslip_east] move=1 & viewBlue=0 & xBlue=3 & yBlue=11 -> 3/3 : (yBlue'=yBlue+1) & (move'=2) ;
[Blueslip_south] move=1 & viewBlue=1 & xBlue=3 & yBlue=11 -> 2/3 : (xBlue'=xBlue+1) + 1/3: (xBlue'=xBlue+1) & (yBlue'=yBlue-1) & (move'=2) ;
[Blueslip_west] move=1 & viewBlue=2 & xBlue=3 & yBlue=11 -> 2/3 : (yBlue'=yBlue-1) + 1/3: (yBlue'=yBlue-1) & (xBlue'=xBlue+1) & (move'=2) ;
[Blueslip_north] move=1 & viewBlue=3 & xBlue=4 & yBlue=2 -> 1/3 : (xBlue'=xBlue-1) + 1/3: (xBlue'=xBlue-1) & (yBlue'=yBlue-1) + 1/3: (xBlue'=xBlue-1) & (yBlue'=yBlue+1) & (move'=2) ;
[Blueslip_east] move=1 & viewBlue=0 & xBlue=4 & yBlue=2 -> 1/3 : (yBlue'=yBlue+1) + 1/3: (yBlue'=yBlue+1) & (xBlue'=xBlue+1) + 1/3: (yBlue'=yBlue+1) & (xBlue'=xBlue-1) & (move'=2) ;
[Blueslip_south] move=1 & viewBlue=1 & xBlue=4 & yBlue=2 -> 1/3 : (xBlue'=xBlue+1) + 1/3: (xBlue'=xBlue+1) & (yBlue'=yBlue-1) + 1/3: (xBlue'=xBlue+1) & (yBlue'=yBlue+1) & (move'=2) ;
[Blueslip_west] move=1 & viewBlue=2 & xBlue=4 & yBlue=2 -> 1/3 : (yBlue'=yBlue-1) + 1/3: (yBlue'=yBlue-1) & (xBlue'=xBlue-1) + 1/3: (yBlue'=yBlue-1) & (xBlue'=xBlue+1) & (move'=2) ;
[Blueslip_north] move=1 & viewBlue=3 & xBlue=4 & yBlue=4 -> 1/3 : (xBlue'=xBlue-1) + 1/3: (xBlue'=xBlue-1) & (yBlue'=yBlue-1) + 1/3: (xBlue'=xBlue-1) & (yBlue'=yBlue+1) & (move'=2) ;
[Blueslip_east] move=1 & viewBlue=0 & xBlue=4 & yBlue=4 -> 1/3 : (yBlue'=yBlue+1) + 1/3: (yBlue'=yBlue+1) & (xBlue'=xBlue+1) + 1/3: (yBlue'=yBlue+1) & (xBlue'=xBlue-1) & (move'=2) ;
[Blueslip_south] move=1 & viewBlue=1 & xBlue=4 & yBlue=4 -> 1/3 : (xBlue'=xBlue+1) + 1/3: (xBlue'=xBlue+1) & (yBlue'=yBlue-1) + 1/3: (xBlue'=xBlue+1) & (yBlue'=yBlue+1) & (move'=2) ;
[Blueslip_west] move=1 & viewBlue=2 & xBlue=4 & yBlue=4 -> 1/3 : (yBlue'=yBlue-1) + 1/3: (yBlue'=yBlue-1) & (xBlue'=xBlue-1) + 1/3: (yBlue'=yBlue-1) & (xBlue'=xBlue+1) & (move'=2) ;
[Blueslip_north] move=1 & viewBlue=3 & xBlue=4 & yBlue=5 -> 1/3 : (xBlue'=xBlue-1) + 1/3: (xBlue'=xBlue-1) & (yBlue'=yBlue-1) + 1/3: (xBlue'=xBlue-1) & (yBlue'=yBlue+1) & (move'=2) ;
[Blueslip_east] move=1 & viewBlue=0 & xBlue=4 & yBlue=5 -> 1/3 : (yBlue'=yBlue+1) + 1/3: (yBlue'=yBlue+1) & (xBlue'=xBlue+1) + 1/3: (yBlue'=yBlue+1) & (xBlue'=xBlue-1) & (move'=2) ;
[Blueslip_south] move=1 & viewBlue=1 & xBlue=4 & yBlue=5 -> 1/3 : (xBlue'=xBlue+1) + 1/3: (xBlue'=xBlue+1) & (yBlue'=yBlue-1) + 1/3: (xBlue'=xBlue+1) & (yBlue'=yBlue+1) & (move'=2) ;
[Blueslip_west] move=1 & viewBlue=2 & xBlue=4 & yBlue=5 -> 1/3 : (yBlue'=yBlue-1) + 1/3: (yBlue'=yBlue-1) & (xBlue'=xBlue-1) + 1/3: (yBlue'=yBlue-1) & (xBlue'=xBlue+1) & (move'=2) ;
[Blueslip_north] move=1 & viewBlue=3 & xBlue=4 & yBlue=7 -> 1/3 : (xBlue'=xBlue-1) + 1/3: (xBlue'=xBlue-1) & (yBlue'=yBlue-1) + 1/3: (xBlue'=xBlue-1) & (yBlue'=yBlue+1) & (move'=2) ;
[Blueslip_east] move=1 & viewBlue=0 & xBlue=4 & yBlue=7 -> 1/3 : (yBlue'=yBlue+1) + 1/3: (yBlue'=yBlue+1) & (xBlue'=xBlue+1) + 1/3: (yBlue'=yBlue+1) & (xBlue'=xBlue-1) & (move'=2) ;
[Blueslip_south] move=1 & viewBlue=1 & xBlue=4 & yBlue=7 -> 1/3 : (xBlue'=xBlue+1) + 1/3: (xBlue'=xBlue+1) & (yBlue'=yBlue-1) + 1/3: (xBlue'=xBlue+1) & (yBlue'=yBlue+1) & (move'=2) ;
[Blueslip_west] move=1 & viewBlue=2 & xBlue=4 & yBlue=7 -> 1/3 : (yBlue'=yBlue-1) + 1/3: (yBlue'=yBlue-1) & (xBlue'=xBlue-1) + 1/3: (yBlue'=yBlue-1) & (xBlue'=xBlue+1) & (move'=2) ;
[Blueslip_north] move=1 & viewBlue=3 & xBlue=4 & yBlue=9 -> 1/3 : (xBlue'=xBlue-1) + 1/3: (xBlue'=xBlue-1) & (yBlue'=yBlue-1) + 1/3: (xBlue'=xBlue-1) & (yBlue'=yBlue+1) & (move'=2) ;
[Blueslip_east] move=1 & viewBlue=0 & xBlue=4 & yBlue=9 -> 1/3 : (yBlue'=yBlue+1) + 1/3: (yBlue'=yBlue+1) & (xBlue'=xBlue+1) + 1/3: (yBlue'=yBlue+1) & (xBlue'=xBlue-1) & (move'=2) ;
[Blueslip_south] move=1 & viewBlue=1 & xBlue=4 & yBlue=9 -> 1/3 : (xBlue'=xBlue+1) + 1/3: (xBlue'=xBlue+1) & (yBlue'=yBlue-1) + 1/3: (xBlue'=xBlue+1) & (yBlue'=yBlue+1) & (move'=2) ;
[Blueslip_west] move=1 & viewBlue=2 & xBlue=4 & yBlue=9 -> 1/3 : (yBlue'=yBlue-1) + 1/3: (yBlue'=yBlue-1) & (xBlue'=xBlue-1) + 1/3: (yBlue'=yBlue-1) & (xBlue'=xBlue+1) & (move'=2) ;
[Blueslip_north] move=1 & viewBlue=3 & xBlue=5 & yBlue=10 -> 1/3 : (xBlue'=xBlue-1) + 1/3: (xBlue'=xBlue-1) & (yBlue'=yBlue-1) + 1/3: (xBlue'=xBlue-1) & (yBlue'=yBlue+1) & (move'=2) ;
[Blueslip_east] move=1 & viewBlue=0 & xBlue=5 & yBlue=10 -> 1/3 : (yBlue'=yBlue+1) + 1/3: (yBlue'=yBlue+1) & (xBlue'=xBlue+1) + 1/3: (yBlue'=yBlue+1) & (xBlue'=xBlue-1) & (move'=2) ;
[Blueslip_south] move=1 & viewBlue=1 & xBlue=5 & yBlue=10 -> 1/3 : (xBlue'=xBlue+1) + 1/3: (xBlue'=xBlue+1) & (yBlue'=yBlue-1) + 1/3: (xBlue'=xBlue+1) & (yBlue'=yBlue+1) & (move'=2) ;
[Blueslip_west] move=1 & viewBlue=2 & xBlue=5 & yBlue=10 -> 1/3 : (yBlue'=yBlue-1) + 1/3: (yBlue'=yBlue-1) & (xBlue'=xBlue-1) + 1/3: (yBlue'=yBlue-1) & (xBlue'=xBlue+1) & (move'=2) ;
[Blueslip_north] move=1 & viewBlue=3 & xBlue=6 & yBlue=4 -> 1/3 : (xBlue'=xBlue-1) + 1/3: (xBlue'=xBlue-1) & (yBlue'=yBlue-1) + 1/3: (xBlue'=xBlue-1) & (yBlue'=yBlue+1) & (move'=2) ;
[Blueslip_east] move=1 & viewBlue=0 & xBlue=6 & yBlue=4 -> 1/3 : (yBlue'=yBlue+1) + 1/3: (yBlue'=yBlue+1) & (xBlue'=xBlue+1) + 1/3: (yBlue'=yBlue+1) & (xBlue'=xBlue-1) & (move'=2) ;
[Blueslip_south] move=1 & viewBlue=1 & xBlue=6 & yBlue=4 -> 1/3 : (xBlue'=xBlue+1) + 1/3: (xBlue'=xBlue+1) & (yBlue'=yBlue-1) + 1/3: (xBlue'=xBlue+1) & (yBlue'=yBlue+1) & (move'=2) ;
[Blueslip_west] move=1 & viewBlue=2 & xBlue=6 & yBlue=4 -> 1/3 : (yBlue'=yBlue-1) + 1/3: (yBlue'=yBlue-1) & (xBlue'=xBlue-1) + 1/3: (yBlue'=yBlue-1) & (xBlue'=xBlue+1) & (move'=2) ;
[Blueslip_north] move=1 & viewBlue=3 & xBlue=7 & yBlue=3 -> 1/3 : (xBlue'=xBlue-1) + 1/3: (xBlue'=xBlue-1) & (yBlue'=yBlue-1) + 1/3: (xBlue'=xBlue-1) & (yBlue'=yBlue+1) & (move'=2) ;
[Blueslip_east] move=1 & viewBlue=0 & xBlue=7 & yBlue=3 -> 1/3 : (yBlue'=yBlue+1) + 1/3: (yBlue'=yBlue+1) & (xBlue'=xBlue+1) + 1/3: (yBlue'=yBlue+1) & (xBlue'=xBlue-1) & (move'=2) ;
[Blueslip_south] move=1 & viewBlue=1 & xBlue=7 & yBlue=3 -> 1/3 : (xBlue'=xBlue+1) + 1/3: (xBlue'=xBlue+1) & (yBlue'=yBlue-1) + 1/3: (xBlue'=xBlue+1) & (yBlue'=yBlue+1) & (move'=2) ;
[Blueslip_west] move=1 & viewBlue=2 & xBlue=7 & yBlue=3 -> 1/3 : (yBlue'=yBlue-1) + 1/3: (yBlue'=yBlue-1) & (xBlue'=xBlue-1) + 1/3: (yBlue'=yBlue-1) & (xBlue'=xBlue+1) & (move'=2) ;
[Blueslip_north] move=1 & viewBlue=3 & xBlue=7 & yBlue=6 -> 1/3 : (xBlue'=xBlue-1) + 1/3: (xBlue'=xBlue-1) & (yBlue'=yBlue-1) + 1/3: (xBlue'=xBlue-1) & (yBlue'=yBlue+1) & (move'=2) ;
[Blueslip_east] move=1 & viewBlue=0 & xBlue=7 & yBlue=6 -> 1/3 : (yBlue'=yBlue+1) + 1/3: (yBlue'=yBlue+1) & (xBlue'=xBlue+1) + 1/3: (yBlue'=yBlue+1) & (xBlue'=xBlue-1) & (move'=2) ;
[Blueslip_south] move=1 & viewBlue=1 & xBlue=7 & yBlue=6 -> 1/3 : (xBlue'=xBlue+1) + 1/3: (xBlue'=xBlue+1) & (yBlue'=yBlue-1) + 1/3: (xBlue'=xBlue+1) & (yBlue'=yBlue+1) & (move'=2) ;
[Blueslip_west] move=1 & viewBlue=2 & xBlue=7 & yBlue=6 -> 1/3 : (yBlue'=yBlue-1) + 1/3: (yBlue'=yBlue-1) & (xBlue'=xBlue-1) + 1/3: (yBlue'=yBlue-1) & (xBlue'=xBlue+1) & (move'=2) ;
[Blueslip_north] move=1 & viewBlue=3 & xBlue=7 & yBlue=9 -> 1/3 : (xBlue'=xBlue-1) + 1/3: (xBlue'=xBlue-1) & (yBlue'=yBlue-1) + 1/3: (xBlue'=xBlue-1) & (yBlue'=yBlue+1) & (move'=2) ;
[Blueslip_east] move=1 & viewBlue=0 & xBlue=7 & yBlue=9 -> 1/3 : (yBlue'=yBlue+1) + 1/3: (yBlue'=yBlue+1) & (xBlue'=xBlue+1) + 1/3: (yBlue'=yBlue+1) & (xBlue'=xBlue-1) & (move'=2) ;
[Blueslip_south] move=1 & viewBlue=1 & xBlue=7 & yBlue=9 -> 1/3 : (xBlue'=xBlue+1) + 1/3: (xBlue'=xBlue+1) & (yBlue'=yBlue-1) + 1/3: (xBlue'=xBlue+1) & (yBlue'=yBlue+1) & (move'=2) ;
[Blueslip_west] move=1 & viewBlue=2 & xBlue=7 & yBlue=9 -> 1/3 : (yBlue'=yBlue-1) + 1/3: (yBlue'=yBlue-1) & (xBlue'=xBlue-1) + 1/3: (yBlue'=yBlue-1) & (xBlue'=xBlue+1) & (move'=2) ;
[Blueslip_north] move=1 & viewBlue=3 & xBlue=8 & yBlue=2 -> 1/3 : (xBlue'=xBlue-1) + 1/3: (xBlue'=xBlue-1) & (yBlue'=yBlue-1) + 1/3: (xBlue'=xBlue-1) & (yBlue'=yBlue+1) & (move'=2) ;
[Blueslip_east] move=1 & viewBlue=0 & xBlue=8 & yBlue=2 -> 1/3 : (yBlue'=yBlue+1) + 1/3: (yBlue'=yBlue+1) & (xBlue'=xBlue+1) + 1/3: (yBlue'=yBlue+1) & (xBlue'=xBlue-1) & (move'=2) ;
[Blueslip_south] move=1 & viewBlue=1 & xBlue=8 & yBlue=2 -> 1/3 : (xBlue'=xBlue+1) + 1/3: (xBlue'=xBlue+1) & (yBlue'=yBlue-1) + 1/3: (xBlue'=xBlue+1) & (yBlue'=yBlue+1) & (move'=2) ;
[Blueslip_west] move=1 & viewBlue=2 & xBlue=8 & yBlue=2 -> 1/3 : (yBlue'=yBlue-1) + 1/3: (yBlue'=yBlue-1) & (xBlue'=xBlue-1) + 1/3: (yBlue'=yBlue-1) & (xBlue'=xBlue+1) & (move'=2) ;
[Blueslip_north] move=1 & viewBlue=3 & xBlue=9 & yBlue=4 -> 1/3 : (xBlue'=xBlue-1) + 1/3: (xBlue'=xBlue-1) & (yBlue'=yBlue-1) + 1/3: (xBlue'=xBlue-1) & (yBlue'=yBlue+1) & (move'=2) ;
[Blueslip_east] move=1 & viewBlue=0 & xBlue=9 & yBlue=4 -> 2/3 : (yBlue'=yBlue+1) + 1/3: (yBlue'=yBlue+1) & (xBlue'=xBlue-1) & (move'=2) ;
[Blueslip_south] move=1 & viewBlue=1 & xBlue=9 & yBlue=4 -> 3/3 : (xBlue'=xBlue+1) & (move'=2) ;
[Blueslip_west] move=1 & viewBlue=2 & xBlue=9 & yBlue=4 -> 2/3 : (yBlue'=yBlue-1) + 1/3: (yBlue'=yBlue-1) & (xBlue'=xBlue-1) & (move'=2) ;
[Blueslip_north] move=1 & viewBlue=3 & xBlue=9 & yBlue=7 -> 1/3 : (xBlue'=xBlue-1) + 1/3: (xBlue'=xBlue-1) & (yBlue'=yBlue-1) + 1/3: (xBlue'=xBlue-1) & (yBlue'=yBlue+1) & (move'=2) ;
[Blueslip_east] move=1 & viewBlue=0 & xBlue=9 & yBlue=7 -> 2/3 : (yBlue'=yBlue+1) + 1/3: (yBlue'=yBlue+1) & (xBlue'=xBlue-1) & (move'=2) ;
[Blueslip_south] move=1 & viewBlue=1 & xBlue=9 & yBlue=7 -> 3/3 : (xBlue'=xBlue+1) & (move'=2) ;
[Blueslip_west] move=1 & viewBlue=2 & xBlue=9 & yBlue=7 -> 2/3 : (yBlue'=yBlue-1) + 1/3: (yBlue'=yBlue-1) & (xBlue'=xBlue-1) & (move'=2) ;
[Blueslip_north] move=1 & viewBlue=3 & xBlue=9 & yBlue=10 -> 1/3 : (xBlue'=xBlue-1) + 1/3: (xBlue'=xBlue-1) & (yBlue'=yBlue-1) + 1/3: (xBlue'=xBlue-1) & (yBlue'=yBlue+1) & (move'=2) ;
[Blueslip_east] move=1 & viewBlue=0 & xBlue=9 & yBlue=10 -> 1/3 : (yBlue'=yBlue+1) + 1/3: (yBlue'=yBlue+1) & (xBlue'=xBlue+1) + 1/3: (yBlue'=yBlue+1) & (xBlue'=xBlue-1) & (move'=2) ;
[Blueslip_south] move=1 & viewBlue=1 & xBlue=9 & yBlue=10 -> 2/3 : (xBlue'=xBlue+1) + 1/3: (xBlue'=xBlue+1) & (yBlue'=yBlue+1) & (move'=2) ;
[Blueslip_west] move=1 & viewBlue=2 & xBlue=9 & yBlue=10 -> 2/3 : (yBlue'=yBlue-1) + 1/3: (yBlue'=yBlue-1) & (xBlue'=xBlue-1) & (move'=2) ;
endmodule
player Blue
[Blue_move_north], [Blue_move_east], [Blue_move_south], [Blue_move_west], [Blue_turn_left], [Blue_turn_right], [Blueslip_east] , [Blueslip_north], [Blueslip_south], [Blueslip_west]
endplayer
module Green
xGreen : [1..12] init 4;
yGreen : [1..12] init 1;
viewGreen : [0..3] init 1;
[Green_turn_right] move=2 & true -> (viewGreen'=mod(viewGreen + 1, 4)) & (move'=0) ;
[Green_turn_left] move=2 & viewGreen>0 -> (viewGreen'=viewGreen - 1) & (move'=0) ;
[Green_turn_left] move=2 & viewGreen=0 -> (viewGreen'=3) & (move'=0) ;
[Green_move_north] move=2 & viewGreen=3 & !GreenIsOnSlippery & !GreenCannotMoveNorth -> (xGreen'=xGreen-1) & (move'=0) ;
[Green_move_east] move=2 & viewGreen=0 & !GreenIsOnSlippery & !GreenCannotMoveEast -> (yGreen'=yGreen+1) & (move'=0) ;
[Green_move_south] move=2 & viewGreen=1 & !GreenIsOnSlippery & !GreenCannotMoveSouth -> (xGreen'=xGreen+1) & (move'=0) ;
[Green_move_west] move=2 & viewGreen=2 & !GreenIsOnSlippery & !GreenCannotMoveWest -> (yGreen'=yGreen-1) & (move'=0) ;
[Greenslip_north] move=2 & viewGreen=3 & xGreen=3 & yGreen=11 -> 3/3 : (xGreen'=xGreen-1) & (move'=0) ;
[Greenslip_east] move=2 & viewGreen=0 & xGreen=3 & yGreen=11 -> 3/3 : (yGreen'=yGreen+1) & (move'=0) ;
[Greenslip_south] move=2 & viewGreen=1 & xGreen=3 & yGreen=11 -> 2/3 : (xGreen'=xGreen+1) + 1/3: (xGreen'=xGreen+1) & (yGreen'=yGreen-1) & (move'=0) ;
[Greenslip_west] move=2 & viewGreen=2 & xGreen=3 & yGreen=11 -> 2/3 : (yGreen'=yGreen-1) + 1/3: (yGreen'=yGreen-1) & (xGreen'=xGreen+1) & (move'=0) ;
[Greenslip_north] move=2 & viewGreen=3 & xGreen=4 & yGreen=2 -> 1/3 : (xGreen'=xGreen-1) + 1/3: (xGreen'=xGreen-1) & (yGreen'=yGreen-1) + 1/3: (xGreen'=xGreen-1) & (yGreen'=yGreen+1) & (move'=0) ;
[Greenslip_east] move=2 & viewGreen=0 & xGreen=4 & yGreen=2 -> 1/3 : (yGreen'=yGreen+1) + 1/3: (yGreen'=yGreen+1) & (xGreen'=xGreen+1) + 1/3: (yGreen'=yGreen+1) & (xGreen'=xGreen-1) & (move'=0) ;
[Greenslip_south] move=2 & viewGreen=1 & xGreen=4 & yGreen=2 -> 1/3 : (xGreen'=xGreen+1) + 1/3: (xGreen'=xGreen+1) & (yGreen'=yGreen-1) + 1/3: (xGreen'=xGreen+1) & (yGreen'=yGreen+1) & (move'=0) ;
[Greenslip_west] move=2 & viewGreen=2 & xGreen=4 & yGreen=2 -> 1/3 : (yGreen'=yGreen-1) + 1/3: (yGreen'=yGreen-1) & (xGreen'=xGreen-1) + 1/3: (yGreen'=yGreen-1) & (xGreen'=xGreen+1) & (move'=0) ;
[Greenslip_north] move=2 & viewGreen=3 & xGreen=4 & yGreen=4 -> 1/3 : (xGreen'=xGreen-1) + 1/3: (xGreen'=xGreen-1) & (yGreen'=yGreen-1) + 1/3: (xGreen'=xGreen-1) & (yGreen'=yGreen+1) & (move'=0) ;
[Greenslip_east] move=2 & viewGreen=0 & xGreen=4 & yGreen=4 -> 1/3 : (yGreen'=yGreen+1) + 1/3: (yGreen'=yGreen+1) & (xGreen'=xGreen+1) + 1/3: (yGreen'=yGreen+1) & (xGreen'=xGreen-1) & (move'=0) ;
[Greenslip_south] move=2 & viewGreen=1 & xGreen=4 & yGreen=4 -> 1/3 : (xGreen'=xGreen+1) + 1/3: (xGreen'=xGreen+1) & (yGreen'=yGreen-1) + 1/3: (xGreen'=xGreen+1) & (yGreen'=yGreen+1) & (move'=0) ;
[Greenslip_west] move=2 & viewGreen=2 & xGreen=4 & yGreen=4 -> 1/3 : (yGreen'=yGreen-1) + 1/3: (yGreen'=yGreen-1) & (xGreen'=xGreen-1) + 1/3: (yGreen'=yGreen-1) & (xGreen'=xGreen+1) & (move'=0) ;
[Greenslip_north] move=2 & viewGreen=3 & xGreen=4 & yGreen=5 -> 1/3 : (xGreen'=xGreen-1) + 1/3: (xGreen'=xGreen-1) & (yGreen'=yGreen-1) + 1/3: (xGreen'=xGreen-1) & (yGreen'=yGreen+1) & (move'=0) ;
[Greenslip_east] move=2 & viewGreen=0 & xGreen=4 & yGreen=5 -> 1/3 : (yGreen'=yGreen+1) + 1/3: (yGreen'=yGreen+1) & (xGreen'=xGreen+1) + 1/3: (yGreen'=yGreen+1) & (xGreen'=xGreen-1) & (move'=0) ;
[Greenslip_south] move=2 & viewGreen=1 & xGreen=4 & yGreen=5 -> 1/3 : (xGreen'=xGreen+1) + 1/3: (xGreen'=xGreen+1) & (yGreen'=yGreen-1) + 1/3: (xGreen'=xGreen+1) & (yGreen'=yGreen+1) & (move'=0) ;
[Greenslip_west] move=2 & viewGreen=2 & xGreen=4 & yGreen=5 -> 1/3 : (yGreen'=yGreen-1) + 1/3: (yGreen'=yGreen-1) & (xGreen'=xGreen-1) + 1/3: (yGreen'=yGreen-1) & (xGreen'=xGreen+1) & (move'=0) ;
[Greenslip_north] move=2 & viewGreen=3 & xGreen=4 & yGreen=7 -> 1/3 : (xGreen'=xGreen-1) + 1/3: (xGreen'=xGreen-1) & (yGreen'=yGreen-1) + 1/3: (xGreen'=xGreen-1) & (yGreen'=yGreen+1) & (move'=0) ;
[Greenslip_east] move=2 & viewGreen=0 & xGreen=4 & yGreen=7 -> 1/3 : (yGreen'=yGreen+1) + 1/3: (yGreen'=yGreen+1) & (xGreen'=xGreen+1) + 1/3: (yGreen'=yGreen+1) & (xGreen'=xGreen-1) & (move'=0) ;
[Greenslip_south] move=2 & viewGreen=1 & xGreen=4 & yGreen=7 -> 1/3 : (xGreen'=xGreen+1) + 1/3: (xGreen'=xGreen+1) & (yGreen'=yGreen-1) + 1/3: (xGreen'=xGreen+1) & (yGreen'=yGreen+1) & (move'=0) ;
[Greenslip_west] move=2 & viewGreen=2 & xGreen=4 & yGreen=7 -> 1/3 : (yGreen'=yGreen-1) + 1/3: (yGreen'=yGreen-1) & (xGreen'=xGreen-1) + 1/3: (yGreen'=yGreen-1) & (xGreen'=xGreen+1) & (move'=0) ;
[Greenslip_north] move=2 & viewGreen=3 & xGreen=4 & yGreen=9 -> 1/3 : (xGreen'=xGreen-1) + 1/3: (xGreen'=xGreen-1) & (yGreen'=yGreen-1) + 1/3: (xGreen'=xGreen-1) & (yGreen'=yGreen+1) & (move'=0) ;
[Greenslip_east] move=2 & viewGreen=0 & xGreen=4 & yGreen=9 -> 1/3 : (yGreen'=yGreen+1) + 1/3: (yGreen'=yGreen+1) & (xGreen'=xGreen+1) + 1/3: (yGreen'=yGreen+1) & (xGreen'=xGreen-1) & (move'=0) ;
[Greenslip_south] move=2 & viewGreen=1 & xGreen=4 & yGreen=9 -> 1/3 : (xGreen'=xGreen+1) + 1/3: (xGreen'=xGreen+1) & (yGreen'=yGreen-1) + 1/3: (xGreen'=xGreen+1) & (yGreen'=yGreen+1) & (move'=0) ;
[Greenslip_west] move=2 & viewGreen=2 & xGreen=4 & yGreen=9 -> 1/3 : (yGreen'=yGreen-1) + 1/3: (yGreen'=yGreen-1) & (xGreen'=xGreen-1) + 1/3: (yGreen'=yGreen-1) & (xGreen'=xGreen+1) & (move'=0) ;
[Greenslip_north] move=2 & viewGreen=3 & xGreen=5 & yGreen=10 -> 1/3 : (xGreen'=xGreen-1) + 1/3: (xGreen'=xGreen-1) & (yGreen'=yGreen-1) + 1/3: (xGreen'=xGreen-1) & (yGreen'=yGreen+1) & (move'=0) ;
[Greenslip_east] move=2 & viewGreen=0 & xGreen=5 & yGreen=10 -> 1/3 : (yGreen'=yGreen+1) + 1/3: (yGreen'=yGreen+1) & (xGreen'=xGreen+1) + 1/3: (yGreen'=yGreen+1) & (xGreen'=xGreen-1) & (move'=0) ;
[Greenslip_south] move=2 & viewGreen=1 & xGreen=5 & yGreen=10 -> 1/3 : (xGreen'=xGreen+1) + 1/3: (xGreen'=xGreen+1) & (yGreen'=yGreen-1) + 1/3: (xGreen'=xGreen+1) & (yGreen'=yGreen+1) & (move'=0) ;
[Greenslip_west] move=2 & viewGreen=2 & xGreen=5 & yGreen=10 -> 1/3 : (yGreen'=yGreen-1) + 1/3: (yGreen'=yGreen-1) & (xGreen'=xGreen-1) + 1/3: (yGreen'=yGreen-1) & (xGreen'=xGreen+1) & (move'=0) ;
[Greenslip_north] move=2 & viewGreen=3 & xGreen=6 & yGreen=4 -> 1/3 : (xGreen'=xGreen-1) + 1/3: (xGreen'=xGreen-1) & (yGreen'=yGreen-1) + 1/3: (xGreen'=xGreen-1) & (yGreen'=yGreen+1) & (move'=0) ;
[Greenslip_east] move=2 & viewGreen=0 & xGreen=6 & yGreen=4 -> 1/3 : (yGreen'=yGreen+1) + 1/3: (yGreen'=yGreen+1) & (xGreen'=xGreen+1) + 1/3: (yGreen'=yGreen+1) & (xGreen'=xGreen-1) & (move'=0) ;
[Greenslip_south] move=2 & viewGreen=1 & xGreen=6 & yGreen=4 -> 1/3 : (xGreen'=xGreen+1) + 1/3: (xGreen'=xGreen+1) & (yGreen'=yGreen-1) + 1/3: (xGreen'=xGreen+1) & (yGreen'=yGreen+1) & (move'=0) ;
[Greenslip_west] move=2 & viewGreen=2 & xGreen=6 & yGreen=4 -> 1/3 : (yGreen'=yGreen-1) + 1/3: (yGreen'=yGreen-1) & (xGreen'=xGreen-1) + 1/3: (yGreen'=yGreen-1) & (xGreen'=xGreen+1) & (move'=0) ;
[Greenslip_north] move=2 & viewGreen=3 & xGreen=7 & yGreen=3 -> 1/3 : (xGreen'=xGreen-1) + 1/3: (xGreen'=xGreen-1) & (yGreen'=yGreen-1) + 1/3: (xGreen'=xGreen-1) & (yGreen'=yGreen+1) & (move'=0) ;
[Greenslip_east] move=2 & viewGreen=0 & xGreen=7 & yGreen=3 -> 1/3 : (yGreen'=yGreen+1) + 1/3: (yGreen'=yGreen+1) & (xGreen'=xGreen+1) + 1/3: (yGreen'=yGreen+1) & (xGreen'=xGreen-1) & (move'=0) ;
[Greenslip_south] move=2 & viewGreen=1 & xGreen=7 & yGreen=3 -> 1/3 : (xGreen'=xGreen+1) + 1/3: (xGreen'=xGreen+1) & (yGreen'=yGreen-1) + 1/3: (xGreen'=xGreen+1) & (yGreen'=yGreen+1) & (move'=0) ;
[Greenslip_west] move=2 & viewGreen=2 & xGreen=7 & yGreen=3 -> 1/3 : (yGreen'=yGreen-1) + 1/3: (yGreen'=yGreen-1) & (xGreen'=xGreen-1) + 1/3: (yGreen'=yGreen-1) & (xGreen'=xGreen+1) & (move'=0) ;
[Greenslip_north] move=2 & viewGreen=3 & xGreen=7 & yGreen=6 -> 1/3 : (xGreen'=xGreen-1) + 1/3: (xGreen'=xGreen-1) & (yGreen'=yGreen-1) + 1/3: (xGreen'=xGreen-1) & (yGreen'=yGreen+1) & (move'=0) ;
[Greenslip_east] move=2 & viewGreen=0 & xGreen=7 & yGreen=6 -> 1/3 : (yGreen'=yGreen+1) + 1/3: (yGreen'=yGreen+1) & (xGreen'=xGreen+1) + 1/3: (yGreen'=yGreen+1) & (xGreen'=xGreen-1) & (move'=0) ;
[Greenslip_south] move=2 & viewGreen=1 & xGreen=7 & yGreen=6 -> 1/3 : (xGreen'=xGreen+1) + 1/3: (xGreen'=xGreen+1) & (yGreen'=yGreen-1) + 1/3: (xGreen'=xGreen+1) & (yGreen'=yGreen+1) & (move'=0) ;
[Greenslip_west] move=2 & viewGreen=2 & xGreen=7 & yGreen=6 -> 1/3 : (yGreen'=yGreen-1) + 1/3: (yGreen'=yGreen-1) & (xGreen'=xGreen-1) + 1/3: (yGreen'=yGreen-1) & (xGreen'=xGreen+1) & (move'=0) ;
[Greenslip_north] move=2 & viewGreen=3 & xGreen=7 & yGreen=9 -> 1/3 : (xGreen'=xGreen-1) + 1/3: (xGreen'=xGreen-1) & (yGreen'=yGreen-1) + 1/3: (xGreen'=xGreen-1) & (yGreen'=yGreen+1) & (move'=0) ;
[Greenslip_east] move=2 & viewGreen=0 & xGreen=7 & yGreen=9 -> 1/3 : (yGreen'=yGreen+1) + 1/3: (yGreen'=yGreen+1) & (xGreen'=xGreen+1) + 1/3: (yGreen'=yGreen+1) & (xGreen'=xGreen-1) & (move'=0) ;
[Greenslip_south] move=2 & viewGreen=1 & xGreen=7 & yGreen=9 -> 1/3 : (xGreen'=xGreen+1) + 1/3: (xGreen'=xGreen+1) & (yGreen'=yGreen-1) + 1/3: (xGreen'=xGreen+1) & (yGreen'=yGreen+1) & (move'=0) ;
[Greenslip_west] move=2 & viewGreen=2 & xGreen=7 & yGreen=9 -> 1/3 : (yGreen'=yGreen-1) + 1/3: (yGreen'=yGreen-1) & (xGreen'=xGreen-1) + 1/3: (yGreen'=yGreen-1) & (xGreen'=xGreen+1) & (move'=0) ;
[Greenslip_north] move=2 & viewGreen=3 & xGreen=8 & yGreen=2 -> 1/3 : (xGreen'=xGreen-1) + 1/3: (xGreen'=xGreen-1) & (yGreen'=yGreen-1) + 1/3: (xGreen'=xGreen-1) & (yGreen'=yGreen+1) & (move'=0) ;
[Greenslip_east] move=2 & viewGreen=0 & xGreen=8 & yGreen=2 -> 1/3 : (yGreen'=yGreen+1) + 1/3: (yGreen'=yGreen+1) & (xGreen'=xGreen+1) + 1/3: (yGreen'=yGreen+1) & (xGreen'=xGreen-1) & (move'=0) ;
[Greenslip_south] move=2 & viewGreen=1 & xGreen=8 & yGreen=2 -> 1/3 : (xGreen'=xGreen+1) + 1/3: (xGreen'=xGreen+1) & (yGreen'=yGreen-1) + 1/3: (xGreen'=xGreen+1) & (yGreen'=yGreen+1) & (move'=0) ;
[Greenslip_west] move=2 & viewGreen=2 & xGreen=8 & yGreen=2 -> 1/3 : (yGreen'=yGreen-1) + 1/3: (yGreen'=yGreen-1) & (xGreen'=xGreen-1) + 1/3: (yGreen'=yGreen-1) & (xGreen'=xGreen+1) & (move'=0) ;
[Greenslip_north] move=2 & viewGreen=3 & xGreen=9 & yGreen=4 -> 1/3 : (xGreen'=xGreen-1) + 1/3: (xGreen'=xGreen-1) & (yGreen'=yGreen-1) + 1/3: (xGreen'=xGreen-1) & (yGreen'=yGreen+1) & (move'=0) ;
[Greenslip_east] move=2 & viewGreen=0 & xGreen=9 & yGreen=4 -> 2/3 : (yGreen'=yGreen+1) + 1/3: (yGreen'=yGreen+1) & (xGreen'=xGreen-1) & (move'=0) ;
[Greenslip_south] move=2 & viewGreen=1 & xGreen=9 & yGreen=4 -> 3/3 : (xGreen'=xGreen+1) & (move'=0) ;
[Greenslip_west] move=2 & viewGreen=2 & xGreen=9 & yGreen=4 -> 2/3 : (yGreen'=yGreen-1) + 1/3: (yGreen'=yGreen-1) & (xGreen'=xGreen-1) & (move'=0) ;
[Greenslip_north] move=2 & viewGreen=3 & xGreen=9 & yGreen=7 -> 1/3 : (xGreen'=xGreen-1) + 1/3: (xGreen'=xGreen-1) & (yGreen'=yGreen-1) + 1/3: (xGreen'=xGreen-1) & (yGreen'=yGreen+1) & (move'=0) ;
[Greenslip_east] move=2 & viewGreen=0 & xGreen=9 & yGreen=7 -> 2/3 : (yGreen'=yGreen+1) + 1/3: (yGreen'=yGreen+1) & (xGreen'=xGreen-1) & (move'=0) ;
[Greenslip_south] move=2 & viewGreen=1 & xGreen=9 & yGreen=7 -> 3/3 : (xGreen'=xGreen+1) & (move'=0) ;
[Greenslip_west] move=2 & viewGreen=2 & xGreen=9 & yGreen=7 -> 2/3 : (yGreen'=yGreen-1) + 1/3: (yGreen'=yGreen-1) & (xGreen'=xGreen-1) & (move'=0) ;
[Greenslip_north] move=2 & viewGreen=3 & xGreen=9 & yGreen=10 -> 1/3 : (xGreen'=xGreen-1) + 1/3: (xGreen'=xGreen-1) & (yGreen'=yGreen-1) + 1/3: (xGreen'=xGreen-1) & (yGreen'=yGreen+1) & (move'=0) ;
[Greenslip_east] move=2 & viewGreen=0 & xGreen=9 & yGreen=10 -> 1/3 : (yGreen'=yGreen+1) + 1/3: (yGreen'=yGreen+1) & (xGreen'=xGreen+1) + 1/3: (yGreen'=yGreen+1) & (xGreen'=xGreen-1) & (move'=0) ;
[Greenslip_south] move=2 & viewGreen=1 & xGreen=9 & yGreen=10 -> 2/3 : (xGreen'=xGreen+1) + 1/3: (xGreen'=xGreen+1) & (yGreen'=yGreen+1) & (move'=0) ;
[Greenslip_west] move=2 & viewGreen=2 & xGreen=9 & yGreen=10 -> 2/3 : (yGreen'=yGreen-1) + 1/3: (yGreen'=yGreen-1) & (xGreen'=xGreen-1) & (move'=0) ;
endmodule
player Green
[Green_move_north], [Green_move_east], [Green_move_south], [Green_move_west], [Green_turn_left], [Green_turn_right], [Greenslip_east] , [Greenslip_north], [Greenslip_south], [Greenslip_west]
endplayer

1
Minigrid2PRISM/test.prop

@ -0,0 +1 @@
<<Agent>> Pmax=? [ F "AgentGoal" ];

5
Minigrid2PRISM/testGrid

@ -0,0 +1,5 @@
WGWGWGWGWG
WGSR WG
WG WG WG
WG WG
WGWGWGWGWG

6
Minigrid2PRISM/testGridWithSlippery

@ -0,0 +1,6 @@
WGWGWGWGWGWGWGWGWGWGWG
WGSB LB WG
WG SB WG WG
WG WG WG
WG WG WG
WGWGWGWGWGWGWGWGWGWGWG

7
Minigrid2PRISM/testGridWithSlipperyAnnotated

@ -0,0 +1,7 @@
1 2 3 4 5 6 7 8 9 1011
1 WGWGWGWGWGWGWGWGWGWGWG
2 WGSB LB WG
3 WG SB WG WG
4 WG WG WG
5 WG WG WG
6 WGWGWGWGDPWGWGWGWGWGWG

8
Minigrid2PRISM/util/CMakeLists.txt

@ -0,0 +1,8 @@
list(APPEND SRCS
${CMAKE_CURRENT_LIST_DIR}/cell.cpp
${CMAKE_CURRENT_LIST_DIR}/MinigridGrammar.h
${CMAKE_CURRENT_LIST_DIR}/Grid.cpp
${CMAKE_CURRENT_LIST_DIR}/PrismModulesPrinter.cpp
${CMAKE_CURRENT_LIST_DIR}/popl.hpp
${CMAKE_CURRENT_LIST_DIR}/OptionParser.cpp
)

212
Minigrid2PRISM/util/Grid.cpp

@ -0,0 +1,212 @@
#include "Grid.h"
#include <algorithm>
Grid::Grid(cells gridCells, cells background, const GridOptions &gridOptions, const std::map<coordinates, float> &stateRewards)
: allGridCells(gridCells), background(background), gridOptions(gridOptions), stateRewards(stateRewards)
{
cell max = allGridCells.at(allGridCells.size() - 1);
maxBoundaries = std::make_pair(max.row, max.column);
std::copy_if(gridCells.begin(), gridCells.end(), std::back_inserter(walls), [](cell c) {
return c.type == Type::Wall;
});
std::copy_if(gridCells.begin(), gridCells.end(), std::back_inserter(lava), [](cell c) {
return c.type == Type::Lava;
});
std::copy_if(gridCells.begin(), gridCells.end(), std::back_inserter(floor), [](cell c) {
return c.type == Type::Floor;
});
std::copy_if(background.begin(), background.end(), std::back_inserter(slipperyNorth), [](cell c) {
return c.type == Type::SlipperyNorth;
});
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(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(goals), [](cell c) {
return c.type == Type::Goal;
});
std::copy_if(gridCells.begin(), gridCells.end(), std::back_inserter(keys), [](cell c) {
return c.type == Type::Key;
});
std::copy_if(gridCells.begin(), gridCells.end(), std::back_inserter(boxes), [](cell c) {
return c.type == Type::Box;
});
agent = *std::find_if(gridCells.begin(), gridCells.end(), [](cell c) {
return c.type == Type::Agent;
});
std::copy_if(gridCells.begin(), gridCells.end(), std::back_inserter(adversaries), [](cell c) {
return c.type == Type::Adversary;
});
agentNameAndPositionMap.insert({ "Agent", agent.getCoordinates() });
for(auto const& adversary : adversaries) {
std::string color = adversary.getColor();
color.at(0) = std::toupper(color.at(0));
try {
if(gridOptions.agentsToBeConsidered.size() != 0 && std::find(gridOptions.agentsToBeConsidered.begin(), gridOptions.agentsToBeConsidered.end(), color) == gridOptions.agentsToBeConsidered.end()) continue;
auto success = agentNameAndPositionMap.insert({ color, adversary.getCoordinates() });
if(!success.second) {
throw std::logic_error("Agent with " + color + " already present\n");
}
} catch(const std::logic_error& e) {
std::cerr << "Expected agents colors to be different. Agent with color : '" << color << "' already present." << std::endl;
throw;
}
}
for(auto const& color : allColors) {
cells cellsOfColor;
std::copy_if(background.begin(), background.end(), std::back_inserter(cellsOfColor), [&color](cell c) {
return c.type == Type::Floor && c.color == color;
});
backgroundTiles.emplace(color, cellsOfColor);
}
}
std::ostream& operator<<(std::ostream& os, const Grid& grid) {
int lastRow = 1;
for(auto const& cell : grid.allGridCells) {
if(lastRow != cell.row)
os << std::endl;
os << static_cast<char>(cell.type) << static_cast<char>(cell.color);
lastRow = cell.row;
}
return os;
}
cells Grid::getGridCells() {
return allGridCells;
}
bool Grid::isBlocked(coordinates p) {
return isWall(p) || isLockedDoor(p) || isKey(p);
}
bool Grid::isWall(coordinates p) {
return std::find_if(walls.begin(), walls.end(),
[p](cell cell) {
return cell.row == p.first && cell.column == p.second;
}) != walls.end();
}
bool Grid::isLockedDoor(coordinates p) {
return std::find_if(lockedDoors.begin(), lockedDoors.end(),
[p](cell cell) {
return cell.row == p.first && cell.column == p.second;
}) != lockedDoors.end();
}
bool Grid::isKey(coordinates p) {
return std::find_if(keys.begin(), keys.end(),
[p](cell cell) {
return cell.row == p.first && cell.column == p.second;
}) != keys.end();
}
bool Grid::isBox(coordinates p) {
return std::find_if(boxes.begin(), boxes.end(),
[p](cell cell) {
return cell.row == p.first && cell.column == p.second;
}) != boxes.end();
}
void Grid::printToPrism(std::ostream& os, const prism::ModelType& modelType) {
cells northRestriction;
cells eastRestriction;
cells southRestriction;
cells westRestriction;
cells walkable = floor;
walkable.insert(walkable.end(), goals.begin(), goals.end());
walkable.insert(walkable.end(), boxes.begin(), boxes.end());
walkable.push_back(agent);
walkable.insert(walkable.end(), adversaries.begin(), adversaries.end());
walkable.insert(walkable.end(), lava.begin(), lava.end());
for(auto const& c : walkable) {
if(isBlocked(c.getNorth())) northRestriction.push_back(c);
if(isBlocked(c.getEast())) eastRestriction.push_back(c);
if(isBlocked(c.getSouth())) southRestriction.push_back(c);
if(isBlocked(c.getWest())) westRestriction.push_back(c);
}
prism::PrismModulesPrinter printer(modelType, agentNameAndPositionMap.size());
printer.printModel(os, modelType);
if(modelType == prism::ModelType::SMG) {
printer.printGlobalMoveVariable(os, agentNameAndPositionMap.size());
}
for(auto const &backgroundTilesOfColor : backgroundTiles) {
for(auto agentNameAndPosition = agentNameAndPositionMap.begin(); agentNameAndPosition != agentNameAndPositionMap.end(); ++agentNameAndPosition) {
printer.printBackgroundLabels(os, agentNameAndPosition->first, backgroundTilesOfColor);
}
}
for(auto agentNameAndPosition = agentNameAndPositionMap.begin(); agentNameAndPosition != agentNameAndPositionMap.end(); ++agentNameAndPosition) {
printer.printFormulas(os, agentNameAndPosition->first, northRestriction, eastRestriction, southRestriction, westRestriction, { slipperyNorth, slipperyEast, slipperySouth, slipperyWest }, lava);
printer.printGoalLabel(os, agentNameAndPosition->first, goals);
printer.printKeysLabels(os, agentNameAndPosition->first, keys);
}
std::vector<AgentName> agentNames;
std::transform(agentNameAndPositionMap.begin(),
agentNameAndPositionMap.end(),
std::back_inserter(agentNames),
[](const std::map<AgentNameAndPosition::first_type,AgentNameAndPosition::second_type>::value_type &pair){return pair.first;});
if(modelType == prism::ModelType::SMG) {
printer.printCrashLabel(os, agentNames);
}
size_t agentIndex = 0;
for(auto agentNameAndPosition = agentNameAndPositionMap.begin(); agentNameAndPosition != agentNameAndPositionMap.end(); ++agentNameAndPosition, agentIndex++) {
AgentName agentName = agentNameAndPosition->first;
bool agentWithView = std::find(gridOptions.agentsWithView.begin(), gridOptions.agentsWithView.end(), agentName) != gridOptions.agentsWithView.end();
bool agentWithProbabilisticBehaviour = std::find(gridOptions.agentsWithProbabilisticBehaviour.begin(), gridOptions.agentsWithProbabilisticBehaviour.end(), agentName) != gridOptions.agentsWithProbabilisticBehaviour.end();
std::set<std::string> slipperyActions;
if(agentWithProbabilisticBehaviour) printer.printModule(os, agentName, agentIndex, maxBoundaries, agentNameAndPosition->second, keys, agentWithView, gridOptions.probabilitiesForActions);
else printer.printModule(os, agentName, agentIndex, maxBoundaries, agentNameAndPosition->second, keys, agentWithView);
for(auto const& c : slipperyNorth) {
printer.printSlipperyMove(os, agentName, agentIndex, c.getCoordinates(), slipperyActions, getWalkableDirOf8Neighborhood(c), prism::PrismModulesPrinter::SlipperyType::North);
printer.printSlipperyTurn(os, agentName, agentIndex, c.getCoordinates(), slipperyActions, getWalkableDirOf8Neighborhood(c), prism::PrismModulesPrinter::SlipperyType::North);
}
for(auto const& c : slipperyEast) {
printer.printSlipperyMove(os, agentName, agentIndex, c.getCoordinates(), slipperyActions, getWalkableDirOf8Neighborhood(c), prism::PrismModulesPrinter::SlipperyType::East);
printer.printSlipperyTurn(os, agentName, agentIndex, c.getCoordinates(), slipperyActions, getWalkableDirOf8Neighborhood(c), prism::PrismModulesPrinter::SlipperyType::East);
}
for(auto const& c : slipperySouth) {
printer.printSlipperyMove(os, agentName, agentIndex, c.getCoordinates(), slipperyActions, getWalkableDirOf8Neighborhood(c), prism::PrismModulesPrinter::SlipperyType::South);
printer.printSlipperyTurn(os, agentName, agentIndex, c.getCoordinates(), slipperyActions, getWalkableDirOf8Neighborhood(c), prism::PrismModulesPrinter::SlipperyType::South);
}
for(auto const& c : slipperyWest) {
printer.printSlipperyMove(os, agentName, agentIndex, c.getCoordinates(), slipperyActions, getWalkableDirOf8Neighborhood(c), prism::PrismModulesPrinter::SlipperyType::West);
printer.printSlipperyTurn(os, agentName, agentIndex, c.getCoordinates(), slipperyActions, getWalkableDirOf8Neighborhood(c), prism::PrismModulesPrinter::SlipperyType::West);
}
printer.printEndmodule(os);
if(modelType == prism::ModelType::SMG) {
if(agentWithProbabilisticBehaviour) printer.printPlayerStruct(os, agentNameAndPosition->first, agentWithView, gridOptions.probabilitiesForActions, slipperyActions);
else printer.printPlayerStruct(os, agentNameAndPosition->first, agentWithView, {}, slipperyActions);
}
if(!stateRewards.empty()) {
printer.printRewards(os, stateRewards, lava, goals);
}
}
}
std::array<bool, 8> Grid::getWalkableDirOf8Neighborhood(cell c) /* const */ {
return (std::array<bool, 8>)
{
!isBlocked(c.getNorth()),
!isBlocked(c.getNorth(allGridCells).getEast()),
!isBlocked(c.getEast()),
!isBlocked(c.getSouth(allGridCells).getEast()),
!isBlocked(c.getSouth()),
!isBlocked(c.getSouth(allGridCells).getWest()),
!isBlocked(c.getWest()),
!isBlocked(c.getNorth(allGridCells).getWest())
};
}

62
Minigrid2PRISM/util/Grid.h

@ -0,0 +1,62 @@
#pragma once
#include <iostream>
#include <fstream>
#include <map>
#include <utility>
#include "MinigridGrammar.h"
#include "PrismModulesPrinter.h"
struct GridOptions {
std::vector<AgentName> agentsToBeConsidered;
std::vector<AgentName> agentsWithView;
std::vector<AgentName> agentsWithProbabilisticBehaviour;
std::vector<float> probabilitiesForActions;
};
class Grid {
public:
Grid(cells gridCells, cells background, const GridOptions &gridOptions, const std::map<coordinates, float> &stateRewards = {});
cells getGridCells();
bool isBlocked(coordinates p);
bool isWall(coordinates p);
bool isLockedDoor(coordinates p);
bool isKey(coordinates p);
bool isBox(coordinates p);
void printToPrism(std::ostream &os, const prism::ModelType& modelType);
std::array<bool, 8> getWalkableDirOf8Neighborhood(cell c);
friend std::ostream& operator<<(std::ostream& os, const Grid &grid);
private:
GridOptions gridOptions;
cells allGridCells;
cells background;
coordinates maxBoundaries;
cell agent;
cells adversaries;
AgentNameAndPositionMap agentNameAndPositionMap;
cells walls;
cells floor;
cells slipperyNorth;
cells slipperyEast;
cells slipperySouth;
cells slipperyWest;
cells lockedDoors;
cells boxes;
cells lava;
cells goals;
cells keys;
std::map<Color, cells> backgroundTiles;
std::map<coordinates, float> stateRewards;
};

102
Minigrid2PRISM/util/MinigridGrammar.h

@ -0,0 +1,102 @@
#pragma once
#include "cell.h"
#include <vector>
#include <boost/tokenizer.hpp>
#include <boost/fusion/adapted/struct.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/variant/recursive_wrapper.hpp>
#include <boost/spirit/include/support_line_pos_iterator.hpp>
namespace qi = boost::spirit::qi;
namespace phoenix = boost::phoenix;
typedef boost::spirit::line_pos_iterator<std::string::const_iterator> pos_iterator_t;
typedef std::vector<cell> row;
typedef std::vector<cell> cells;
BOOST_FUSION_ADAPT_STRUCT(
cell,
(Type, type)
(Color, color)
)
template<typename It>
struct annotation_f {
typedef void result_type;
annotation_f(It first) : first(first) {}
It const first;
template<typename Val, typename First, typename Last>
void operator()(Val& v, First f, Last l) const {
do_annotate(v, f, l, first);
}
private:
void static do_annotate(cell& c, It f, It l, It first) {
c.row = get_line(f) - 1;
c.column = get_column(first, f) / 2;
}
static void do_annotate(...) { std::cerr << "(not having LocationInfo)\n"; }
};
template <typename It>
struct MinigridParser : qi::grammar<It, row()>
{
MinigridParser(It first) : MinigridParser::base_type(row_), annotate(first)
{
using namespace qi;
type_.add
("W", Type::Wall)
(" ", Type::Floor)
("D", Type::Door)
("L", Type::LockedDoor)
("K", Type::Key)
("A", Type::Ball)
("B", Type::Box)
("G", Type::Goal)
("V", Type::Lava)
("n", Type::SlipperyNorth)
("e", Type::SlipperyEast)
("s", Type::SlipperySouth)
("w", Type::SlipperyWest)
("X", Type::Agent)
("Z", Type::Adversary);
color_.add
("R", Color::Red)
("G", Color::Green)
("B", Color::Blue)
("P", Color::Purple)
("Y", Color::Yellow)
(" ", Color::None);
cell_ = type_ > color_;
row_ = (cell_ % -qi::char_("\n"));
auto set_location_info = annotate(_val, _1, _3);
on_success(cell_, set_location_info);
BOOST_SPIRIT_DEBUG_NODE(type_);
BOOST_SPIRIT_DEBUG_NODE(color_);
BOOST_SPIRIT_DEBUG_NODE(cell_);
}
private:
phoenix::function<annotation_f<It>> annotate;
qi::symbols<char, Type> type_;
qi::symbols<char, Color> color_;
qi::rule<It, cell()> cell_;
qi::rule<It, row()> row_;
};
typedef boost::tokenizer< boost::escaped_list_separator<char> , std::string::const_iterator, std::string> Tokenizer;
//std::ostream& operator<<(std::ostream& os, const row& r);

32
Minigrid2PRISM/util/OptionParser.cpp

@ -0,0 +1,32 @@
#include <iostream>
#include "popl.hpp"
#include "OptionParser.h"
namespace io {
int printPoplException(const popl::invalid_option &e) {
std::cerr << "Invalid Option Exception: " << e.what() << "\n";
std::cerr << "error: ";
if (e.error() == popl::invalid_option::Error::missing_argument) {
std::cerr << "missing_argument\n";
} else if (e.error() == popl::invalid_option::Error::invalid_argument) {
std::cerr << "invalid_argument\n";
} else if (e.error() == popl::invalid_option::Error::too_many_arguments) {
std::cerr << "too_many_arguments\n";
} else if (e.error() == popl::invalid_option::Error::missing_option) {
std::cerr << "missing_option\n";
}
if (e.error() == popl::invalid_option::Error::missing_option) {
std::string option_name(e.option()->name(popl::OptionName::short_name, true));
if (option_name.empty())
option_name = e.option()->name(popl::OptionName::long_name, true);
std::cerr << "option: " << option_name << "\n";
}
else {
std::cerr << "option: " << e.option()->name(e.what_name()) << "\n";
std::cerr << "value: " << e.value() << "\n";
}
return EXIT_FAILURE;
}
}

13
Minigrid2PRISM/util/OptionParser.h

@ -0,0 +1,13 @@
#pragma once
#include <iostream>
#include "popl.hpp"
#define INPUT_ERROR 1
#define INPUT_OK 0
namespace io {
int printPoplException(const popl::invalid_option &e);
}

496
Minigrid2PRISM/util/PrismModulesPrinter.cpp

@ -0,0 +1,496 @@
#include "PrismModulesPrinter.h"
#include <map>
#include <string>
namespace prism {
PrismModulesPrinter::PrismModulesPrinter(const ModelType &modelType, const size_t &numberOfPlayer)
: modelType(modelType), numberOfPlayer(numberOfPlayer) {
}
std::ostream& PrismModulesPrinter::printModel(std::ostream &os, const ModelType &modelType) {
switch(modelType) {
case(ModelType::MDP):
os << "mdp";
break;
case(ModelType::SMG):
os << "smg";
break;
}
os << "\n\n";
return os;
}
std::ostream& PrismModulesPrinter::printBackgroundLabels(std::ostream &os, const AgentName &agentName, const std::pair<Color, cells> &backgroundTiles) {
if(backgroundTiles.second.size() == 0) return os;
bool first = true;
std::string color = getColor(backgroundTiles.first);
color.at(0) = std::toupper(color.at(0));
os << "label " << agentName << "On" << color << " = ";
for(auto const& cell : backgroundTiles.second) {
if(first) first = false; else os << " | ";
os << "(x" << agentName << "=" << cell.column << "&y" << agentName << "=" << cell.row << ")";
}
os << ";\n";
return os;
}
std::ostream& PrismModulesPrinter::printRestrictionFormula(std::ostream& os, const AgentName &agentName, const std::string &direction, const cells &cells) {
bool first = true;
os << "formula " << agentName << "CannotMove" << direction << " = " ;
for(auto const& cell : cells) {
if(first) first = false;
else os << " | ";
os << "(x" << agentName << "=" << cell.column << "&y" << agentName << "=" << cell.row << ")";
}
os << ";\n";
return os;
}
std::ostream& PrismModulesPrinter::printIsOnSlipperyFormula(std::ostream& os, const AgentName &agentName, const std::vector<std::reference_wrapper<cells>>& slipperyCollection) {
if(std::find_if(slipperyCollection.cbegin(), slipperyCollection.cend(), [=](const std::reference_wrapper<cells>& c) { return !c.get().empty(); }) == slipperyCollection.cend()) {
os << "formula " << agentName << "IsOnSlippery = false;\n";
return os;
}
bool first = true;
os << "formula " << agentName << "IsOnSlippery = ";
for (const auto& slippery: slipperyCollection) {
for(const auto& cell : slippery.get()) {
if(first) first = false; else os << " | ";
os << "(x" << agentName << "=" << cell.column << "&y" << agentName << "=" << cell.row << ")";
}
}
os << ";\n";
return os;
}
std::ostream& PrismModulesPrinter::printIsInLavaFormula(std::ostream& os, const AgentName &agentName, const cells &lava) {
if(lava.size() == 0) {
os << "formula " << agentName << "IsInLava = false;\n";
return os;
}
bool first = true;
os << "formula " << agentName << "IsInLava = ";
for(auto const& cell : lava) {
if(first) first = false; else os << " | ";
os << "(x" << agentName << "=" << cell.column << "&y" << agentName << "=" << cell.row << ")";
}
os << ";\n";
os << "formula " << agentName << "IsInLavaAndNotDone = " << agentName << "IsInLava & !" << agentName << "Done;\n";
os << "label \"" << agentName << "IsInLavaAndNotDone\" = " << agentName << "IsInLava & !" << agentName << "Done;\n";
return os;
}
std::ostream& PrismModulesPrinter::printFormulas(std::ostream& os,
const AgentName &agentName,
const cells &restrictionNorth,
const cells &restrictionEast,
const cells &restrictionSouth,
const cells &restrictionWest,
const std::vector<std::reference_wrapper<cells>> &slipperyCollection,
const cells &lava) {
printRestrictionFormula(os, agentName, "North", restrictionNorth);
printRestrictionFormula(os, agentName, "East ", restrictionEast);
printRestrictionFormula(os, agentName, "South", restrictionSouth);
printRestrictionFormula(os, agentName, "West ", restrictionWest);
printIsOnSlipperyFormula(os, agentName, slipperyCollection);
printIsInLavaFormula(os, agentName, lava);
os << "\n";
return os;
}
std::ostream& PrismModulesPrinter::printGoalLabel(std::ostream& os, const AgentName &agentName, const cells &goals) {
if(goals.size() == 0) {
os << "formula " << agentName << "IsInGoal = false;\n";
return os;
}
bool first = true;
os << "formula " << agentName << "IsInGoal = ";
for(auto const& cell : goals) {
if(first) first = false; else os << " | ";
os << "(x" << agentName << "=" << cell.column << "&y" << agentName << "=" << cell.row << ")";
}
os << ";\n";
os << "formula " << agentName << "IsInGoalAndNotDone = " << agentName << "IsInGoal & !" << agentName << "Done;\n";
os << "label \"" << agentName << "IsInGoalAndNotDone\" = " << agentName << "IsInGoal & !" << agentName << "Done;\n";
return os;
}
std::ostream& PrismModulesPrinter::printCrashLabel(std::ostream &os, const std::vector<AgentName> agentNames) {
os << "label crash = ";
bool first = true;
for(auto const& agentName : agentNames) {
if(agentName == "Agent") continue;
if(first) first = false; else os << " | ";
os << "(xAgent=x" << agentName << ")&(yAgent=y" << agentName << ")";
}
os << ";\n\n";
return os;
}
std::ostream& PrismModulesPrinter::printAvoidanceLabel(std::ostream &os, const std::vector<AgentName> agentNames, const int &distance) {
os << "label avoidance = ";
bool first = true;
for(auto const& agentName : agentNames) {
if(agentName == "Agent") continue;
if(first) first = false; else os << " | ";
os << "max(xAgent-x" << agentName << ",x" << agentName << "-xAgent)+";
os << "max(yAgent-y" << agentName << ",y" << agentName << "-yAgent) ";
}
os << ";\n\n";
return os;
}
std::ostream& PrismModulesPrinter::printKeysLabels(std::ostream& os, const AgentName &agentName, const cells &keys) {
if(keys.size() == 0) return os;
for(auto const& key : keys) {
std::string keyColor = key.getColor();
os << "label picked_up_" << keyColor << "_key = has_" << keyColor << "_key = true;\n";
}
os << "\n";
return os;
}
std::ostream& PrismModulesPrinter::printBooleansForKeys(std::ostream &os, const cells &keys) {
for(auto const& key : keys) {
os << "\thas_"<< key.getColor() << "_key : bool init false;\n";
}
os << "\n";
return os;
}
std::ostream& PrismModulesPrinter::printActionsForKeys(std::ostream &os, cells keys) {
for(auto const& key : keys) {
std::string keyColor = key.getColor();
os << "\t[pickup_" << keyColor << "_key] \n";
os << "\t\tview=0 & x=" << key.row << " & y=" << key.column - 1 << " |\n";
os << "\t\tview=1 & x=" << key.row - 1 << " & y=" << key.column << " |\n";
os << "\t\tview=2 & x=" << key.row << " & y=" << key.column + 1 << " |\n";
os << "\t\tview=3 & x=" << key.row + 1 << " & y=" << key.column << " -> (has_" << keyColor << "_key'=true);\n";
}
os << "\n";
return os;
}
std::ostream& PrismModulesPrinter::printModule(std::ostream &os, const AgentName &agentName, const size_t &agentIndex, const coordinates &boundaries, const coordinates& initialPosition, const cells &keys, const bool agentWithView, const std::vector<float> &probabilities) {
os << "module " << agentName << "\n";
os << "\tx" << agentName << " : [1.." << boundaries.first << "] init " << initialPosition.second << ";\n";
os << "\ty" << agentName << " : [1.." << boundaries.second << "] init " << initialPosition.first << ";\n";
printBooleansForKeys(os, keys);
os << "\t" << agentName << "Done : bool init false;\n";
if(agentWithView) {
os << "\tview" << agentName << " : [0..3] init 0;\n";
os << "\n";
os << "\t[" << agentName << "_turn_right] " << moveGuard(agentIndex) << " !" << agentName << "IsInGoal & !" << agentName << "IsInLava & !" << agentName << "IsOnSlippery -> (view" << agentName << "'=mod(view" << agentName << " + 1, 4)) " << moveUpdate(agentIndex) << ";\n";
os << "\t[" << agentName << "_turn_left] " << moveGuard(agentIndex) << " !" << agentName << "IsInGoal & !" << agentName << "IsInLava & !" << agentName << "IsOnSlippery & view" << agentName << ">0 -> (view" << agentName << "'=view" << agentName << " - 1) " << moveUpdate(agentIndex) << ";\n";
os << "\t[" << agentName << "_turn_left] " << moveGuard(agentIndex) << " !" << agentName << "IsInGoal & !" << agentName << "IsInLava & !" << agentName << "IsOnSlippery & view" << agentName << "=0 -> (view" << agentName << "'=3) " << moveUpdate(agentIndex) << ";\n";
} else {
os << "\t[" << agentName << "_turns] " << moveGuard(agentIndex) << " true -> (x" << agentName << "'=x" << agentName << ")" << moveUpdate(agentIndex) << ";\n";
}
printActionsForKeys(os, keys);
os << "\n";
printMovementActions(os, agentName, agentIndex, agentWithView);
for(auto const& probability : probabilities) {
printMovementActions(os, agentName, agentIndex, agentWithView, probability);
}
printDoneActions(os, agentName, agentIndex);
os << "\n";
return os;
}
std::ostream& PrismModulesPrinter::printMovementActions(std::ostream &os, const AgentName &agentName, const size_t &agentIndex, const bool agentWithView, const float &probability) {
if(probability >= 1) {
os << "\t[" << agentName << "_move_north]" << moveGuard(agentIndex) << viewVariable(agentName, 3, agentWithView) << " !" << agentName << "IsOnSlippery & !" << agentName << "IsInLava &!" << agentName << "IsInGoal & !" << agentName << "CannotMoveNorth -> (y" << agentName << "'=y" << agentName << "-1)" << moveUpdate(agentIndex) << ";\n";
os << "\t[" << agentName << "_move_east] " << moveGuard(agentIndex) << viewVariable(agentName, 0, agentWithView) << " !" << agentName << "IsOnSlippery & !" << agentName << "IsInLava &!" << agentName << "IsInGoal & !" << agentName << "CannotMoveEast -> (x" << agentName << "'=x" << agentName << "+1)" << moveUpdate(agentIndex) << ";\n";
os << "\t[" << agentName << "_move_south]" << moveGuard(agentIndex) << viewVariable(agentName, 1, agentWithView) << " !" << agentName << "IsOnSlippery & !" << agentName << "IsInLava &!" << agentName << "IsInGoal & !" << agentName << "CannotMoveSouth -> (y" << agentName << "'=y" << agentName << "+1)" << moveUpdate(agentIndex) << ";\n";
os << "\t[" << agentName << "_move_west] " << moveGuard(agentIndex) << viewVariable(agentName, 2, agentWithView) << " !" << agentName << "IsOnSlippery & !" << agentName << "IsInLava &!" << agentName << "IsInGoal & !" << agentName << "CannotMoveWest -> (x" << agentName << "'=x" << agentName << "-1)" << moveUpdate(agentIndex) << ";\n";
} else {
std::string probabilityString = std::to_string(probability);
std::string percentageString = std::to_string((int)(100 * probability));
std::string complementProbabilityString = std::to_string(1 - probability);
os << "\t[" << agentName << "_move_north_" << percentageString << "] ";
os << moveGuard(agentIndex) << viewVariable(agentName, 3, agentWithView) << " !" << agentName << "IsOnSlippery & !" << agentName << "IsInLava & !" << agentName << "CannotMoveNorth -> ";
os << probabilityString << ": (y" << agentName << "'=y" << agentName << "-1)" << moveUpdate(agentIndex) << " + ";
os << complementProbabilityString << ": (y" << agentName << "'=y" << agentName << ") " << moveUpdate(agentIndex) << ";\n";
os << "\t[" << agentName << "_move_east_" << percentageString << "] ";
os << moveGuard(agentIndex) << viewVariable(agentName, 0, agentWithView) << " !" << agentName << "IsOnSlippery & !" << agentName << "IsInLava & !" << agentName << "CannotMoveEast -> ";
os << probabilityString << ": (x" << agentName << "'=x" << agentName << "+1)" << moveUpdate(agentIndex) << " + ";
os << complementProbabilityString << ": (x" << agentName << "'=x" << agentName << ") " << moveUpdate(agentIndex) << ";\n";
os << "\t[" << agentName << "_move_south_" << percentageString << "] ";
os << moveGuard(agentIndex) << viewVariable(agentName, 1, agentWithView) << " !" << agentName << "IsOnSlippery & !" << agentName << "IsInLava & !" << agentName << "CannotMoveSouth -> ";
os << probabilityString << ": (y" << agentName << "'=y" << agentName << "+1)" << moveUpdate(agentIndex) << " + ";
os << complementProbabilityString << ": (y" << agentName << "'=y" << agentName << ") " << moveUpdate(agentIndex) << ";\n";
os << "\t[" << agentName << "_move_west_" << percentageString << "] ";
os << moveGuard(agentIndex) << viewVariable(agentName, 2, agentWithView) << " !" << agentName << "IsOnSlippery & !" << agentName << "IsInLava & !" << agentName << "CannotMoveWest -> ";
os << probabilityString << ": (x" << agentName << "'=x" << agentName << "-1)" << moveUpdate(agentIndex) << " + ";
os << complementProbabilityString << ": (x" << agentName << "'=x" << agentName << ") " << moveUpdate(agentIndex) << ";\n";
}
return os;
}
std::ostream& PrismModulesPrinter::printDoneActions(std::ostream &os, const AgentName &agentName, const size_t &agentIndex) {
os << "\t[" << agentName << "_done]" << moveGuard(agentIndex) << agentName << "IsInGoal | " << agentName << "IsInLava -> (" << agentName << "Done'=true);\n";
return os;
}
std::ostream& PrismModulesPrinter::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) {
constexpr std::size_t PROB_PIECES = 9, ALL_POSS_DIRECTIONS = 9;
std::array<std::string, ALL_POSS_DIRECTIONS> positionTransition = {
/* north */ "(y" + agentName + "'=y" + agentName + "-1)",
/* north east */ "(x" + agentName + "'=x" + agentName + "+1) & (y" + agentName + "'=y" + agentName + "-1)",
/* east */ "(x" + agentName + "'=x" + agentName + "+1)",
/* east south */ "(x" + agentName + "'=x" + agentName + "+1) & (y" + agentName + "'=y" + agentName + "+1)",
/* south */ "(y" + agentName + "'=y" + agentName + "+1)",
/* south west */ "(x" + agentName + "'=x" + agentName + "-1) & (y" + agentName + "'=y" + agentName + "+1)",
/* west */ "(x" + agentName + "'=x" + agentName + "-1)",
/* north west */ "(x" + agentName + "'=x" + agentName + "-1) & (y" + agentName + "'=y" + agentName + "-1)",
/* own position */ "(x" + agentName + "'=x" + agentName + ") & (y" + agentName + "'=y" + agentName + ")"
};
// view transition appdx in form (guard, update part)
// IMPORTANT: No mod() usage for turn left due to bug in mod() function for decrement
std::array<std::pair<std::string, std::string>, 3> viewTransition = {
/* turn to right */ std::make_pair("", " & (view" + agentName + "'=mod(view" + agentName + " + 1, 4))"),
/* turn to left */ std::make_pair(" & view" + agentName + ">0", " & (view" + agentName + "'=view" + agentName + " - 1)"),
/* turn to left */ std::make_pair(" & view" + agentName + "=0", " & (view" + agentName + "'=3)")
};
// direction specifics
std::string actionName;
std::size_t remainPosIndex = 8;
std::array<std::size_t, ALL_POSS_DIRECTIONS> prob_piece_dir; // { n, ne, w, se, s, sw, w, nw, CURRENT POS }
switch (orientation)
{
case SlipperyType::North:
actionName = "\t[" + agentName + "turn_at_slip_north]";
prob_piece_dir = { 0, 0, 0, 1, 1, 1, 0, 0, 0 /* <- R */ };
break;
case SlipperyType::South:
actionName = "\t[" + agentName + "turn_at_slip_south]";
prob_piece_dir = { 1, 1, 0, 0, 0, 0, 0, 1, 0 /* <- R */ };
break;
case SlipperyType::East:
actionName = "\t[" + agentName + "turn_at_slip_east]";
prob_piece_dir = { 0, 0, 0, 0, 0, 1, 1, 1, 0 /* <- R */ };
break;
case SlipperyType::West:
actionName = "\t[" + agentName + "turn_at_slip_west]";
prob_piece_dir = { 0, 1, 1, 1, 0, 0, 0, 0, 0 /* <- R */ };
break;
}
slipperyActions.insert(actionName);
// override probability to 0 if corresp. direction is blocked
for (std::size_t i = 0; i < ALL_POSS_DIRECTIONS - 1; i++) {
if (!neighborhood.at(i))
prob_piece_dir.at(i) = 0;
}
// determine residual probability (R) by replacing 0 with (1 - overall sum)
prob_piece_dir.at(remainPosIndex) = PROB_PIECES - std::accumulate(prob_piece_dir.begin(), prob_piece_dir.end(), 0);
// <DEBUG_AREA>
{
assert(prob_piece_dir.at(remainPosIndex) <= 9 && prob_piece_dir.at(remainPosIndex) >= 6 && "Value not in Range!");
assert(std::accumulate(prob_piece_dir.begin(), prob_piece_dir.end(), 0) == PROB_PIECES && "Does not sum up to 1!");
}
// </DEBUG_AREA>
// generic output (for every view transition)
for (std::size_t v = 0; v < viewTransition.size(); v++) {
os << actionName << moveGuard(agentIndex) << " x" << agentName << "=" << c.second << " & y" << agentName << "=" << c.first << viewTransition.at(v).first;
for (std::size_t i = 0; i < ALL_POSS_DIRECTIONS; i++) {
os << (i == 0 ? " -> " : " + ") << prob_piece_dir.at(i) << "/" << PROB_PIECES << " : " << positionTransition.at(i) << viewTransition.at(v).second << moveUpdate(agentIndex) << (i == ALL_POSS_DIRECTIONS - 1 ? ";\n" : "\n");
}
}
return os;
}
std::ostream& PrismModulesPrinter::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) {
constexpr std::size_t PROB_PIECES = 9, ALL_POSS_DIRECTIONS = 8;
std::array<std::string, ALL_POSS_DIRECTIONS> positionTransition = {
/* north */ "(y" + agentName + "'=y" + agentName + "-1)",
/* north east */ "(x" + agentName + "'=x" + agentName + "+1) & (y" + agentName + "'=y" + agentName + "-1)",
/* east */ "(x" + agentName + "'=x" + agentName + "+1)",
/* east south */ "(x" + agentName + "'=x" + agentName + "+1) & (y" + agentName + "'=y" + agentName + "+1)",
/* south */ "(y" + agentName + "'=y" + agentName + "+1)",
/* south west */ "(x" + agentName + "'=x" + agentName + "-1) & (y" + agentName + "'=y" + agentName + "+1)",
/* west */ "(x" + agentName + "'=x" + agentName + "-1)",
/* north west */ "(x" + agentName + "'=x" + agentName + "-1) & (y" + agentName + "'=y" + agentName + "-1)"
};
// direction specifics
std::size_t straightPosIndex;
std::string actionName, specialTransition; // if straight ahead is blocked
std::array<std::size_t, ALL_POSS_DIRECTIONS> prob_piece_dir; // { n, ne, w, se, s, sw, w, nw }
switch (orientation)
{
case SlipperyType::North:
actionName = "\t[" + agentName + "move_on_slip_north]";
prob_piece_dir = { 0, 0, 1, 2, 0 /* <- R */, 2, 1, 0 };
straightPosIndex = 4;
specialTransition = "(y" + agentName + "'=y" + agentName + (!neighborhood.at(straightPosIndex) ? ")" : "+1)");
break;
case SlipperyType::South:
actionName = "\t[" + agentName + "move_on_slip_south]";
prob_piece_dir = { 0 /* <- R */, 2, 1, 0, 0, 0, 1, 2 };
straightPosIndex = 0; // always north
specialTransition = "(y" + agentName + "'=y" + agentName + (!neighborhood.at(straightPosIndex) ? ")" : "-1)");
break;
case SlipperyType::East:
actionName = "\t[" + agentName + "move_on_slip_east]";
prob_piece_dir = { 1, 0, 0, 0, 1, 2, 0 /* <- R */, 2 };
straightPosIndex = 6;
specialTransition = "(x" + agentName + "'=x" + agentName + (!neighborhood.at(straightPosIndex) ? ")" : "-1)");
break;
case SlipperyType::West:
actionName = "\t[" + agentName + "move_on_slip_west]";
prob_piece_dir = { 1, 2, 0 /* <- R */, 2, 1, 0, 0, 0 };
straightPosIndex = 2;
specialTransition = "(x" + agentName + "'=x" + agentName + (!neighborhood.at(straightPosIndex) ? ")" : "+1)");
break;
}
slipperyActions.insert(actionName);
// override probability to 0 if corresp. direction is blocked
for (std::size_t i = 0; i < ALL_POSS_DIRECTIONS; i++) {
if (!neighborhood.at(i))
prob_piece_dir.at(i) = 0;
}
// determine residual probability (R) by replacing 0 with (1 - overall sum)
prob_piece_dir.at(straightPosIndex) = PROB_PIECES - std::accumulate(prob_piece_dir.begin(), prob_piece_dir.end(), 0);
// <DEBUG_AREA>
{
assert(prob_piece_dir.at(straightPosIndex) <= 9 && prob_piece_dir.at(straightPosIndex) >= 3 && "Value not in Range!");
assert(std::accumulate(prob_piece_dir.begin(), prob_piece_dir.end(), 0) == PROB_PIECES && "Does not sum up to 1!");
assert(orientation != SlipperyType::North || (prob_piece_dir.at(7) == 0 && prob_piece_dir.at(0) == 0 && prob_piece_dir.at(1) == 0 && "Slippery up should be impossible!"));
assert(orientation != SlipperyType::South || (prob_piece_dir.at(3) == 0 && prob_piece_dir.at(4) == 0 && prob_piece_dir.at(5) == 0 && "Slippery down should be impossible!"));
assert(orientation != SlipperyType::East || (prob_piece_dir.at(1) == 0 && prob_piece_dir.at(2) == 0 && prob_piece_dir.at(3) == 0 && "Slippery right should be impossible!"));
assert(orientation != SlipperyType::West || (prob_piece_dir.at(5) == 0 && prob_piece_dir.at(6) == 0 && prob_piece_dir.at(7) == 0 && "Slippery left should be impossible!"));
}
// </DEBUG_AREA>
// special case: straight forward is blocked (then remain in same position)
positionTransition.at(straightPosIndex) = specialTransition;
// generic output (for every view and every possible view direction)
os << actionName << moveGuard(agentIndex) << " x" << agentName << "=" << c.second << " & y" << agentName << "=" << c.first;
for (std::size_t i = 0; i < ALL_POSS_DIRECTIONS; i++) {
os << (i == 0 ? " -> " : " + ") << prob_piece_dir.at(i) << "/" << PROB_PIECES << " : " << positionTransition.at(i) << moveUpdate(agentIndex) << (i == ALL_POSS_DIRECTIONS - 1 ? ";\n" : "\n");
}
return os;
}
std::ostream& PrismModulesPrinter::printEndmodule(std::ostream &os) {
os << "endmodule\n";
os << "\n";
return os;
}
std::ostream& PrismModulesPrinter::printPlayerStruct(std::ostream &os, const AgentName &agentName, const bool agentWithView, const std::vector<float> &probabilities, const std::set<std::string> &slipperyActions) {
os << "player " << agentName << "\n\t";
bool first = true;
std::list<std::string> allActions = { "_move_north", "_move_east", "_move_south", "_move_west" };
std::list<std::string> movementActions = allActions;
for(auto const& probability : probabilities) {
std::string percentageString = std::to_string((int)(100 * probability));
for(auto const& movement : movementActions) {
allActions.push_back(movement + "_" + percentageString);
}
}
if(agentWithView) {
allActions.push_back("_turn_left");
allActions.push_back("_turn_right");
} else {
allActions.push_back("_turns");
}
for(auto const& action : allActions) {
if(first) first = false; else os << ", ";
os << "[" << agentName << action << "]";
}
for(auto const& action : slipperyActions) {
os << ", " << action;
}
os << "\nendplayer\n";
return os;
}
std::ostream& PrismModulesPrinter::printGlobalMoveVariable(std::ostream &os, const size_t &numberOfPlayer) {
os << "\nglobal move : [0.." << std::to_string(numberOfPlayer - 1) << "] init 0;\n\n";
return os;
}
std::ostream& PrismModulesPrinter::printRewards(std::ostream &os, const std::map<coordinates, float> &stateRewards, const cells &lava, const cells &goals) {
os << "rewards \"NoBFS\"\n";
os << "\tAgentIsInGoalAndNotDone: 100;\n";
os << "\tAgentIsInLavaAndNotDone: -100;\n";
os << "endrewards\n";
os << "rewards \"WithBFS\"\n";
os << "\tAgentIsInGoalAndNotDone: 100;\n";
os << "\tAgentIsInLavaAndNotDone: -100;\n";
for(auto const [coordinates, reward] : stateRewards) {
os << "\txAgent=" << coordinates.first << "&yAgent=" << coordinates.second << " : " << reward << ";\n";
}
os << "endrewards\n";
return os;
}
std::string PrismModulesPrinter::moveGuard(const size_t &agentIndex) {
return isGame() ? " move=" + std::to_string(agentIndex) + " & " : " ";
}
std::string PrismModulesPrinter::moveUpdate(const size_t &agentIndex) {
return isGame() ?
(agentIndex == numberOfPlayer - 1) ?
" & (move'=0) " :
" & (move'=" + std::to_string(agentIndex + 1) + ") " :
"";
}
std::string PrismModulesPrinter::viewVariable(const AgentName &agentName, const size_t &agentDirection, const bool agentWithView) {
return agentWithView ? " view" + agentName + "=" + std::to_string(agentDirection) + " & " : " ";
}
bool PrismModulesPrinter::isGame() const {
return modelType == ModelType::SMG;
}
}

78
Minigrid2PRISM/util/PrismModulesPrinter.h

@ -0,0 +1,78 @@
#pragma once
#include <iostream>
#include <functional>
#include "MinigridGrammar.h"
#include "PrismPrinter.h"
namespace prism {
class PrismModulesPrinter {
public:
PrismModulesPrinter(const ModelType &modelType, const size_t &numberOfPlayer);
std::ostream& printRestrictionFormula(std::ostream& os, const AgentName &agentName, const std::string &direction, const cells &cells);
std::ostream& printIsOnSlipperyFormula(std::ostream& os, const AgentName &agentName, const std::vector<std::reference_wrapper<cells>> &slipperyCollection);
std::ostream& printGoalLabel(std::ostream& os, const AgentName&agentName, const cells &goals);
std::ostream& printCrashLabel(std::ostream &os, const std::vector<AgentName> agentNames);
std::ostream& printAvoidanceLabel(std::ostream &os, const std::vector<AgentName> agentNames, const int &distance);
std::ostream& printKeysLabels(std::ostream& os, const AgentName&agentName, const cells &keys);
std::ostream& printBackgroundLabels(std::ostream &os, const AgentName &agentName, const std::pair<Color, cells> &backgroundTiles);
std::ostream& printIsInLavaFormula(std::ostream& os, const AgentName &agentName, const cells &lava);
std::ostream& printFormulas(std::ostream& os,
const AgentName&agentName,
const cells &restrictionNorth,
const cells &restrictionEast,
const cells &restrictionSouth,
const cells &restrictionWest,
const std::vector<std::reference_wrapper<cells>> &slipperyCollection,
const cells &lava);
/*
* Representation for Slippery Tile.
* -) North: Slips from North to South
* -) East: Slips from East to West
* -) South: Slips from South to North
* -) West: Slips from West to East
*/
enum class SlipperyType { North, East, South, West };
/*
* Prints Slippery on move action.
*
* @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.
* @param orientation: Information of slippery type (either north, south, east, west).
*/
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);
/*
* Prints Slippery on turn action.
*
* @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.
* @param orientation: Information of slippery type (either north, south, east, west).
*/
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);
std::ostream& printModel(std::ostream &os, const ModelType &modelType);
std::ostream& printBooleansForKeys(std::ostream &os, const cells &keys);
std::ostream& printActionsForKeys(std::ostream &os, cells keys);
std::ostream& printModule(std::ostream &os, const AgentName &agentName, const size_t &agentIndex, const coordinates &boundaries, const coordinates& initialPosition, const cells &keys, const bool agentWithView, const std::vector<float> &probabilities = {});
std::ostream& printMovementActions(std::ostream &os, const AgentName &agentName, const size_t &agentIndex, const bool agentWithView, const float &probability = 1.0);
std::ostream& printDoneActions(std::ostream &os, const AgentName &agentName, const size_t &agentIndex);
std::ostream& printEndmodule(std::ostream &os);
std::ostream& printPlayerStruct(std::ostream &os, const AgentName &agentName, const bool agentWithView, const std::vector<float> &probabilities = {}, const std::set<std::string> &slipperyActions = {});
std::ostream& printGlobalMoveVariable(std::ostream &os, const size_t &numberOfPlayer);
std::ostream& printRewards(std::ostream &os, const std::map<coordinates, float> &stateRewards, const cells &lava, const cells &goals);
std::string moveGuard(const size_t &agentIndex);
std::string moveUpdate(const size_t &agentIndex);
std::string viewVariable(const AgentName &agentName, const size_t &agentDirection, const bool agentWithView);
bool isGame() const;
private:
ModelType const& modelType;
const size_t numberOfPlayer;
};
}

15
Minigrid2PRISM/util/PrismPrinter.h

@ -0,0 +1,15 @@
#pragma once
#include <string>
#include "cell.h"
typedef std::string AgentName;
typedef std::pair<std::string, coordinates> AgentNameAndPosition;
typedef std::map<AgentNameAndPosition::first_type, AgentNameAndPosition::second_type> AgentNameAndPositionMap;
namespace prism {
enum class ModelType {
MDP, SMG
};
}

83
Minigrid2PRISM/util/cell.cpp

@ -0,0 +1,83 @@
#include "cell.h"
#include <stdexcept>
std::ostream &operator<<(std::ostream &os, const cell &c) {
os << static_cast<char>(c.type) << static_cast<char>(c.color);
os << " at (" << c.row << "," << c.column << ")";
return os;
}
cell cell::getNorth(const std::vector<cell> &grid) const {
auto north = std::find_if(grid.begin(), grid.end(), [this](const cell &c) {
return this->row - 1 == c.row && this->column == c.column;
});
if(north == grid.end()) {
throw std::logic_error{ "Cannot get cell north of (" + std::to_string(row) + "," + std::to_string(column) + ")"};
std::exit(EXIT_FAILURE);
}
return *north;
}
cell cell::getEast(const std::vector<cell> &grid) const {
auto east = std::find_if(grid.begin(), grid.end(), [this](const cell &c) {
return this->row == c.row && this->column + 1 == c.column;
});
if(east == grid.end()) {
throw std::logic_error{ "Cannot get cell east of (" + std::to_string(row) + "," + std::to_string(column) + ")"};
std::exit(EXIT_FAILURE);
}
return *east;
}
cell cell::getSouth(const std::vector<cell> &grid) const {
auto south = std::find_if(grid.begin(), grid.end(), [this](const cell &c) {
return this->row + 1 == c.row && this->column == c.column;
});
if(south == grid.end()) {
throw std::logic_error{ "Cannot get cell south of (" + std::to_string(row) + "," + std::to_string(column) + ")"};
std::exit(EXIT_FAILURE);
}
return *south;
}
cell cell::getWest(const std::vector<cell> &grid) const {
auto west = std::find_if(grid.begin(), grid.end(), [this](const cell &c) {
return this->row == c.row && this->column - 1 == c.column;
});
if(west == grid.end()) {
throw std::logic_error{ "Cannot get cell west of (" + std::to_string(row) + "," + std::to_string(column) + ")"};
std::exit(EXIT_FAILURE);
}
return *west;
}
coordinates cell::getCoordinates() const {
return std::make_pair(row, column);
}
std::string cell::getColor() const {
switch(color) {
case Color::Red: return "red";
case Color::Green: return "green";
case Color::Blue: return "blue";
case Color::Purple: return "purple";
case Color::Yellow: return "yellow";
case Color::None: return "transparent";
default: return "";
//case Color::Grey = 'G',
}
}
std::string getColor(Color color) {
switch(color) {
case Color::Red: return "red";
case Color::Green: return "green";
case Color::Blue: return "blue";
case Color::Purple: return "purple";
case Color::Yellow: return "yellow";
case Color::None: return "transparent";
default: return "";
//case Color::Grey = 'G',
}
}

62
Minigrid2PRISM/util/cell.h

@ -0,0 +1,62 @@
#pragma once
#include <iostream>
#include <utility>
#include <vector>
typedef std::pair<int, int> coordinates;
class Grid;
enum class Type : char {
Wall = 'W',
Floor = ' ',
Door = 'D',
LockedDoor = 'L',
Key = 'K',
Ball = 'A',
Box = 'B',
Goal = 'G',
Lava = 'V',
Agent = 'X',
Adversary = 'Z',
SlipperyNorth = 'n',
SlipperySouth = 's',
SlipperyEast = 'e',
SlipperyWest = 'w'
};
enum class Color : char {
Red = 'R',
Green = 'G',
Blue = 'B',
Purple = 'P',
Yellow = 'Y',
//Grey = 'G',
None = ' '
};
constexpr std::initializer_list<Color> allColors = {Color::Red, Color::Green, Color::Blue, Color::Purple, Color::Yellow};
std::string getColor(Color color);
class cell {
public:
coordinates getNorth() const { return std::make_pair(row - 1, column); }
coordinates getSouth() const { return std::make_pair(row + 1, column); }
coordinates getEast() const { return std::make_pair(row, column + 1); }
coordinates getWest() const { return std::make_pair(row, column - 1); }
cell getNorth(const std::vector<cell> &grid) const;
cell getEast(const std::vector<cell> &grid) const;
cell getSouth(const std::vector<cell> &grid) const;
cell getWest(const std::vector<cell> &grid) const;
friend std::ostream& operator<<(std::ostream& os, const cell& cell);
coordinates getCoordinates() const;
std::string getColor() const;
int row;
int column;
Type type;
Color color;
};

1331
Minigrid2PRISM/util/popl.hpp
File diff suppressed because it is too large
View File

160
gym_minigrid/.gitignore

@ -0,0 +1,160 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

1
gym_minigrid/.orig_git/HEAD

@ -0,0 +1 @@
ref: refs/heads/ag_proof_of_concept

11
gym_minigrid/.orig_git/config

@ -0,0 +1,11 @@
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = gitea@git.pranger.xyz:sp/Minigrid.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "ag_proof_of_concept"]
remote = origin
merge = refs/heads/ag_proof_of_concept

1
gym_minigrid/.orig_git/description

@ -0,0 +1 @@
Unnamed repository; edit this file 'description' to name the repository.

15
gym_minigrid/.orig_git/hooks/applypatch-msg.sample

@ -0,0 +1,15 @@
#!/bin/sh
#
# An example hook script to check the commit log message taken by
# applypatch from an e-mail message.
#
# The hook should exit with non-zero status after issuing an
# appropriate message if it wants to stop the commit. The hook is
# allowed to edit the commit message file.
#
# To enable this hook, rename this file to "applypatch-msg".
. git-sh-setup
commitmsg="$(git rev-parse --git-path hooks/commit-msg)"
test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"}
:

24
gym_minigrid/.orig_git/hooks/commit-msg.sample

@ -0,0 +1,24 @@
#!/bin/sh
#
# An example hook script to check the commit log message.
# Called by "git commit" with one argument, the name of the file
# that has the commit message. The hook should exit with non-zero
# status after issuing an appropriate message if it wants to stop the
# commit. The hook is allowed to edit the commit message file.
#
# To enable this hook, rename this file to "commit-msg".
# Uncomment the below to add a Signed-off-by line to the message.
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
# hook is more suited to it.
#
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
# This example catches duplicate Signed-off-by lines.
test "" = "$(grep '^Signed-off-by: ' "$1" |
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
echo >&2 Duplicate Signed-off-by lines.
exit 1
}

109
gym_minigrid/.orig_git/hooks/fsmonitor-watchman.sample

@ -0,0 +1,109 @@
#!/usr/bin/perl
use strict;
use warnings;
use IPC::Open2;
# An example hook script to integrate Watchman
# (https://facebook.github.io/watchman/) with git to speed up detecting
# new and modified files.
#
# The hook is passed a version (currently 1) and a time in nanoseconds
# formatted as a string and outputs to stdout all files that have been
# modified since the given time. Paths must be relative to the root of
# the working tree and separated by a single NUL.
#
# To enable this hook, rename this file to "query-watchman" and set
# 'git config core.fsmonitor .git/hooks/query-watchman'
#
my ($version, $time) = @ARGV;
# Check the hook interface version
if ($version == 1) {
# convert nanoseconds to seconds
# subtract one second to make sure watchman will return all changes
$time = int ($time / 1000000000) - 1;
} else {
die "Unsupported query-fsmonitor hook version '$version'.\n" .
"Falling back to scanning...\n";
}
my $git_work_tree;
if ($^O =~ 'msys' || $^O =~ 'cygwin') {
$git_work_tree = Win32::GetCwd();
$git_work_tree =~ tr/\\/\//;
} else {
require Cwd;
$git_work_tree = Cwd::cwd();
}
my $retry = 1;
launch_watchman();
sub launch_watchman {
my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty')
or die "open2() failed: $!\n" .
"Falling back to scanning...\n";
# In the query expression below we're asking for names of files that
# changed since $time but were not transient (ie created after
# $time but no longer exist).
#
# To accomplish this, we're using the "since" generator to use the
# recency index to select candidate nodes and "fields" to limit the
# output to file names only.
my $query = <<" END";
["query", "$git_work_tree", {
"since": $time,
"fields": ["name"]
}]
END
print CHLD_IN $query;
close CHLD_IN;
my $response = do {local $/; <CHLD_OUT>};
die "Watchman: command returned no output.\n" .
"Falling back to scanning...\n" if $response eq "";
die "Watchman: command returned invalid output: $response\n" .
"Falling back to scanning...\n" unless $response =~ /^\{/;
my $json_pkg;
eval {
require JSON::XS;
$json_pkg = "JSON::XS";
1;
} or do {
require JSON::PP;
$json_pkg = "JSON::PP";
};
my $o = $json_pkg->new->utf8->decode($response);
if ($retry > 0 and $o->{error} and $o->{error} =~ m/unable to resolve root .* directory (.*) is not watched/) {
print STDERR "Adding '$git_work_tree' to watchman's watch list.\n";
$retry--;
qx/watchman watch "$git_work_tree"/;
die "Failed to make watchman watch '$git_work_tree'.\n" .
"Falling back to scanning...\n" if $? != 0;
# Watchman will always return all files on the first query so
# return the fast "everything is dirty" flag to git and do the
# Watchman query just to get it over with now so we won't pay
# the cost in git to look up each individual file.
print "/\0";
eval { launch_watchman() };
exit 0;
}
die "Watchman: $o->{error}.\n" .
"Falling back to scanning...\n" if $o->{error};
binmode STDOUT, ":utf8";
local $, = "\0";
print @{$o->{files}};
}

8
gym_minigrid/.orig_git/hooks/post-update.sample

@ -0,0 +1,8 @@
#!/bin/sh
#
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
# To enable this hook, rename this file to "post-update".
exec git update-server-info

14
gym_minigrid/.orig_git/hooks/pre-applypatch.sample

@ -0,0 +1,14 @@
#!/bin/sh
#
# An example hook script to verify what is about to be committed
# by applypatch from an e-mail message.
#
# The hook should exit with non-zero status after issuing an
# appropriate message if it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-applypatch".
. git-sh-setup
precommit="$(git rev-parse --git-path hooks/pre-commit)"
test -x "$precommit" && exec "$precommit" ${1+"$@"}
:

49
gym_minigrid/.orig_git/hooks/pre-commit.sample

@ -0,0 +1,49 @@
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=$(git hash-object -t tree /dev/null)
fi
# If you want to allow non-ASCII filenames set this variable to true.
allownonascii=$(git config --bool hooks.allownonascii)
# Redirect output to stderr.
exec 1>&2
# Cross platform projects tend to avoid non-ASCII filenames; prevent
# them from being added to the repository. We exploit the fact that the
# printable range starts at the space character and ends with tilde.
if [ "$allownonascii" != "true" ] &&
# Note that the use of brackets around a tr range is ok here, (it's
# even required, for portability to Solaris 10's /usr/bin/tr), since
# the square bracket bytes happen to fall in the designated range.
test $(git diff --cached --name-only --diff-filter=A -z $against |
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
then
cat <<\EOF
Error: Attempt to add a non-ASCII file name.
This can cause problems if you want to work with people on other platforms.
To be portable it is advisable to rename the file.
If you know what you are doing you can disable this check using:
git config hooks.allownonascii true
EOF
exit 1
fi
# If there are whitespace errors, print the offending file names and fail.
exec git diff-index --check --cached $against --

13
gym_minigrid/.orig_git/hooks/pre-merge-commit.sample

@ -0,0 +1,13 @@
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git merge" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message to
# stderr if it wants to stop the merge commit.
#
# To enable this hook, rename this file to "pre-merge-commit".
. git-sh-setup
test -x "$GIT_DIR/hooks/pre-commit" &&
exec "$GIT_DIR/hooks/pre-commit"
:

53
gym_minigrid/.orig_git/hooks/pre-push.sample

@ -0,0 +1,53 @@
#!/bin/sh
# An example hook script to verify what is about to be pushed. Called by "git
# push" after it has checked the remote status, but before anything has been
# pushed. If this script exits with a non-zero status nothing will be pushed.
#
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
# $2 -- URL to which the push is being done
#
# If pushing without using a named remote those arguments will be equal.
#
# Information about the commits which are being pushed is supplied as lines to
# the standard input in the form:
#
# <local ref> <local sha1> <remote ref> <remote sha1>
#
# This sample shows how to prevent push of commits where the log message starts
# with "WIP" (work in progress).
remote="$1"
url="$2"
z40=0000000000000000000000000000000000000000
while read local_ref local_sha remote_ref remote_sha
do
if [ "$local_sha" = $z40 ]
then
# Handle delete
:
else
if [ "$remote_sha" = $z40 ]
then
# New branch, examine all commits
range="$local_sha"
else
# Update to existing branch, examine new commits
range="$remote_sha..$local_sha"
fi
# Check for WIP commit
commit=`git rev-list -n 1 --grep '^WIP' "$range"`
if [ -n "$commit" ]
then
echo >&2 "Found WIP commit in $local_ref, not pushing"
exit 1
fi
fi
done
exit 0

169
gym_minigrid/.orig_git/hooks/pre-rebase.sample

@ -0,0 +1,169 @@
#!/bin/sh
#
# Copyright (c) 2006, 2008 Junio C Hamano
#
# The "pre-rebase" hook is run just before "git rebase" starts doing
# its job, and can prevent the command from running by exiting with
# non-zero status.
#
# The hook is called with the following parameters:
#
# $1 -- the upstream the series was forked from.
# $2 -- the branch being rebased (or empty when rebasing the current branch).
#
# This sample shows how to prevent topic branches that are already
# merged to 'next' branch from getting rebased, because allowing it
# would result in rebasing already published history.
publish=next
basebranch="$1"
if test "$#" = 2
then
topic="refs/heads/$2"
else
topic=`git symbolic-ref HEAD` ||
exit 0 ;# we do not interrupt rebasing detached HEAD
fi
case "$topic" in
refs/heads/??/*)
;;
*)
exit 0 ;# we do not interrupt others.
;;
esac
# Now we are dealing with a topic branch being rebased
# on top of master. Is it OK to rebase it?
# Does the topic really exist?
git show-ref -q "$topic" || {
echo >&2 "No such branch $topic"
exit 1
}
# Is topic fully merged to master?
not_in_master=`git rev-list --pretty=oneline ^master "$topic"`
if test -z "$not_in_master"
then
echo >&2 "$topic is fully merged to master; better remove it."
exit 1 ;# we could allow it, but there is no point.
fi
# Is topic ever merged to next? If so you should not be rebasing it.
only_next_1=`git rev-list ^master "^$topic" ${publish} | sort`
only_next_2=`git rev-list ^master ${publish} | sort`
if test "$only_next_1" = "$only_next_2"
then
not_in_topic=`git rev-list "^$topic" master`
if test -z "$not_in_topic"
then
echo >&2 "$topic is already up to date with master"
exit 1 ;# we could allow it, but there is no point.
else
exit 0
fi
else
not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"`
/usr/bin/perl -e '
my $topic = $ARGV[0];
my $msg = "* $topic has commits already merged to public branch:\n";
my (%not_in_next) = map {
/^([0-9a-f]+) /;
($1 => 1);
} split(/\n/, $ARGV[1]);
for my $elem (map {
/^([0-9a-f]+) (.*)$/;
[$1 => $2];
} split(/\n/, $ARGV[2])) {
if (!exists $not_in_next{$elem->[0]}) {
if ($msg) {
print STDERR $msg;
undef $msg;
}
print STDERR " $elem->[1]\n";
}
}
' "$topic" "$not_in_next" "$not_in_master"
exit 1
fi
<<\DOC_END
This sample hook safeguards topic branches that have been
published from being rewound.
The workflow assumed here is:
* Once a topic branch forks from "master", "master" is never
merged into it again (either directly or indirectly).
* Once a topic branch is fully cooked and merged into "master",
it is deleted. If you need to build on top of it to correct
earlier mistakes, a new topic branch is created by forking at
the tip of the "master". This is not strictly necessary, but
it makes it easier to keep your history simple.
* Whenever you need to test or publish your changes to topic
branches, merge them into "next" branch.
The script, being an example, hardcodes the publish branch name
to be "next", but it is trivial to make it configurable via
$GIT_DIR/config mechanism.
With this workflow, you would want to know:
(1) ... if a topic branch has ever been merged to "next". Young
topic branches can have stupid mistakes you would rather
clean up before publishing, and things that have not been
merged into other branches can be easily rebased without
affecting other people. But once it is published, you would
not want to rewind it.
(2) ... if a topic branch has been fully merged to "master".
Then you can delete it. More importantly, you should not
build on top of it -- other people may already want to
change things related to the topic as patches against your
"master", so if you need further changes, it is better to
fork the topic (perhaps with the same name) afresh from the
tip of "master".
Let's look at this example:
o---o---o---o---o---o---o---o---o---o "next"
/ / / /
/ a---a---b A / /
/ / / /
/ / c---c---c---c B /
/ / / \ /
/ / / b---b C \ /
/ / / / \ /
---o---o---o---o---o---o---o---o---o---o---o "master"
A, B and C are topic branches.
* A has one fix since it was merged up to "next".
* B has finished. It has been fully merged up to "master" and "next",
and is ready to be deleted.
* C has not merged to "next" at all.
We would want to allow C to be rebased, refuse A, and encourage
B to be deleted.
To compute (1):
git rev-list ^master ^topic next
git rev-list ^master next
if these match, topic has not merged in next at all.
To compute (2):
git rev-list master..topic
if this is empty, it is fully merged to "master".
DOC_END

24
gym_minigrid/.orig_git/hooks/pre-receive.sample

@ -0,0 +1,24 @@
#!/bin/sh
#
# An example hook script to make use of push options.
# The example simply echoes all push options that start with 'echoback='
# and rejects all pushes when the "reject" push option is used.
#
# To enable this hook, rename this file to "pre-receive".
if test -n "$GIT_PUSH_OPTION_COUNT"
then
i=0
while test "$i" -lt "$GIT_PUSH_OPTION_COUNT"
do
eval "value=\$GIT_PUSH_OPTION_$i"
case "$value" in
echoback=*)
echo "echo from the pre-receive-hook: ${value#*=}" >&2
;;
reject)
exit 1
esac
i=$((i + 1))
done
fi

42
gym_minigrid/.orig_git/hooks/prepare-commit-msg.sample

@ -0,0 +1,42 @@
#!/bin/sh
#
# An example hook script to prepare the commit log message.
# Called by "git commit" with the name of the file that has the
# commit message, followed by the description of the commit
# message's source. The hook's purpose is to edit the commit
# message file. If the hook fails with a non-zero status,
# the commit is aborted.
#
# To enable this hook, rename this file to "prepare-commit-msg".
# This hook includes three examples. The first one removes the
# "# Please enter the commit message..." help message.
#
# The second includes the output of "git diff --name-status -r"
# into the message, just before the "git status" output. It is
# commented because it doesn't cope with --amend or with squashed
# commits.
#
# The third example adds a Signed-off-by line to the message, that can
# still be edited. This is rarely a good idea.
COMMIT_MSG_FILE=$1
COMMIT_SOURCE=$2
SHA1=$3
/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE"
# case "$COMMIT_SOURCE,$SHA1" in
# ,|template,)
# /usr/bin/perl -i.bak -pe '
# print "\n" . `git diff --cached --name-status -r`
# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;;
# *) ;;
# esac
# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE"
# if test -z "$COMMIT_SOURCE"
# then
# /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE"
# fi

128
gym_minigrid/.orig_git/hooks/update.sample

@ -0,0 +1,128 @@
#!/bin/sh
#
# An example hook script to block unannotated tags from entering.
# Called by "git receive-pack" with arguments: refname sha1-old sha1-new
#
# To enable this hook, rename this file to "update".
#
# Config
# ------
# hooks.allowunannotated
# This boolean sets whether unannotated tags will be allowed into the
# repository. By default they won't be.
# hooks.allowdeletetag
# This boolean sets whether deleting tags will be allowed in the
# repository. By default they won't be.
# hooks.allowmodifytag
# This boolean sets whether a tag may be modified after creation. By default
# it won't be.
# hooks.allowdeletebranch
# This boolean sets whether deleting branches will be allowed in the
# repository. By default they won't be.
# hooks.denycreatebranch
# This boolean sets whether remotely creating branches will be denied
# in the repository. By default this is allowed.
#
# --- Command line
refname="$1"
oldrev="$2"
newrev="$3"
# --- Safety check
if [ -z "$GIT_DIR" ]; then
echo "Don't run this script from the command line." >&2
echo " (if you want, you could supply GIT_DIR then run" >&2
echo " $0 <ref> <oldrev> <newrev>)" >&2
exit 1
fi
if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
echo "usage: $0 <ref> <oldrev> <newrev>" >&2
exit 1
fi
# --- Config
allowunannotated=$(git config --bool hooks.allowunannotated)
allowdeletebranch=$(git config --bool hooks.allowdeletebranch)
denycreatebranch=$(git config --bool hooks.denycreatebranch)
allowdeletetag=$(git config --bool hooks.allowdeletetag)
allowmodifytag=$(git config --bool hooks.allowmodifytag)
# check for no description
projectdesc=$(sed -e '1q' "$GIT_DIR/description")
case "$projectdesc" in
"Unnamed repository"* | "")
echo "*** Project description file hasn't been set" >&2
exit 1
;;
esac
# --- Check types
# if $newrev is 0000...0000, it's a commit to delete a ref.
zero="0000000000000000000000000000000000000000"
if [ "$newrev" = "$zero" ]; then
newrev_type=delete
else
newrev_type=$(git cat-file -t $newrev)
fi
case "$refname","$newrev_type" in
refs/tags/*,commit)
# un-annotated tag
short_refname=${refname##refs/tags/}
if [ "$allowunannotated" != "true" ]; then
echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2
echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
exit 1
fi
;;
refs/tags/*,delete)
# delete tag
if [ "$allowdeletetag" != "true" ]; then
echo "*** Deleting a tag is not allowed in this repository" >&2
exit 1
fi
;;
refs/tags/*,tag)
# annotated tag
if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1
then
echo "*** Tag '$refname' already exists." >&2
echo "*** Modifying a tag is not allowed in this repository." >&2
exit 1
fi
;;
refs/heads/*,commit)
# branch
if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then
echo "*** Creating a branch is not allowed in this repository" >&2
exit 1
fi
;;
refs/heads/*,delete)
# delete branch
if [ "$allowdeletebranch" != "true" ]; then
echo "*** Deleting a branch is not allowed in this repository" >&2
exit 1
fi
;;
refs/remotes/*,commit)
# tracking branch
;;
refs/remotes/*,delete)
# delete tracking branch
if [ "$allowdeletebranch" != "true" ]; then
echo "*** Deleting a tracking branch is not allowed in this repository" >&2
exit 1
fi
;;
*)
# Anything else (is there anything else?)
echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2
exit 1
;;
esac
# --- Finished
exit 0

BIN
gym_minigrid/.orig_git/index

6
gym_minigrid/.orig_git/info/exclude

@ -0,0 +1,6 @@
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~

1
gym_minigrid/.orig_git/logs/HEAD

@ -0,0 +1 @@
0000000000000000000000000000000000000000 69bf17f1d8fd026c6418d8a66a2448fbec679e4c Stefan Pranger <stefan.pranger@iaik.tugraz.at> 1672500021 +0100 clone: from gitea@git.pranger.xyz:sp/Minigrid.git

1
gym_minigrid/.orig_git/logs/refs/heads/ag_proof_of_concept

@ -0,0 +1 @@
0000000000000000000000000000000000000000 69bf17f1d8fd026c6418d8a66a2448fbec679e4c Stefan Pranger <stefan.pranger@iaik.tugraz.at> 1672500021 +0100 clone: from gitea@git.pranger.xyz:sp/Minigrid.git

1
gym_minigrid/.orig_git/logs/refs/remotes/origin/HEAD

@ -0,0 +1 @@
0000000000000000000000000000000000000000 9dd8245c7350404a2f2103a2d14dc2ef2a232d76 Stefan Pranger <stefan.pranger@iaik.tugraz.at> 1672500021 +0100 clone: from gitea@git.pranger.xyz:sp/Minigrid.git

BIN
gym_minigrid/.orig_git/objects/pack/pack-54b6a72683794b61ae148f24378d4f8d4ad4a769.idx

BIN
gym_minigrid/.orig_git/objects/pack/pack-54b6a72683794b61ae148f24378d4f8d4ad4a769.pack

3
gym_minigrid/.orig_git/packed-refs

@ -0,0 +1,3 @@
# pack-refs with: peeled fully-peeled sorted
69bf17f1d8fd026c6418d8a66a2448fbec679e4c refs/remotes/origin/ag_proof_of_concept
9dd8245c7350404a2f2103a2d14dc2ef2a232d76 refs/remotes/origin/guided_rl

1
gym_minigrid/.orig_git/refs/heads/ag_proof_of_concept

@ -0,0 +1 @@
69bf17f1d8fd026c6418d8a66a2448fbec679e4c

1
gym_minigrid/.orig_git/refs/remotes/origin/HEAD

@ -0,0 +1 @@
ref: refs/remotes/origin/guided_rl

202
gym_minigrid/LICENSE

@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2019 Maxime Chevalier-Boisvert
Copyright 2022 Farama Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

111
gym_minigrid/PKG-INFO

@ -0,0 +1,111 @@
Metadata-Version: 2.1
Name: gym_minigrid
Version: 1.2.2
Summary: Minimalistic gridworld reinforcement learning environments
Home-page: https://github.com/Farama-Foundation/gym-minigrid
Author: Farama Foundation
Author-email: jkterry@farama.org
License: Apache
Keywords: memory,environment,agent,rl,gym
Classifier: Development Status :: 5 - Production/Stable
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Provides-Extra: testing
License-File: LICENSE
# MiniGrid (formerly gym-minigrid)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://pre-commit.com/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
There are other gridworld Gym environments out there, but this one is
designed to be particularly simple, lightweight and fast. The code has very few
dependencies, making it less likely to break or fail to install. It loads no
external sprites/textures, and it can run at up to 5000 FPS on a Core i7
laptop, which means you can run your experiments faster. A known-working RL
implementation can be found [in this repository](https://github.com/lcswillems/torch-rl).
Requirements:
- Python 3.7 to 3.10
- OpenAI Gym v0.26
- NumPy 1.18+
- Matplotlib (optional, only needed for display) - 3.0+
Please use this bibtex if you want to cite this repository in your publications:
```
@misc{gym_minigrid,
author = {Chevalier-Boisvert, Maxime and Willems, Lucas and Pal, Suman},
title = {Minimalistic Gridworld Environment for OpenAI Gym},
year = {2018},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/maximecb/gym-minigrid}},
}
```
List of publications & submissions using MiniGrid or BabyAI (please open a pull request to add missing entries):
- [History Compression via Language Models in Reinforcement Learning.](https://proceedings.mlr.press/v162/paischer22a.html) (Johannes Kepler University Linz, PMLR 2022)
- [Leveraging Approximate Symbolic Models for Reinforcement Learning via Skill Diversity](https://arxiv.org/abs/2202.02886) (Arizona State University, ICML 2022)
- [How to Stay Curious while avoiding Noisy TVs using Aleatoric Uncertainty Estimation](https://proceedings.mlr.press/v162/mavor-parker22a.html) (University College London, Boston University, ICML 2022)
- [In a Nutshell, the Human Asked for This: Latent Goals for Following Temporal Specifications](https://openreview.net/pdf?id=rUwm9wCjURV) (Imperial College London, ICLR 2022)
- [Interesting Object, Curious Agent: Learning Task-Agnostic Exploration](https://arxiv.org/abs/2111.13119) (Meta AI Research, NeurIPS 2021)
- [Safe Policy Optimization with Local Generalized Linear Function Approximations](https://arxiv.org/abs/2111.04894) (IBM Research, Tsinghua University, NeurIPS 2021)
- [A Consciousness-Inspired Planning Agent for Model-Based Reinforcement Learning](https://arxiv.org/abs/2106.02097) (Mila, McGill University, NeurIPS 2021)
- [SPOTTER: Extending Symbolic Planning Operators through Targeted Reinforcement Learning](http://www.ifaamas.org/Proceedings/aamas2021/pdfs/p1118.pdf) (Tufts University, SIFT, AAMAS 2021)
- [Grid-to-Graph: Flexible Spatial Relational Inductive Biases for Reinforcement Learning](https://arxiv.org/abs/2102.04220) (UCL, AAMAS 2021)
- [Rank the Episodes: A Simple Approach for Exploration in Procedurally-Generated Environments](https://openreview.net/forum?id=MtEE0CktZht) (Texas A&M University, Kuai Inc., ICLR 2021)
- [Adversarially Guided Actor-Critic](https://openreview.net/forum?id=_mQp5cr_iNy) (INRIA, Google Brain, ICLR 2021)
- [Information-theoretic Task Selection for Meta-Reinforcement Learning](https://papers.nips.cc/paper/2020/file/ec3183a7f107d1b8dbb90cb3c01ea7d5-Paper.pdf) (University of Leeds, NeurIPS 2020)
- [BeBold: Exploration Beyond the Boundary of Explored Regions](https://arxiv.org/pdf/2012.08621.pdf) (UCB, December 2020)
- [Approximate Information State for Approximate Planning and Reinforcement Learning in Partially Observed Systems](https://arxiv.org/abs/2010.08843) (McGill, October 2020)
- [Prioritized Level Replay](https://arxiv.org/pdf/2010.03934.pdf) (FAIR, October 2020)
- [AllenAct: A Framework for Embodied AI Research](https://arxiv.org/pdf/2008.12760.pdf) (Allen Institute for AI, August 2020)
- [Learning with AMIGO: Adversarially Motivated Intrinsic Goals](https://arxiv.org/pdf/2006.12122.pdf) (MIT, FAIR, ICLR 2021)
- [RIDE: Rewarding Impact-Driven Exploration for Procedurally-Generated Environments](https://openreview.net/forum?id=rkg-TJBFPB) (FAIR, ICLR 2020)
- [Learning to Request Guidance in Emergent Communication](https://arxiv.org/pdf/1912.05525.pdf) (University of Amsterdam, Dec 2019)
- [Working Memory Graphs](https://arxiv.org/abs/1911.07141) (MSR, Nov 2019)
- [Fast Task-Adaptation for Tasks Labeled Using Natural Language in Reinforcement Learning](https://arxiv.org/pdf/1910.04040.pdf) (Oct 2019, University of Antwerp)
- [Generalization in Reinforcement Learning with Selective Noise Injection and Information Bottleneck](https://arxiv.org/abs/1910.12911) (MSR, NeurIPS, Oct 2019)
- [Recurrent Independent Mechanisms](https://arxiv.org/pdf/1909.10893.pdf) (Mila, Sept 2019)
- [Learning Effective Subgoals with Multi-Task Hierarchical Reinforcement Learning](http://surl.tirl.info/proceedings/SURL-2019_paper_10.pdf) (Tsinghua University, August 2019)
- [Mastering emergent language: learning to guide in simulated navigation](https://arxiv.org/abs/1908.05135) (University of Amsterdam, Aug 2019)
- [Transfer Learning by Modeling a Distribution over Policies](https://arxiv.org/abs/1906.03574) (Mila, June 2019)
- [Reinforcement Learning with Competitive Ensembles of Information-Constrained Primitives](https://arxiv.org/abs/1906.10667) (Mila, June 2019)
- [Learning distant cause and effect using only local and immediate credit assignment](https://arxiv.org/abs/1905.11589) (Incubator 491, May 2019)
- [Practical Open-Loop Optimistic Planning](https://arxiv.org/abs/1904.04700) (INRIA, April 2019)
- [Learning World Graphs to Accelerate Hierarchical Reinforcement Learning](https://arxiv.org/abs/1907.00664) (Salesforce Research, 2019)
- [Variational State Encoding as Intrinsic Motivation in Reinforcement Learning](https://mila.quebec/wp-content/uploads/2019/05/WebPage.pdf) (Mila, TARL 2019)
- [Unsupervised Discovery of Decision States Through Intrinsic Control](https://tarl2019.github.io/assets/papers/modhe2019unsupervised.pdf) (Georgia Tech, TARL 2019)
- [Modeling the Long Term Future in Model-Based Reinforcement Learning](https://openreview.net/forum?id=SkgQBn0cF7) (Mila, ICLR 2019)
- [Unifying Ensemble Methods for Q-learning via Social Choice Theory](https://arxiv.org/pdf/1902.10646.pdf) (Max Planck Institute, Feb 2019)
- [Planning Beyond The Sensing Horizon Using a Learned Context](https://personalrobotics.cs.washington.edu/workshops/mlmp2018/assets/docs/18_CameraReadySubmission.pdf) (MLMP@IROS, 2018)
- [Guiding Policies with Language via Meta-Learning](https://arxiv.org/abs/1811.07882) (UC Berkeley, Nov 2018)
- [On the Complexity of Exploration in Goal-Driven Navigation](https://arxiv.org/abs/1811.06889) (CMU, NeurIPS, Nov 2018)
- [Transfer and Exploration via the Information Bottleneck](https://openreview.net/forum?id=rJg8yhAqKm) (Mila, Nov 2018)
- [Creating safer reward functions for reinforcement learning agents in the gridworld](https://gupea.ub.gu.se/bitstream/2077/62445/1/gupea_2077_62445_1.pdf) (University of Gothenburg, 2018)
- [BabyAI: First Steps Towards Grounded Language Learning With a Human In the Loop](https://arxiv.org/abs/1810.08272) (Mila, ICLR, Oct 2018)
This environment has been built as part of work done at [Mila](https://mila.quebec). The Dynamic obstacles environment has been added as part of work done at [IAS in TU Darmstadt](https://www.ias.informatik.tu-darmstadt.de/) and the University of Genoa for mobile robot navigation with dynamic obstacles.
## Installation
There is now a [pip package](https://pypi.org/project/gym-minigrid/) available, which is updated periodically:
```
pip3 install gym-minigrid
```
Alternatively, to get the latest version of MiniGrid, you can clone this repository and install the dependencies with `pip3`:
```
git clone https://github.com/maximecb/gym-minigrid.git
cd gym-minigrid
pip3 install -e .
```

525
gym_minigrid/README.md

@ -0,0 +1,525 @@
# MiniGrid (formerly gym-minigrid)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://pre-commit.com/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
There are other gridworld Gym environments out there, but this one is
designed to be particularly simple, lightweight and fast. The code has very few
dependencies, making it less likely to break or fail to install. It loads no
external sprites/textures, and it can run at up to 5000 FPS on a Core i7
laptop, which means you can run your experiments faster. A known-working RL
implementation can be found [in this repository](https://github.com/lcswillems/torch-rl).
Requirements:
- Python 3.7 to 3.10
- OpenAI Gym v0.26
- NumPy 1.18+
- Matplotlib (optional, only needed for display) - 3.0+
Please use this bibtex if you want to cite this repository in your publications:
```
@misc{gym_minigrid,
author = {Chevalier-Boisvert, Maxime and Willems, Lucas and Pal, Suman},
title = {Minimalistic Gridworld Environment for OpenAI Gym},
year = {2018},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/maximecb/gym-minigrid}},
}
```
List of publications & submissions using MiniGrid or BabyAI (please open a pull request to add missing entries):
- [History Compression via Language Models in Reinforcement Learning.](https://proceedings.mlr.press/v162/paischer22a.html) (Johannes Kepler University Linz, PMLR 2022)
- [Leveraging Approximate Symbolic Models for Reinforcement Learning via Skill Diversity](https://arxiv.org/abs/2202.02886) (Arizona State University, ICML 2022)
- [How to Stay Curious while avoiding Noisy TVs using Aleatoric Uncertainty Estimation](https://proceedings.mlr.press/v162/mavor-parker22a.html) (University College London, Boston University, ICML 2022)
- [In a Nutshell, the Human Asked for This: Latent Goals for Following Temporal Specifications](https://openreview.net/pdf?id=rUwm9wCjURV) (Imperial College London, ICLR 2022)
- [Interesting Object, Curious Agent: Learning Task-Agnostic Exploration](https://arxiv.org/abs/2111.13119) (Meta AI Research, NeurIPS 2021)
- [Safe Policy Optimization with Local Generalized Linear Function Approximations](https://arxiv.org/abs/2111.04894) (IBM Research, Tsinghua University, NeurIPS 2021)
- [A Consciousness-Inspired Planning Agent for Model-Based Reinforcement Learning](https://arxiv.org/abs/2106.02097) (Mila, McGill University, NeurIPS 2021)
- [SPOTTER: Extending Symbolic Planning Operators through Targeted Reinforcement Learning](http://www.ifaamas.org/Proceedings/aamas2021/pdfs/p1118.pdf) (Tufts University, SIFT, AAMAS 2021)
- [Grid-to-Graph: Flexible Spatial Relational Inductive Biases for Reinforcement Learning](https://arxiv.org/abs/2102.04220) (UCL, AAMAS 2021)
- [Rank the Episodes: A Simple Approach for Exploration in Procedurally-Generated Environments](https://openreview.net/forum?id=MtEE0CktZht) (Texas A&M University, Kuai Inc., ICLR 2021)
- [Adversarially Guided Actor-Critic](https://openreview.net/forum?id=_mQp5cr_iNy) (INRIA, Google Brain, ICLR 2021)
- [Information-theoretic Task Selection for Meta-Reinforcement Learning](https://papers.nips.cc/paper/2020/file/ec3183a7f107d1b8dbb90cb3c01ea7d5-Paper.pdf) (University of Leeds, NeurIPS 2020)
- [BeBold: Exploration Beyond the Boundary of Explored Regions](https://arxiv.org/pdf/2012.08621.pdf) (UCB, December 2020)
- [Approximate Information State for Approximate Planning and Reinforcement Learning in Partially Observed Systems](https://arxiv.org/abs/2010.08843) (McGill, October 2020)
- [Prioritized Level Replay](https://arxiv.org/pdf/2010.03934.pdf) (FAIR, October 2020)
- [AllenAct: A Framework for Embodied AI Research](https://arxiv.org/pdf/2008.12760.pdf) (Allen Institute for AI, August 2020)
- [Learning with AMIGO: Adversarially Motivated Intrinsic Goals](https://arxiv.org/pdf/2006.12122.pdf) (MIT, FAIR, ICLR 2021)
- [RIDE: Rewarding Impact-Driven Exploration for Procedurally-Generated Environments](https://openreview.net/forum?id=rkg-TJBFPB) (FAIR, ICLR 2020)
- [Learning to Request Guidance in Emergent Communication](https://arxiv.org/pdf/1912.05525.pdf) (University of Amsterdam, Dec 2019)
- [Working Memory Graphs](https://arxiv.org/abs/1911.07141) (MSR, Nov 2019)
- [Fast Task-Adaptation for Tasks Labeled Using Natural Language in Reinforcement Learning](https://arxiv.org/pdf/1910.04040.pdf) (Oct 2019, University of Antwerp)
- [Generalization in Reinforcement Learning with Selective Noise Injection and Information Bottleneck](https://arxiv.org/abs/1910.12911) (MSR, NeurIPS, Oct 2019)
- [Recurrent Independent Mechanisms](https://arxiv.org/pdf/1909.10893.pdf) (Mila, Sept 2019)
- [Learning Effective Subgoals with Multi-Task Hierarchical Reinforcement Learning](http://surl.tirl.info/proceedings/SURL-2019_paper_10.pdf) (Tsinghua University, August 2019)
- [Mastering emergent language: learning to guide in simulated navigation](https://arxiv.org/abs/1908.05135) (University of Amsterdam, Aug 2019)
- [Transfer Learning by Modeling a Distribution over Policies](https://arxiv.org/abs/1906.03574) (Mila, June 2019)
- [Reinforcement Learning with Competitive Ensembles of Information-Constrained Primitives](https://arxiv.org/abs/1906.10667) (Mila, June 2019)
- [Learning distant cause and effect using only local and immediate credit assignment](https://arxiv.org/abs/1905.11589) (Incubator 491, May 2019)
- [Practical Open-Loop Optimistic Planning](https://arxiv.org/abs/1904.04700) (INRIA, April 2019)
- [Learning World Graphs to Accelerate Hierarchical Reinforcement Learning](https://arxiv.org/abs/1907.00664) (Salesforce Research, 2019)
- [Variational State Encoding as Intrinsic Motivation in Reinforcement Learning](https://mila.quebec/wp-content/uploads/2019/05/WebPage.pdf) (Mila, TARL 2019)
- [Unsupervised Discovery of Decision States Through Intrinsic Control](https://tarl2019.github.io/assets/papers/modhe2019unsupervised.pdf) (Georgia Tech, TARL 2019)
- [Modeling the Long Term Future in Model-Based Reinforcement Learning](https://openreview.net/forum?id=SkgQBn0cF7) (Mila, ICLR 2019)
- [Unifying Ensemble Methods for Q-learning via Social Choice Theory](https://arxiv.org/pdf/1902.10646.pdf) (Max Planck Institute, Feb 2019)
- [Planning Beyond The Sensing Horizon Using a Learned Context](https://personalrobotics.cs.washington.edu/workshops/mlmp2018/assets/docs/18_CameraReadySubmission.pdf) (MLMP@IROS, 2018)
- [Guiding Policies with Language via Meta-Learning](https://arxiv.org/abs/1811.07882) (UC Berkeley, Nov 2018)
- [On the Complexity of Exploration in Goal-Driven Navigation](https://arxiv.org/abs/1811.06889) (CMU, NeurIPS, Nov 2018)
- [Transfer and Exploration via the Information Bottleneck](https://openreview.net/forum?id=rJg8yhAqKm) (Mila, Nov 2018)
- [Creating safer reward functions for reinforcement learning agents in the gridworld](https://gupea.ub.gu.se/bitstream/2077/62445/1/gupea_2077_62445_1.pdf) (University of Gothenburg, 2018)
- [BabyAI: First Steps Towards Grounded Language Learning With a Human In the Loop](https://arxiv.org/abs/1810.08272) (Mila, ICLR, Oct 2018)
This environment has been built as part of work done at [Mila](https://mila.quebec). The Dynamic obstacles environment has been added as part of work done at [IAS in TU Darmstadt](https://www.ias.informatik.tu-darmstadt.de/) and the University of Genoa for mobile robot navigation with dynamic obstacles.
## Installation
There is now a [pip package](https://pypi.org/project/gym-minigrid/) available, which is updated periodically:
```
pip3 install gym-minigrid
```
Alternatively, to get the latest version of MiniGrid, you can clone this repository and install the dependencies with `pip3`:
```
git clone https://github.com/maximecb/gym-minigrid.git
cd gym-minigrid
pip3 install -e .
```
## Basic Usage
There is a UI application which allows you to manually control the agent with the arrow keys:
```
./gym-minigrid/manual_control.py
```
The environment being run can be selected with the `--env` option, eg:
```
./gym-minigrid/manual_control.py --env MiniGrid-Empty-8x8-v0
```
## Reinforcement Learning
If you want to train an agent with reinforcement learning, I recommend using the code found in the [torch-rl](https://github.com/lcswillems/torch-rl) repository.
This code has been tested and is known to work with this environment. The default hyper-parameters are also known to converge.
A sample training command is:
```
cd torch-rl
python3 -m scripts.train --env MiniGrid-Empty-8x8-v0 --algo ppo
```
## Wrappers
MiniGrid is built to support tasks involving natural language and sparse rewards.
The observations are dictionaries, with an 'image' field, partially observable
view of the environment, a 'mission' field which is a textual string
describing the objective the agent should reach to get a reward, and a 'direction'
field which can be used as an optional compass. Using dictionaries makes it
easy for you to add additional information to observations
if you need to, without having to encode everything into a single tensor.
There are a variety of wrappers to change the observation format available in [gym_minigrid/wrappers.py](/gym_minigrid/wrappers.py).
If your RL code expects one single tensor for observations, take a look at `FlatObsWrapper`.
There is also an `ImgObsWrapper` that gets rid of the 'mission' field in observations, leaving only the image field tensor.
Please note that the default observation format is a partially observable view of the environment using a
compact and efficient encoding, with 3 input values per visible grid cell, 7x7x3 values total.
These values are **not pixels**. If you want to obtain an array of RGB pixels as observations instead,
use the `RGBImgPartialObsWrapper`. You can use it as follows:
```python
import gym
from gym_minigrid.wrappers import RGBImgPartialObsWrapper, ImgObsWrapper
env = gym.make('MiniGrid-Empty-8x8-v0')
env = RGBImgPartialObsWrapper(env) # Get pixel observations
env = ImgObsWrapper(env) # Get rid of the 'mission' field
obs, _ = env.reset() # This now produces an RGB tensor only
```
## Design
Structure of the world:
- The world is an NxM grid of tiles
- Each tile in the grid world contains zero or one object
- Cells that do not contain an object have the value `None`
- Each object has an associated discrete color (string)
- Each object has an associated type (string)
- Provided object types are: wall, floor, lava, door, key, ball, box and goal
- The agent can pick up and carry exactly one object (eg: ball or key)
- To open a locked door, the agent has to be carrying a key matching the door's color
Actions in the basic environment:
- Turn left
- Turn right
- Move forward
- Pick up an object
- Drop the object being carried
- Toggle (open doors, interact with objects)
- Done (task completed, optional)
Default tile/observation encoding:
- Each tile is encoded as a 3 dimensional tuple: `(OBJECT_IDX, COLOR_IDX, STATE)`
- `OBJECT_TO_IDX` and `COLOR_TO_IDX` mapping can be found in [gym_minigrid/minigrid.py](gym_minigrid/minigrid.py)
- `STATE` refers to the door state with 0=open, 1=closed and 2=locked
By default, sparse rewards are given for reaching a green goal tile. A
reward of 1 is given for success, and zero for failure. There is also an
environment-specific time step limit for completing the task.
You can define your own reward function by creating a class derived
from `MiniGridEnv`. Extending the environment with new object types or new actions
should be very easy. If you wish to do this, you should take a look at the
[gym_minigrid/minigrid.py](gym_minigrid/minigrid.py) source file.
## Included Environments
The environments listed below are implemented in the [gym_minigrid/envs](/gym_minigrid/envs) directory.
Each environment provides one or more configurations registered with OpenAI gym. Each environment
is also programmatically tunable in terms of size/complexity, which is useful for curriculum learning
or to fine-tune difficulty.
### Empty environment
This environment is an empty room, and the goal of the agent is to reach the
green goal square, which provides a sparse reward. A small penalty is
subtracted for the number of steps to reach the goal. This environment is
useful, with small rooms, to validate that your RL algorithm works correctly,
and with large rooms to experiment with sparse rewards and exploration.
The random variants of the environment have the agent starting at a random
position for each episode, while the regular variants have the agent always
starting in the corner opposite to the goal.
<p align="center">
<img src="figures/empty-env.png" width=250 alt="Figure of the empty environment">
</p>
Registered configurations:
- `MiniGrid-Empty-5x5-v0`
- `MiniGrid-Empty-Random-5x5-v0`
- `MiniGrid-Empty-6x6-v0`
- `MiniGrid-Empty-Random-6x6-v0`
- `MiniGrid-Empty-8x8-v0`
- `MiniGrid-Empty-16x16-v0`
### Four rooms environment
Classic four room reinforcement learning environment. The agent must navigate
in a maze composed of four rooms interconnected by 4 gaps in the walls. To
obtain a reward, the agent must reach the green goal square. Both the agent
and the goal square are randomly placed in any of the four rooms.
<p align="center">
<img src="figures/four-rooms-env.png" width=380 alt="Figure of the four room environment">
</p>
Registered configurations:
- `MiniGrid-FourRooms-v0`
### Door & key environment
This environment has a key that the agent must pick up in order to unlock
a goal and then get to the green goal square. This environment is difficult,
because of the sparse reward, to solve using classical RL algorithms. It is
useful to experiment with curiosity or curriculum learning.
<p align="center">
<img src="figures/door-key-env.png" alt="Figure of the door key environment">
</p>
Registered configurations:
- `MiniGrid-DoorKey-5x5-v0`
- `MiniGrid-DoorKey-6x6-v0`
- `MiniGrid-DoorKey-8x8-v0`
- `MiniGrid-DoorKey-16x16-v0`
### Multi-room environment
This environment has a series of connected rooms with doors that must be
opened in order to get to the next room. The final room has the green goal
square the agent must get to. This environment is extremely difficult to
solve using RL alone. However, by gradually increasing the number of
rooms and building a curriculum, the environment can be solved.
<p align="center">
<img src="figures/multi-room.gif" width=416 height=424 alt="Figure of the Multi-room environment">
</p>
Registered configurations:
- `MiniGrid-MultiRoom-N2-S4-v0` (two small rooms)
- `MiniGrid-MultiRoom-N4-S5-v0` (four rooms)
- `MiniGrid-MultiRoom-N6-v0` (six rooms)
### Fetch environment
This environment has multiple objects of assorted types and colors. The
agent receives a textual string as part of its observation telling it
which object to pick up. Picking up the wrong object terminates the
episode with zero reward.
<p align="center">
<img src="figures/fetch-env.png" width=450 alt="Figure of the fetch environment">
</p>
Registered configurations:
- `MiniGrid-Fetch-5x5-N2-v0`
- `MiniGrid-Fetch-6x6-N2-v0`
- `MiniGrid-Fetch-8x8-N3-v0`
### Go-to-door environment
This environment is a room with four doors, one on each wall. The agent
receives a textual (mission) string as input, telling it which door to go to,
(eg: "go to the red door"). It receives a positive reward for performing the
`done` action next to the correct door, as indicated in the mission string.
<p align="center">
<img src="figures/gotodoor-6x6.png" width=400 alt="Figure of the go-to-door environment">
</p>
Registered configurations:
- `MiniGrid-GoToDoor-5x5-v0`
- `MiniGrid-GoToDoor-6x6-v0`
- `MiniGrid-GoToDoor-8x8-v0`
### Put-near environment
The agent is instructed through a textual string to pick up an object and
place it next to another object. This environment is easy to solve with two
objects, but difficult to solve with more, as it involves both textual
understanding and spatial reasoning involving multiple objects.
Registered configurations:
- `MiniGrid-PutNear-6x6-N2-v0`
- `MiniGrid-PutNear-8x8-N3-v0`
### Red and blue doors environment
The agent is randomly placed within a room with one red and one blue door
facing opposite directions. The agent has to open the red door and then open
the blue door, in that order. Note that, surprisingly, this environment is
solvable without memory.
Registered configurations:
- `MiniGrid-RedBlueDoors-6x6-v0`
- `MiniGrid-RedBlueDoors-8x8-v0`
### Memory environment
This environment is a memory test. The agent starts in a small room
where it sees an object. It then has to go through a narrow hallway
which ends in a split. At each end of the split there is an object,
one of which is the same as the object in the starting room. The
agent has to remember the initial object, and go to the matching
object at split.
Registered configurations:
- `MiniGrid-MemoryS17Random-v0`
- `MiniGrid-MemoryS13Random-v0`
- `MiniGrid-MemoryS13-v0`
- `MiniGrid-MemoryS11-v0`
### Locked room environment
The environment has six rooms, one of which is locked. The agent receives
a textual mission string as input, telling it which room to go to in order
to get the key that opens the locked room. It then has to go into the locked
room in order to reach the final goal. This environment is extremely difficult
to solve with vanilla reinforcement learning alone.
Registered configurations:
- `MiniGrid-LockedRoom-v0`
### Key corridor environment
This environment is similar to the locked room environment, but there are
multiple registered environment configurations of increasing size,
making it easier to use curriculum learning to train an agent to solve it.
The agent has to pick up an object which is behind a locked door. The key is
hidden in another room, and the agent has to explore the environment to find
it. The mission string does not give the agent any clues as to where the
key is placed. This environment can be solved without relying on language.
<p align="center">
<img src="figures/KeyCorridorS3R1.png" width=250 alt="Figure of the Key Corridor for config S3R1">
<img src="figures/KeyCorridorS3R2.png" width=250 alt="Figure of the Key Corridor for config S3R2">
<img src="figures/KeyCorridorS3R3.png" width=250 alt="Figure of the Key Corridor for config S3R3">
<img src="figures/KeyCorridorS4R3.png" width=250 alt="Figure of the Key Corridor for config S4R3">
<img src="figures/KeyCorridorS5R3.png" width=250 alt="Figure of the Key Corridor for config S5R3">
<img src="figures/KeyCorridorS6R3.png" width=250 alt="Figure of the Key Corridor for config S6R3">
</p>
Registered configurations:
- `MiniGrid-KeyCorridorS3R1-v0`
- `MiniGrid-KeyCorridorS3R2-v0`
- `MiniGrid-KeyCorridorS3R3-v0`
- `MiniGrid-KeyCorridorS4R3-v0`
- `MiniGrid-KeyCorridorS5R3-v0`
- `MiniGrid-KeyCorridorS6R3-v0`
### Unlock environment
The agent has to open a locked door. This environment can be solved without
relying on language.
<p align="center">
<img src="figures/Unlock.png" width=200 alt="Figure of the unlock environment">
</p>
Registered configurations:
- `MiniGrid-Unlock-v0`
### Unlock pickup environment
The agent has to pick up a box which is placed in another room, behind a
locked door. This environment can be solved without relying on language.
<p align="center">
<img src="figures/UnlockPickup.png" width=250 alt="Figure of the unlock pickup environment">
</p>
Registered configurations:
- `MiniGrid-UnlockPickup-v0`
### Blocked unlock pickup environment
The agent has to pick up a box which is placed in another room, behind a
locked door. The door is also blocked by a ball which the agent has to move
before it can unlock the door. Hence, the agent has to learn to move the ball,
pick up the key, open the door and pick up the object in the other room.
This environment can be solved without relying on language.
<p align="center">
<img src="figures/BlockedUnlockPickup.png" width=250 alt="Figure of the blocked-unlock-pickup environment">
</p>
Registered configurations:
- `MiniGrid-BlockedUnlockPickup-v0`
## Obstructed maze environment
The agent has to pick up a box which is placed in a corner of a 3x3 maze.
The doors are locked, the keys are hidden in boxes and doors are obstructed
by balls. This environment can be solved without relying on language.
<p align="center">
<img src="figures/ObstructedMaze-1Dl.png" width="250">
<img src="figures/ObstructedMaze-1Dlh.png" width="250">
<img src="figures/ObstructedMaze-1Dlhb.png" width="250">
<img src="figures/ObstructedMaze-2Dl.png" width="100">
<img src="figures/ObstructedMaze-2Dlh.png" width="100">
<img src="figures/ObstructedMaze-2Dlhb.png" width="100">
<img src="figures/ObstructedMaze-1Q.png" width="250">
<img src="figures/ObstructedMaze-2Q.png" width="250">
<img src="figures/ObstructedMaze-4Q.png" width="250">
</p>
Registered configurations:
- `MiniGrid-ObstructedMaze-1Dl-v0`
- `MiniGrid-ObstructedMaze-1Dlh-v0`
- `MiniGrid-ObstructedMaze-1Dlhb-v0`
- `MiniGrid-ObstructedMaze-2Dl-v0`
- `MiniGrid-ObstructedMaze-2Dlh-v0`
- `MiniGrid-ObstructedMaze-2Dlhb-v0`
- `MiniGrid-ObstructedMaze-1Q-v0`
- `MiniGrid-ObstructedMaze-2Q-v0`
- `MiniGrid-ObstructedMaze-Full-v0`
## Distributional shift environment
This environment is based on one of the DeepMind [AI safety gridworlds](https://github.com/deepmind/ai-safety-gridworlds).
The agent starts in the top-left corner and must reach the goal which is in the top-right corner, but has to avoid stepping
into lava on its way. The aim of this environment is to test an agent's ability to generalize. There are two slightly
different variants of the environment, so that the agent can be trained on one variant and tested on the other.
<p align="center">
<img src="figures/DistShift1.png" width=200 alt="Figure of the DistShift1 environment">
<img src="figures/DistShift2.png" width=200 alt="Figure of the DistShift2 environment">
</p>
Registered configurations:
- `MiniGrid-DistShift1-v0`
- `MiniGrid-DistShift2-v0`
## Lava gap environment
The agent has to reach the green goal square at the opposite corner of the room,
and must pass through a narrow gap in a vertical strip of deadly lava. Touching
the lava terminate the episode with a zero reward. This environment is useful
for studying safety and safe exploration.
Registered configurations:
- `MiniGrid-LavaGapS5-v0`
- `MiniGrid-LavaGapS6-v0`
- `MiniGrid-LavaGapS7-v0`
<p align="center">
<img src="figures/LavaGapS6.png" width=200 alt="Figure of the LavaGap environment">
</p>
## Lava crossing environment
The agent has to reach the green goal square on the other corner of the room
while avoiding rivers of deadly lava which terminate the episode in failure.
Each lava stream runs across the room either horizontally or vertically, and
has a single crossing point which can be safely used; Luckily, a path to the
goal is guaranteed to exist. This environment is useful for studying safety and
safe exploration.
<p align="center">
<img src="figures/LavaCrossingS9N1.png" width=200 alt="Figure of the LavaCrossingS9N1 environment">
<img src="figures/LavaCrossingS9N2.png" width=200 alt="Figure of the LavaCrossingS9N2 environment">
<img src="figures/LavaCrossingS9N3.png" width=200 alt="Figure of the LavaCrossingS9N3 environment">
<img src="figures/LavaCrossingS11N5.png" width=250 alt="Figure of the LavaCrossingS11N5 environment">
</p>
Registered configurations:
- `MiniGrid-LavaCrossingS9N1-v0`
- `MiniGrid-LavaCrossingS9N2-v0`
- `MiniGrid-LavaCrossingS9N3-v0`
- `MiniGrid-LavaCrossingS11N5-v0`
## Simple crossing environment
Similar to the `LavaCrossing` environment, the agent has to reach the green
goal square on the other corner of the room, however lava is replaced by
walls. This MDP is therefore much easier and maybe useful for quickly
testing your algorithms.
<p align="center">
<img src="figures/SimpleCrossingS9N1.png" width=200 alt="Figure of the SimpleCrossingS9N1 environment">
<img src="figures/SimpleCrossingS9N2.png" width=200 alt="Figure of the SimpleCrossingS9N2 environment">
<img src="figures/SimpleCrossingS9N3.png" width=200 alt="Figure of the SimpleCrossingS9N3 environment">
<img src="figures/SimpleCrossingS11N5.png" width=250 alt="Figure of the SimpleCrossingS11N5 environment">
</p>
Registered configurations:
- `MiniGrid-SimpleCrossingS9N1-v0`
- `MiniGrid-SimpleCrossingS9N2-v0`
- `MiniGrid-SimpleCrossingS9N3-v0`
- `MiniGrid-SimpleCrossingS11N5-v0`
### Dynamic obstacles environment
This environment is an empty room with moving obstacles.
The goal of the agent is to reach the green goal square without colliding with any obstacle.
A large penalty is subtracted if the agent collides with an obstacle and the episode finishes.
This environment is useful to test Dynamic Obstacle Avoidance for mobile robots with Reinforcement Learning in Partial Observability.
<p align="center">
<img src="figures/dynamic_obstacles.gif" alt="GIF of the Dynamic Obstacles environment">
</p>
Registered configurations:
- `MiniGrid-Dynamic-Obstacles-5x5-v0`
- `MiniGrid-Dynamic-Obstacles-Random-5x5-v0`
- `MiniGrid-Dynamic-Obstacles-6x6-v0`
- `MiniGrid-Dynamic-Obstacles-Random-6x6-v0`
- `MiniGrid-Dynamic-Obstacles-8x8-v0`
- `MiniGrid-Dynamic-Obstacles-16x16-v0`

230
gym_minigrid/gym_minigrid/Task.py

@ -0,0 +1,230 @@
from abc import ABC
from typing import Iterable, List
try:
from astar import find_path
except:
print("Install with:")
print("pip install git+https://github.com/jrialland/python-astar.git")
raise Exception("Need to install astar")
import numpy.random
class Task(ABC):
# returns a bool, true if task is completed, false otherwise
def completed(self, pos, dir, carrying, env):
pass
# Returns the best action to solve this task
def get_best_action(self, pos, dir, carrying, env):
pass
# returns a string representing the task
def __repr__(self):
pass
def get_plan(pos, dir, carrying, env, goal_pos):
def neighbors_fnct_a_star(node):
left = (node[0], node[1], node[3], -node[2])
right = (node[0], node[1], -node[3], node[2])
fwd_pos = node[0] + node[2], node[1] + node[3]
forward_cell = env.grid.get(*fwd_pos)
forward_background = env.grid.get_background(*fwd_pos)
my_color = "red" if env.agent_pos == pos else env.grid.get(*pos).color
background_color = forward_background.color if forward_background is not None else None
forward_pos_open = forward_cell is None or forward_cell.can_overlap()
forward_pos_not_agent = fwd_pos != env.agent_pos
background_is_my_color_or_none_or_i_am_red = (forward_background is None or
(background_color == "lightblue" and my_color == "blue") or
(background_color == "lightgreen" and my_color == "green") or
(background_color == "lightgreen" and my_color == "purple") or # purple belongs to green region
my_color == "red") # red can do whatever
if forward_pos_open and forward_pos_not_agent and background_is_my_color_or_none_or_i_am_red:
forward = (node[0] + node[2], node[1] + node[3], node[2], node[3])
return forward, left, right
else:
return left, right
plan = find_path(
start=(pos[0], pos[1], dir[0], dir[1]),
goal=(goal_pos[0], goal_pos[1], dir[0], dir[1]),
neighbors_fnct=neighbors_fnct_a_star,
reversePath=False,
heuristic_cost_estimate_fnct=lambda a, b: abs(a[0] - b[0]) + abs(a[1] - b[1]),
distance_between_fnct=lambda a, b: 1.0,
is_goal_reached_fnct=lambda a, b: abs(a[0] - b[0]) + abs(a[1] - b[1]) <= 1
)
return list(plan) if plan is not None else None
class GoTo(Task):
def __init__(self, goal_position):
self.goal_position = goal_position
self.plan = None
def completed(self, pos, dir, carrying, env):
return pos == self.goal_position
def get_best_action(self, pos, dir, carrying, env):
# if farther than 1 unit away, Run A*
if self.plan is None or len(self.plan) == 0:
self.plan = get_plan(pos, dir, carrying, env, self.goal_position)
# if we have a plan, but we are not in the state we should be, create new plan
if self.plan is not None:
current_state_maybe = self.plan.pop(0)
if current_state_maybe[0] != pos[0] or \
current_state_maybe[1] != pos[1] or \
current_state_maybe[2] != dir[0] or \
current_state_maybe[3] != dir[1]:
self.plan = None # get_plan(pos, dir, carrying, env, self.goal_position)
return self.get_best_action(pos, dir, carrying, env)
if self.plan is None or len(self.plan) <= 1: # this will only happen if the agent is blocked in somehow
return 6 # done, does nothing
next_state = self.plan[0]
# decide how to achieve next state
if abs(next_state[0] - pos[0]) == 1 or abs(next_state[1] - pos[1]) == 1:
return 2 # forward
elif next_state[2] == dir[1] and next_state[3] == -dir[0]:
return 0 # left
elif next_state[2] == -dir[1] and next_state[3] == dir[0]:
return 1 # right
else: # something went wrong such as bumping into other agent, replan
self.plan = None
return self.get_best_action(pos, dir, carrying, env)
def __repr__(self):
return "Task: Go to position {}".format(self.goal_position)
class PickUpObject(Task):
def __init__(self, obj_position, obj):
self.obj_position = obj_position
self.obj = obj
self.plan = None
def completed(self, pos, dir, carrying, env):
return carrying == self.obj
def get_best_action(self, pos, dir, carrying, env):
d_x = self.obj_position[0] - pos[0]
d_y = self.obj_position[1] - pos[1]
# if farther than 1 unit away, Run A*
if abs(d_x) + abs(d_y) > 1:
# if we have no plan, create new plan
if self.plan is None or len(self.plan) == 0:
self.plan = get_plan(pos, dir, carrying, env, self.obj_position)
# if we have a plan, but we are not in the state we should be, create new plan
if self.plan is not None:
current_state_maybe = self.plan.pop(0)
if current_state_maybe[0] != pos[0] or \
current_state_maybe[1] != pos[1] or \
current_state_maybe[2] != dir[0] or \
current_state_maybe[3] != dir[1]:
self.plan = get_plan(pos, dir, carrying, env, self.obj_position)
if self.plan is None: # this will only happen if the agent is blocked in somehow
return 6 # done, does nothing
next_state = self.plan[0]
# decide how to achieve next state
if abs(next_state[0] - pos[0]) == 1 or abs(next_state[1] - pos[1]) == 1:
return 2 # forward
elif next_state[2] == dir[1] and next_state[3] == -dir[0]:
return 0 # left
elif next_state[2] == -dir[1] and next_state[3] == dir[0]:
return 1 # right
else: # something went wrong such as bumping into other agent, replan
self.plan = None
return self.get_best_action(pos, dir, carrying, env)
else:
if d_x != dir[0] or d_y != dir[1]:
return 0 # left
else:
return 3 # pickup
def __repr__(self):
return "Task: Pick up object at position {}".format(self.obj_position)
class PlaceObject(Task):
def __init__(self, obj_position, obj):
self.obj_position = obj_position
self.obj = obj
self.plan = None
def completed(self, pos, dir, carrying, env):
return env.grid.get(*self.obj_position) == self.obj and carrying is None
def get_best_action(self, pos, dir, carrying, env):
d_x = self.obj_position[0] - pos[0]
d_y = self.obj_position[1] - pos[1]
# if farther than 1 unit away, go to it
if abs(d_x) + abs(d_y) > 1:
# if we have no plan, create new plan
if self.plan is None or len(self.plan) == 0:
self.plan = get_plan(pos, dir, carrying, env, self.obj_position)
# if we have a plan, but we are not in the state we should be, create new plan
if self.plan is not None:
current_state_maybe = self.plan.pop(0)
if current_state_maybe[0] != pos[0] or \
current_state_maybe[1] != pos[1] or \
current_state_maybe[2] != dir[0] or \
current_state_maybe[3] != dir[1]:
self.plan = get_plan(pos, dir, carrying, env, self.obj_position)
if self.plan is None: # this will only happen if the agent is blocked in somehow
return 6 # done, does nothing
next_state = self.plan[0]
# decide how to achieve next state
if abs(next_state[0] - pos[0]) == 1 or \
abs(next_state[1] - pos[1]) == 1:
return 2 # forward
elif next_state[2] == dir[1] and next_state[3] == -dir[0]:
return 0 # left
elif next_state[2] == -dir[1] and next_state[3] == dir[0]:
return 1 # right
else: # something went wrong such as bumping into other agent, replan
self.plan = None
return self.get_best_action(pos, dir, carrying, env)
else:
if d_x != dir[0] or d_y != dir[1]:
return 0 # left
else:
return 4 # drop
def __repr__(self):
return "Task: Place object at position {}".format(self.obj_position)
class DoNothing(Task):
def __init__(self):
pass
def completed(self, pos, dir, carrying, env):
return False
def get_best_action(self, pos, dir, carrying, env):
return 6 # done
def __repr__(self):
return "Task: Do nothing"
class DoRandom(Task):
def __init__(self):
pass
def completed(self, pos, dir, carrying, env):
return False
def get_best_action(self, pos, dir, carrying, env):
return numpy.random.random_integers(0, 2, 1)# indexes between 0 and 2 are forward, left, right
def __repr__(self):
return "Task: Act randomly"
class TaskManager:
def __init__(self, tasks:List[Task]):
self.tasks = tasks
def get_best_action(self, pos, dir, carrying, env):
if len(self.tasks) == 0:
raise Exception("Task empty")
if self.tasks[0].completed(pos, dir, carrying, env):
self.tasks.pop(0)
best_action = self.tasks[0].get_best_action(pos, dir, carrying, env)
return best_action

625
gym_minigrid/gym_minigrid/__init__.py

@ -0,0 +1,625 @@
from warnings import warn
from gym.envs.registration import register
from gym_minigrid import minigrid, roomgrid, wrappers
from gym_minigrid.policyRepairEnv import *
def register_minigrid_envs():
# gym_minigrid package deprecated in favor of minigrid
warn(
"The package name gym_minigrid has been deprecated in favor of minigrid. Please uninstall gym_minigrid and install minigrid with `pip install minigrid`. Future releases will be maintained under the new package name minigrid.",
DeprecationWarning,
stacklevel=2,
)
# BlockedUnlockPickup
# ----------------------------------------
register(
id="MiniGrid-BlockedUnlockPickup-v0",
entry_point="gym_minigrid.envs:BlockedUnlockPickupEnv",
)
# LavaCrossing
# ----------------------------------------
register(
id="MiniGrid-LavaCrossingS9N1-v0",
entry_point="gym_minigrid.envs:CrossingEnv",
kwargs={"size": 9, "num_crossings": 1},
)
register(
id="MiniGrid-LavaCrossingS9N2-v0",
entry_point="gym_minigrid.envs:CrossingEnv",
kwargs={"size": 9, "num_crossings": 2},
)
register(
id="MiniGrid-LavaCrossingS9N3-v0",
entry_point="gym_minigrid.envs:CrossingEnv",
kwargs={"size": 9, "num_crossings": 3},
)
register(
id="MiniGrid-LavaCrossingS11N5-v0",
entry_point="gym_minigrid.envs:CrossingEnv",
kwargs={"size": 11, "num_crossings": 5},
)
# SimpleCrossing
# ----------------------------------------
register(
id="MiniGrid-SimpleCrossingS9N1-v0",
entry_point="gym_minigrid.envs:CrossingEnv",
kwargs={"size": 9, "num_crossings": 1, "obstacle_type": minigrid.Wall},
)
register(
id="MiniGrid-SimpleCrossingS9N2-v0",
entry_point="gym_minigrid.envs:CrossingEnv",
kwargs={"size": 9, "num_crossings": 2, "obstacle_type": minigrid.Wall},
)
register(
id="MiniGrid-SimpleCrossingS9N3-v0",
entry_point="gym_minigrid.envs:CrossingEnv",
kwargs={"size": 9, "num_crossings": 3, "obstacle_type": minigrid.Wall},
)
register(
id="MiniGrid-SimpleCrossingS11N5-v0",
entry_point="gym_minigrid.envs:CrossingEnv",
kwargs={"size": 11, "num_crossings": 5, "obstacle_type": minigrid.Wall},
)
# DistShift
# ----------------------------------------
register(
id="MiniGrid-DistShift1-v0",
entry_point="gym_minigrid.envs:DistShiftEnv",
kwargs={"strip2_row": 2},
)
register(
id="MiniGrid-DistShift2-v0",
entry_point="gym_minigrid.envs:DistShiftEnv",
kwargs={"strip2_row": 5},
)
# DoorKey
# ----------------------------------------
register(
id="MiniGrid-DoorKey-5x5-v0",
entry_point="gym_minigrid.envs:DoorKeyEnv",
kwargs={"size": 5},
)
register(
id="MiniGrid-DoorKey-6x6-v0",
entry_point="gym_minigrid.envs:DoorKeyEnv",
kwargs={"size": 5},
)
register(
id="MiniGrid-DoorKey-8x8-v0",
entry_point="gym_minigrid.envs:DoorKeyEnv",
kwargs={"size": 8},
)
register(
id="MiniGrid-DoorKey-16x16-v0",
entry_point="gym_minigrid.envs:DoorKeyEnv",
kwargs={"size": 16},
)
# Dynamic-Obstacles
# ----------------------------------------
register(
id="MiniGrid-Dynamic-Obstacles-5x5-v0",
entry_point="gym_minigrid.envs:DynamicObstaclesEnv",
kwargs={"size": 5, "n_obstacles": 2},
)
register(
id="MiniGrid-Dynamic-Obstacles-Random-5x5-v0",
entry_point="gym_minigrid.envs:DynamicObstaclesEnv",
kwargs={"size": 5, "agent_start_pos": None, "n_obstacles": 2},
)
register(
id="MiniGrid-Dynamic-Obstacles-6x6-v0",
entry_point="gym_minigrid.envs:DynamicObstaclesEnv",
kwargs={"size": 6, "n_obstacles": 3},
)
register(
id="MiniGrid-Dynamic-Obstacles-Random-6x6-v0",
entry_point="gym_minigrid.envs:DynamicObstaclesEnv",
kwargs={"size": 6, "agent_start_pos": None, "n_obstacles": 3},
)
register(
id="MiniGrid-Dynamic-Obstacles-8x8-v0",
entry_point="gym_minigrid.envs:DynamicObstaclesEnv",
)
register(
id="MiniGrid-Dynamic-Obstacles-16x16-v0",
entry_point="gym_minigrid.envs:DynamicObstaclesEnv",
kwargs={"size": 16, "n_obstacles": 8},
)
# Empty
# ----------------------------------------
register(
id="MiniGrid-Empty-5x5-v0",
entry_point="gym_minigrid.envs:EmptyEnv",
kwargs={"size": 5},
)
register(
id="MiniGrid-Empty-Random-5x5-v0",
entry_point="gym_minigrid.envs:EmptyEnv",
kwargs={"size": 5, "agent_start_pos": None},
)
register(
id="MiniGrid-Empty-6x6-v0",
entry_point="gym_minigrid.envs:EmptyEnv",
kwargs={"size": 6},
)
register(
id="MiniGrid-Empty-Random-6x6-v0",
entry_point="gym_minigrid.envs:EmptyEnv",
kwargs={"size": 6, "agent_start_pos": None},
)
register(
id="MiniGrid-Empty-8x8-v0",
entry_point="gym_minigrid.envs:EmptyEnv",
)
register(
id="MiniGrid-Empty-11x11-v0",
entry_point="gym_minigrid.envs:EmptyEnv",
kwargs={"size": 11},
)
register(
id="MiniGrid-Empty-16x16-v0",
entry_point="gym_minigrid.envs:EmptyEnv",
kwargs={"size": 16},
)
# Fetch
# ----------------------------------------
register(
id="MiniGrid-Fetch-5x5-N2-v0",
entry_point="gym_minigrid.envs:FetchEnv",
kwargs={"size": 5, "numObjs": 2},
)
register(
id="MiniGrid-Fetch-6x6-N2-v0",
entry_point="gym_minigrid.envs:FetchEnv",
kwargs={"size": 6, "numObjs": 2},
)
register(id="MiniGrid-Fetch-8x8-N3-v0", entry_point="gym_minigrid.envs:FetchEnv")
# FourRooms
# ----------------------------------------
register(
id="MiniGrid-FourRooms-v0",
entry_point="gym_minigrid.envs:FourRoomsEnv",
)
# GoToDoor
# ----------------------------------------
register(
id="MiniGrid-GoToDoor-5x5-v0",
entry_point="gym_minigrid.envs:GoToDoorEnv",
)
register(
id="MiniGrid-GoToDoor-6x6-v0",
entry_point="gym_minigrid.envs:GoToDoorEnv",
kwargs={"size": 6},
)
register(
id="MiniGrid-GoToDoor-8x8-v0",
entry_point="gym_minigrid.envs:GoToDoorEnv",
kwargs={"size": 8},
)
# GoToObject
# ----------------------------------------
register(
id="MiniGrid-GoToObject-6x6-N2-v0",
entry_point="gym_minigrid.envs:GoToObjectEnv",
)
register(
id="MiniGrid-GoToObject-8x8-N2-v0",
entry_point="gym_minigrid.envs:GoToObjectEnv",
kwargs={"size": 8, "numObjs": 2},
)
# KeyCorridor
# ----------------------------------------
register(
id="MiniGrid-KeyCorridorS3R1-v0",
entry_point="gym_minigrid.envs:KeyCorridorEnv",
kwargs={"room_size": 3, "num_rows": 1},
)
register(
id="MiniGrid-KeyCorridorS3R2-v0",
entry_point="gym_minigrid.envs:KeyCorridorEnv",
kwargs={"room_size": 3, "num_rows": 2},
)
register(
id="MiniGrid-KeyCorridorS3R3-v0",
entry_point="gym_minigrid.envs:KeyCorridorEnv",
kwargs={"room_size": 3, "num_rows": 3},
)
register(
id="MiniGrid-KeyCorridorS4R3-v0",
entry_point="gym_minigrid.envs:KeyCorridorEnv",
kwargs={"room_size": 4, "num_rows": 3},
)
register(
id="MiniGrid-KeyCorridorS5R3-v0",
entry_point="gym_minigrid.envs:KeyCorridorEnv",
kwargs={"room_size": 5, "num_rows": 3},
)
register(
id="MiniGrid-KeyCorridorS6R3-v0",
entry_point="gym_minigrid.envs:KeyCorridorEnv",
kwargs={"room_size": 6, "num_rows": 3},
)
# LavaGap
# ----------------------------------------
register(
id="MiniGrid-LavaGapS5-v0",
entry_point="gym_minigrid.envs:LavaGapEnv",
kwargs={"size": 5},
)
register(
id="MiniGrid-LavaGapS6-v0",
entry_point="gym_minigrid.envs:LavaGapEnv",
kwargs={"size": 6},
)
register(
id="MiniGrid-LavaGapS7-v0",
entry_point="gym_minigrid.envs:LavaGapEnv",
kwargs={"size": 7},
)
# LockedRoom
# ----------------------------------------
register(
id="MiniGrid-LockedRoom-v0",
entry_point="gym_minigrid.envs:LockedRoomEnv",
)
# Memory
# ----------------------------------------
register(
id="MiniGrid-MemoryS17Random-v0",
entry_point="gym_minigrid.envs:MemoryEnv",
kwargs={"size": 17, "random_length": True},
)
register(
id="MiniGrid-MemoryS13Random-v0",
entry_point="gym_minigrid.envs:MemoryEnv",
kwargs={"size": 13, "random_length": True},
)
register(
id="MiniGrid-MemoryS13-v0",
entry_point="gym_minigrid.envs:MemoryEnv",
kwargs={"size": 13},
)
register(
id="MiniGrid-MemoryS11-v0",
entry_point="gym_minigrid.envs:MemoryEnv",
kwargs={"size": 11},
)
register(
id="MiniGrid-MemoryS9-v0",
entry_point="gym_minigrid.envs:MemoryEnv",
kwargs={"size": 9},
)
register(
id="MiniGrid-MemoryS7-v0",
entry_point="gym_minigrid.envs:MemoryEnv",
kwargs={"size": 7},
)
# MultiRoom
# ----------------------------------------
register(
id="MiniGrid-MultiRoom-N2-S4-v0",
entry_point="gym_minigrid.envs:MultiRoomEnv",
kwargs={"minNumRooms": 2, "maxNumRooms": 2, "maxRoomSize": 4},
)
register(
id="MiniGrid-MultiRoom-N4-S5-v0",
entry_point="gym_minigrid.envs:MultiRoomEnv",
kwargs={"minNumRooms": 6, "maxNumRooms": 6, "maxRoomSize": 5},
)
register(
id="MiniGrid-MultiRoom-N6-v0",
entry_point="gym_minigrid.envs:MultiRoomEnv",
kwargs={"minNumRooms": 6, "maxNumRooms": 6},
)
# ObstructedMaze
# ----------------------------------------
register(
id="MiniGrid-ObstructedMaze-1Dl-v0",
entry_point="gym_minigrid.envs:ObstructedMaze_1Dlhb",
kwargs={"key_in_box": False, "blocked": False},
)
register(
id="MiniGrid-ObstructedMaze-1Dlh-v0",
entry_point="gym_minigrid.envs:ObstructedMaze_1Dlhb",
kwargs={"key_in_box": True, "blocked": False},
)
register(
id="MiniGrid-ObstructedMaze-1Dlhb-v0",
entry_point="gym_minigrid.envs:ObstructedMaze_1Dlhb",
)
register(
id="MiniGrid-ObstructedMaze-2Dl-v0",
entry_point="gym_minigrid.envs:ObstructedMaze_Full",
kwargs={
"agent_room": (2, 1),
"key_in_box": False,
"blocked": False,
"num_quarters": 1,
"num_rooms_visited": 4,
},
)
register(
id="MiniGrid-ObstructedMaze-2Dlh-v0",
entry_point="gym_minigrid.envs:ObstructedMaze_Full",
kwargs={
"agent_room": (2, 1),
"key_in_box": True,
"blocked": False,
"num_quarters": 1,
"num_rooms_visited": 4,
},
)
register(
id="MiniGrid-ObstructedMaze-2Dlhb-v0",
entry_point="gym_minigrid.envs:ObstructedMaze_Full",
kwargs={
"agent_room": (2, 1),
"key_in_box": True,
"blocked": True,
"num_quarters": 1,
"num_rooms_visited": 4,
},
)
register(
id="MiniGrid-ObstructedMaze-1Q-v0",
entry_point="gym_minigrid.envs:ObstructedMaze_Full",
kwargs={
"agent_room": (1, 1),
"key_in_box": True,
"blocked": True,
"num_quarters": 1,
"num_rooms_visited": 5,
},
)
register(
id="MiniGrid-ObstructedMaze-2Q-v0",
entry_point="gym_minigrid.envs:ObstructedMaze_Full",
kwargs={
"agent_room": (2, 1),
"key_in_box": True,
"blocked": True,
"num_quarters": 2,
"num_rooms_visited": 11,
},
)
register(
id="MiniGrid-ObstructedMaze-Full-v0",
entry_point="gym_minigrid.envs:ObstructedMaze_Full",
)
# Playground
# ----------------------------------------
register(
id="MiniGrid-Playground-v0",
entry_point="gym_minigrid.envs:PlaygroundEnv",
)
# PutNear
# ----------------------------------------
register(
id="MiniGrid-PutNear-6x6-N2-v0",
entry_point="gym_minigrid.envs:PutNearEnv",
)
register(
id="MiniGrid-PutNear-8x8-N3-v0",
entry_point="gym_minigrid.envs:PutNearEnv",
kwargs={"size": 8, "numObjs": 3},
)
# RedBlueDoors
# ----------------------------------------
register(
id="MiniGrid-RedBlueDoors-6x6-v0",
entry_point="gym_minigrid.envs:RedBlueDoorEnv",
kwargs={"size": 6},
)
register(
id="MiniGrid-RedBlueDoors-8x8-v0",
entry_point="gym_minigrid.envs:RedBlueDoorEnv",
)
# Unlock
# ----------------------------------------
register(id="MiniGrid-Unlock-v0", entry_point="gym_minigrid.envs:UnlockEnv")
# UnlockPickup
# ----------------------------------------
register(
id="MiniGrid-UnlockPickup-v0",
entry_point="gym_minigrid.envs:UnlockPickupEnv",
)
# GuidedRLExperiments
# ----------------------------------------
#register(
# id="MiniGrid-GuidedRLExperiments-TwoRooms-v0",
# entry_point="gym_minigrid.envs:TwoRooms",
#)
## AgExperiments
## ----------------------------------------
#register(
# id="MiniGrid-AgExperiments-DeliveryStations-v0",
# entry_point="gym_minigrid.envs:DeliveryStations",
#)
#register(
# id="MiniGrid-AgExperiments-DeliveryStationsWithRows-v0",
# entry_point="gym_minigrid.envs:DeliveryStationsWithRows",
#)
#register(
# id="MiniGrid-WareHouse",
# entry_point="gym_minigrid.envs:WareHouse",
#)
#register(
# id="MiniGrid-AgExperiments-DeliveryStationsSmall-v0",
# entry_point="gym_minigrid.envs:DeliveryStationsSmall",
#)
#register(
# id="MiniGrid-AgExperiments-DeliveryStationsSmallNoAg-v0",
# entry_point="gym_minigrid.envs:DeliveryStationsSmallNoAg",
#)
register(
id="Testing-v0",
entry_point="gym_minigrid.envs:Testing",
)
register(
id="LavaObstaclesMini-v0",
entry_point="gym_minigrid.envs:LavaObstaclesMini",
)
register(
id="LavaSymmetricMini-v0",
entry_point="gym_minigrid.envs:LavaSymmetricMini",
)
register(
id="SlipperyMini-v0",
entry_point="gym_minigrid.envs:SlipperyMini",
)
# Testing Playground
register(
id="Abagarion",
entry_point="gym_minigrid.envs:Abagarion",
)
register(
id="ColumnsMini-v0",
entry_point="gym_minigrid.envs:ColumnsMini",
)
register(
id="ExperimentSlippery-v0",
entry_point="gym_minigrid.envs:ExperimentSlippery",
)
#cliff walking
register(
id="MyCliffWalking-v0",
entry_point="gym_minigrid.envs:CliffWalking",
)
register(
id="MyCliffWalking-S11-v0",
entry_point="gym_minigrid.envs:CliffWalking",
kwargs={"size": 11, "nr_cliffs":2},
)
register(
id="MyCliffWalking-S16-v0",
entry_point="gym_minigrid.envs:CliffWalking",
kwargs={"size": 16, "nr_cliffs":3},
)
register(
id="MyCliffWalking-S20-v0",
entry_point="gym_minigrid.envs:CliffWalking",
kwargs={"size": 20, "nr_cliffs":4},
)
register(
id="MyCliffWalking-S25-v0",
entry_point="gym_minigrid.envs:CliffWalking",
kwargs={"size": 25, "nr_cliffs":5},
)

62
gym_minigrid/gym_minigrid/benchmark.py

@ -0,0 +1,62 @@
#!/usr/bin/env python3
import time
import gym
from gym_minigrid.wrappers import ImgObsWrapper, RGBImgPartialObsWrapper
def benchmark(env_id, num_resets, num_frames):
env = gym.make(env_id, render_mode="rgb_array")
# Benchmark env.reset
t0 = time.time()
for i in range(num_resets):
env.reset()
t1 = time.time()
dt = t1 - t0
reset_time = (1000 * dt) / num_resets
# Benchmark rendering
t0 = time.time()
for i in range(num_frames):
env.render()
t1 = time.time()
dt = t1 - t0
frames_per_sec = num_frames / dt
# Create an environment with an RGB agent observation
env = gym.make(env_id, render_mode="rgb_array")
env = RGBImgPartialObsWrapper(env)
env = ImgObsWrapper(env)
env.reset()
# Benchmark rendering
t0 = time.time()
for i in range(num_frames):
obs, reward, terminated, truncated, info = env.step(0)
t1 = time.time()
dt = t1 - t0
agent_view_fps = num_frames / dt
print(f"Env reset time: {reset_time:.1f} ms")
print(f"Rendering FPS : {frames_per_sec:.0f}")
print(f"Agent view FPS: {agent_view_fps:.0f}")
env.close()
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
"--env-id",
dest="env_id",
help="gym environment to load",
default="MiniGrid-LavaGapS7-v0",
)
parser.add_argument("--num_resets", default=200)
parser.add_argument("--num_frames", default=5000)
args = parser.parse_args()
benchmark(args.env_id, args.num_resets, args.num_frames)

40
gym_minigrid/gym_minigrid/envs/__init__.py

@ -0,0 +1,40 @@
from gym_minigrid.envs.blockedunlockpickup import BlockedUnlockPickupEnv
from gym_minigrid.envs.crossing import CrossingEnv
from gym_minigrid.envs.distshift import DistShiftEnv
from gym_minigrid.envs.doorkey import DoorKeyEnv
from gym_minigrid.envs.dynamicobstacles import DynamicObstaclesEnv
from gym_minigrid.envs.empty import EmptyEnv
from gym_minigrid.envs.fetch import FetchEnv
from gym_minigrid.envs.fourrooms import FourRoomsEnv
from gym_minigrid.envs.gotodoor import GoToDoorEnv
from gym_minigrid.envs.gotoobject import GoToObjectEnv
from gym_minigrid.envs.keycorridor import KeyCorridorEnv
from gym_minigrid.envs.lavagap import LavaGapEnv
from gym_minigrid.envs.lockedroom import LockedRoom, LockedRoomEnv
from gym_minigrid.envs.memory import MemoryEnv
from gym_minigrid.envs.multiroom import MultiRoom, MultiRoomEnv
from gym_minigrid.envs.obstructedmaze import (
ObstructedMaze_1Dlhb,
ObstructedMaze_Full,
ObstructedMazeEnv,
)
from gym_minigrid.envs.playground import PlaygroundEnv
from gym_minigrid.envs.putnear import PutNearEnv
from gym_minigrid.envs.redbluedoors import RedBlueDoorEnv
from gym_minigrid.envs.unlock import UnlockEnv
from gym_minigrid.envs.unlockpickup import UnlockPickupEnv
#from gym_minigrid.envs.guidedRLExperiments import TwoRooms
#from gym_minigrid.envs.agExperiments import DeliveryStations
#from gym_minigrid.envs.agSmall import DeliveryStationsSmall
#from gym_minigrid.envs.small import DeliveryStationsSmallNoAg
#from gym_minigrid.envs.warehouse import WareHouse
from gym_minigrid.envs.testing import Testing
import gym_minigrid.policyRepairEnv
from gym_minigrid.envs.lavaObstaclesMini import LavaObstaclesMini
from gym_minigrid.envs.lavaSymmetricMini import LavaSymmetricMini
from gym_minigrid.envs.slipperyMini import SlipperyMini
from gym_minigrid.envs.abagarion import Abagarion
from gym_minigrid.envs.columnsMini import ColumnsMini
from gym_minigrid.envs.slipperyMini import SlipperyMini
from gym_minigrid.envs.experimentSlippery import ExperimentSlippery
from gym_minigrid.envs.cliffWalking import CliffWalking

67
gym_minigrid/gym_minigrid/envs/abagarion.py

@ -0,0 +1,67 @@
# boilder plate code stolen from slipperyMini.py
# 3x3 Lava + Slippery Environment:
# WGWGWGWGWG
# WGXR WG
# WGSBVR WG
# WGSBSBGGWG
# WGWGWGWGWG
from gym_minigrid.minigrid import Goal, Grid, MiniGridEnv, MissionSpace, SlipperyNorth, Wall, HeatMapTile, Lava
from gym_minigrid.policyRepairEnv import PolicyRepairEnv
from gym_minigrid.minigrid import run_BFS_reward
class Abagarion(PolicyRepairEnv):
def __init__(self, size=5, agent_start_pos=(1, 1), agent_start_dir=0, **kwargs):
super().__init__(
size=size,
agent_start_pos=agent_start_pos,
agent_start_dir=agent_start_dir,
**kwargs
)
def _gen_grid(self, width, height):
# Create an empty grid
self.grid = Grid(width, height)
# Generate the surrounding walls
self.grid.wall_rect(0, 0, width, height)
# Place a goal square in the bottom-right corner
self.put_obj(Goal(), width - 2, height - 2)
self.put_obj(Lava(), 2, 2)
self.put_obj(SlipperyNorth(), 1, 2)
self.put_obj(SlipperyNorth(), 1, 3)
self.put_obj(SlipperyNorth(), 2, 3)
# Place the agent
if not self.agent_pos or (self.agent_pos[0] == -1 and self.agent_pos[1] == -1 and self.agent_dir == -1):
self.agent_pos = self.agent_start_pos
self.agent_dir = self.agent_start_dir
self.bfs_reward = run_BFS_reward(self.grid, (width - 2, height - 2))
self.mission = "get to the green goal square"
def step(self, action):
# Get the position in front of the agent
fwd_pos = self.front_pos
# Get the contents of the cell in front of the agent
fwd_cell = self.grid.get(*fwd_pos)
obs, reward, terminated, truncated, info = super().step(action)
#bfs reward
reward = self.bfs_reward[self.agent_pos[0] + self.grid.width * self.agent_pos[1]]
#negative reward for stepping in lava, positive reward for reaching goal
if action == self.actions.forward:
if fwd_cell is not None and fwd_cell.type == "goal":
reward += 100
elif fwd_cell is not None and fwd_cell.type == "lava":
reward -=100
if self.render_mode == "human":
print("step: {}, reward: {}, info: {}\t\t\tthat terminated: {}".format(self.total_timesteps, reward, info, terminated or truncated))
return obs, reward, terminated, truncated, info

172
gym_minigrid/gym_minigrid/envs/agExperimentSetTwo.py

@ -0,0 +1,172 @@
import numpy as np
from gym import spaces
from gym_minigrid.minigrid import Goal, Grid, MiniGridEnv, MissionSpace, Floor, Adversary, Box, SlipperyNorth
from gym_minigrid.Task import DoRandom, TaskManager, DoNothing, GoTo, PlaceObject, PickUpObject, Task
deliveryStation1Tile = Floor("blue")
deliveryStation2Tile = Floor("green")
deliveryStationRLTile = Floor("red")
deliveryRegion1Tile = Floor("lightblue")
deliveryRegion2Tile = Floor("lightgreen")
def random_boxes_in_region(env, amount, xTop, yTop, width, height, agent_pos, color="red"):
totalBoxCount = amount
while totalBoxCount > 0:
x = np.random.choice(range(xTop, width - 1))
y = np.random.choice(range(yTop, height - 1))
if env.grid.get(x,y) == None and (x,y) != agent_pos:
env.put_obj(Box(color),x,y)
totalBoxCount -= 1
class WareHouse(MiniGridEnv):
def __init__(self, agent_start_pos=(1, 7), agent_start_dir=0, sb3_mode=False, width=7, **kwargs):
self.agent_start_pos = agent_start_pos
self.agent_start_dir = agent_start_dir
mission_space = MissionSpace(
mission_func=lambda: "Avoid crashing into the other agents."
)
super().__init__(
mission_space=mission_space,
width=width,
height=17,
# Set this to True for maximum speed
see_through_walls=True,
**kwargs
)
def _gen_grid(self, width, height):
# Create an empty grid
assert(width > 6)
self.grid = Grid(width, height)
self.grid.set_background(1,7,deliveryRegion1Tile)
self.grid.set_background(1,8,deliveryRegion1Tile)
self.grid.set_background(1,9,deliveryRegion1Tile)
self.adversaries = []
self.add_adversary(5,5,"blue",1)
self.add_adversary(10,9,"green",3)
self.grid.wall_rect(0, 0, width, height)
self.grid.vert_wall(1,1 , 6)
self.grid.vert_wall(1,10, 6)
cols = (self.width - 4) // 3
for r in range(0, cols):
print(r)
self.grid.vert_wall(4 + r * 3,2 , 5)
self.grid.vert_wall(4 + r * 3,10, 5)
# Place the agent
if self.agent_start_pos is not None:
self.agent_pos = self.agent_start_pos
self.agent_dir = self.agent_start_dir
else:
self.place_agent()
random_boxes_in_region(self, 1, 3,1, self.width-1, self.height-1, self.agent_pos, "red")
random_boxes_in_region(self, 1, 3,1, self.width-1, self.height-1, self.agent_pos, "blue")
random_boxes_in_region(self, 1, 3,1, self.width-1, self.height-1, self.agent_pos, "green")
self.mission = "Avoid crashing into the other agents."
def step(self, action):
self.reward = 0.0
# need to augment this just like the agent, and we can hardcode a policy to follow
for adversary in self.adversaries:
blocked_positions = [adv.cur_pos for adv in self.adversaries]
agent_pos = self.agent_pos
advsersary_action = self.get_adversary_action(adversary)
self.move_adversary(adversary, advsersary_action, blocked_positions, agent_pos)
# get obs from env
obs, reward, terminated, truncated, info = super().step(action)
# reward function and done function are custom
reward = self.reward
terminated = self.done
return obs, reward, terminated, truncated, info
# Todo make this an intelligent adversary policy
def get_adversary_action(self, adversary):
return adversary.task_manager.get_best_action(adversary.cur_pos, adversary.dir_vec(), adversary.carrying, self)
# Moves the adversary according to current policy, code copy pasted from minigrid.step
def move_adversary(self, adversary, action, blocked_positions, agent_pos):
# fetch current location and forward location
cur_pos = adversary.cur_pos
current_cell = self.grid.get(*adversary.cur_pos)
fwd_pos = cur_pos + adversary.dir_vec()
fwd_cell = self.grid.get(*fwd_pos)
if action == self.actions.left:
adversary.adversary_dir -= 1
if adversary.adversary_dir < 0:
adversary.adversary_dir += 4
# Rotate right
elif action == self.actions.right:
adversary.adversary_dir = (adversary.adversary_dir + 1) % 4
# Move forward
elif action == self.actions.forward and isinstance(current_cell, SlipperyNorth):
print("TODO: actual slippery obs, for now: Teleporting the agent")
# TODO also what if blocked, see below
adversary.cur_pos = (3, 3)
elif action == self.actions.forward and not isinstance(current_cell, SlipperyNorth):
if tuple(fwd_pos) == agent_pos:
self.reward -= 0.1
elif (fwd_cell is None or fwd_cell.can_overlap()) and not tuple(fwd_pos) in blocked_positions:
adversary.cur_pos = tuple(fwd_pos)
# Pick up an object
elif action == self.actions.pickup:
if fwd_cell and fwd_cell.can_pickup():
if adversary.carrying is None:
adversary.carrying = fwd_cell
adversary.carrying.cur_pos = np.array([-1, -1])
self.grid.set(fwd_pos[0], fwd_pos[1], None)
# Drop an object
elif action == self.actions.drop:
if not fwd_cell and adversary.carrying:
self.grid.set(fwd_pos[0], fwd_pos[1], adversary.carrying)
adversary.carrying.cur_pos = fwd_pos
adversary.carrying = None
# Toggle/activate an object
elif action == self.actions.toggle:
if fwd_cell:
fwd_cell.toggle(self, fwd_pos)
# Done action (not used by default)
elif action == self.actions.done:
pass
else:
raise ValueError(f"Unknown action: {action}")
# finally update the env with these changes
self.grid.set(*cur_pos, None)
self.grid.set(*adversary.cur_pos, adversary)
def get_adversaries(self):
return [adversary.color for adversary in self.adversaries]
def get_property_map(self):
return { "blue" : ("SafetyAGBlue", 'concat(<_, PreSafety, lambda=0.89> <<Blue>> Pmax=? [ G !"BlueOnGreen" ], <SafetyAGBlue, PreSafety, lambda=0.89> <<Agent>> Pmax=? [G<10 !"crash" ] );'), "green": ("SafetyAGGreen", 'concat(<_, PreSafety, lambda=0.89> <<Green>> Pmax=? [ G !"GreenOnBlue" ], <SafetyAGGreen, PreSafety, lambda=0.89> <<Agent>> Pmax=? [G<10 !"crash" ] );') }
def get_shield_info(self):
#adv_positions = [(adv.color, adv.cur_pos[0], adv.cur_pos[1]) for adv in self.adversaries]
adv_positions = {adv.color : adv.cur_pos for adv in self.adversaries}
adv_directions = [adv.dir_vec() for adv in self.adversaries]
return self.agent_pos, self.agent_dir, adv_positions, adv_directions

498
gym_minigrid/gym_minigrid/envs/agExperiments.py

@ -0,0 +1,498 @@
import numpy as np
from gym import spaces
from gym_minigrid.minigrid import Goal, Grid, MiniGridEnv, MissionSpace, Floor, Adversary, Box, SlipperyNorth
from gym_minigrid.Task import DoRandom, TaskManager, DoNothing, GoTo, PlaceObject, PickUpObject, Task
deliveryStation1Tile = Floor("blue")
deliveryStation2Tile = Floor("green")
deliveryStationRLTile = Floor("red")
deliveryRegion1Tile = Floor("lightblue")
deliveryRegion2Tile = Floor("lightgreen")
class DeliveryStations(MiniGridEnv):
"""
### Description
This environment is an empty room, and the goal of the agent is to reach the
green goal square, which provides a sparse reward. A small penalty is
subtracted for the number of steps to reach the goal. This environment is
useful, with small rooms, to validate that your RL algorithm works
correctly, and with large rooms to experiment with sparse rewards and
exploration. The random variants of the environment have the agent starting
at a random position for each episode, while the regular variants have the
agent always starting in the corner opposite to the goal.
### Mission Space
"get to the green goal square"
### Action Space
| Num | Name | Action |
|-----|--------------|--------------|
| 0 | left | Turn left |
| 1 | right | Turn right |
| 2 | forward | Move forward |
| 3 | pickup | Unused |
| 4 | drop | Unused |
| 5 | toggle | Unused |
| 6 | done | Unused |
### Observation Encoding
- Each tile is encoded as a 3 dimensional tuple:
`(OBJECT_IDX, COLOR_IDX, STATE)`
- `OBJECT_TO_IDX` and `COLOR_TO_IDX` mapping can be found in
[gym_minigrid/minigrid.py](gym_minigrid/minigrid.py)
- `STATE` refers to the door state with 0=open, 1=closed and 2=locked
### Rewards
A reward of '1' is given for success, and '0' for failure.
### Termination
The episode ends if any one of the following conditions is met:
1. The agent reaches the goal.
2. Timeout (see `max_steps`).
### Registered Configurations
- `MiniGrid-Empty-5x5-v0`
- `MiniGrid-Empty-Random-5x5-v0`
- `MiniGrid-Empty-6x6-v0`
- `MiniGrid-Empty-Random-6x6-v0`
- `MiniGrid-Empty-8x8-v0`
- `MiniGrid-Empty-16x16-v0`
"""
def __init__(self, agent_start_pos=(1, 1), agent_start_dir=0, highlight:bool=False,
reward_type:str='Sparse', number_adversaries:int=2, max_steps=200,
shield_gamma=1.0, shield_horizon=30, collision_penalty=0.1, **kwargs):
assert reward_type == 'Sparse' or reward_type == 'Dense', "Must select either 'Sparse' or 'Dense' reward"
assert 0 <= number_adversaries <= 2, "Must select either 0, 1, or 2 adversaries"
self.collision_penalty = collision_penalty
self.shield_gamma = shield_gamma
self.shield_horizon = shield_horizon
self.agent_start_pos = agent_start_pos
self.agent_start_dir = agent_start_dir
self.number_adversaries = number_adversaries
self.reward_type = reward_type
mission_space = MissionSpace(
mission_func=lambda: "Avoid crashing into the other agents."
)
super().__init__(
mission_space=mission_space,
width=13,
height=13,
# Set this to True for maximum speed
highlight=highlight,
see_through_walls=True,
max_steps=max_steps,
**kwargs
)
def _gen_grid(self, width, height):
self.use_green_adversary = self.number_adversaries == 2
self.use_blue_adversary = self.number_adversaries >= 1
# Create an empty grid
self.grid = Grid(width, height)
# add walls
self.grid.wall_rect(0, 0, width, height) # outside border
self.grid.horz_wall(2, 2, width - 4) # top wall
self.grid.horz_wall(2, height - 3, width - 4) # bottom wall
self.grid.horz_wall(2, int(height/2), width - 4) # middle wall
# find where to spawn boxes
self.potential_box_locations_red = []
self.potential_box_locations_green = []
self.potential_box_locations_blue = []
for i in range(1,width-1):
for j in range(1,4):
if j != 2 or (i == 1 or i == width-2):
self.grid.set_background(i,j,deliveryRegion1Tile)
for j in range(height - 4, height-1):
if j != height-3 or (i == 1 or i == width-2):
self.grid.set_background(i,j,deliveryRegion2Tile)
if i != 1 and i != width-2:
if i == 2 or i == 3 or i == 4:
self.potential_box_locations_red.append((i, int(height/2)+1))
self.potential_box_locations_red.append((i, int(height/2)-1))
self.potential_box_locations_green.append((i, int(height/2)-1))
self.potential_box_locations_blue.append((i, int(height/2)+1))
# get all possible spawn locations
self.potential_spawn_locations_blue = []
self.potential_spawn_locations_green = []
for i in range(1,width-1):
for j in range(1, height-1):
# add a buffer around the agent spawn location
if abs(i - self.agent_start_pos[0]) <= 1 or abs(j - self.agent_start_pos[1]) <= 1:
continue
obj = self.grid.get(i,j)
bg = self.grid.get_background(i, j)
if obj is None:
if bg is None or bg.color == 'lightblue':
self.potential_spawn_locations_blue.append((i,j))
if bg is None or bg.color == 'lightgreen':
self.potential_spawn_locations_green.append((i,j))
self.red_delivery_station = (2,1)
self.grid.set_background(*self.red_delivery_station,deliveryStationRLTile)
self.blue_delivery_station = (8,1)
self.grid.set_background(*self.blue_delivery_station,deliveryStation1Tile)
self.green_delivery_station = (6,height - 2)
self.grid.set_background(*self.green_delivery_station,deliveryStation2Tile)
self.adversaries = {}
if self.use_blue_adversary:
random_start = self.get_viable_location(self.potential_spawn_locations_blue)
self.add_adversary(*random_start, "blue", np.random.randint(low=0, high=4), [DoNothing()])
self.add_blue_box()
if self.use_green_adversary:
random_start = self.get_viable_location(self.potential_spawn_locations_green)
self.add_adversary(*random_start, "green", np.random.randint(low=0, high=4), [DoNothing()])
self.add_green_box()
# learning agent boxes
red_random_box_location1 = self.get_viable_location(self.potential_box_locations_red)
self.grid.set(*red_random_box_location1,Box("red"))
if self.reward_type == 'Dense':
self.learning_agent_manager = TaskManager([
PickUpObject(red_random_box_location1, self.grid.get(*red_random_box_location1)),
PlaceObject(self.red_delivery_station, self.grid.get(*red_random_box_location1)),
DoNothing()
])
# Place the agent
if self.agent_start_pos is not None:
self.agent_pos = self.agent_start_pos
self.agent_dir = self.agent_start_dir
else:
self.place_agent()
self.mission = "Avoid crashing into the other agents."
def add_blue_box(self):
random_box_location1 = self.get_viable_location(self.potential_box_locations_blue)
self.grid.set(*random_box_location1, Box("blue"))
self.adversaries["blue"].task_manager.tasks.insert(0,PickUpObject(random_box_location1, self.grid.get(*random_box_location1)))
self.adversaries["blue"].task_manager.tasks.insert(1, PlaceObject(self.blue_delivery_station, self.grid.get(*random_box_location1)))
def add_green_box(self):
random_box_location1 = self.get_viable_location(self.potential_box_locations_green)
self.grid.set(*random_box_location1, Box("green"))
self.adversaries["green"].task_manager.tasks.insert(0,PickUpObject(random_box_location1, self.grid.get(*random_box_location1)))
self.adversaries["green"].task_manager.tasks.insert(1, PlaceObject(self.green_delivery_station, self.grid.get(*random_box_location1)))
def add_red_box(self):
random_box_location1 = self.get_viable_location(self.potential_box_locations_red)
self.grid.set(*random_box_location1, Box("red"))
if self.reward_type == 'Dense':
self.learning_agent_manager.tasks.insert(0,PickUpObject(random_box_location1, self.grid.get(*random_box_location1)))
self.learning_agent_manager.tasks.insert(1, PlaceObject(self.red_delivery_station, self.grid.get(*random_box_location1)))
def step(self, action):
delete_list = list()
for position, box in self.background_boxes.items():
if self.grid.get(*position) is None:
self.grid.set(*position, box)
self.grid.set_background(*position, None)
delete_list.append(tuple(position))
#else:
# print("Cannot remove box at {}, {} from backgroud".format(*position))
for position in delete_list:
#print("Removed box at {}, {} from backgroud".format(*position))
del self.background_boxes[position]
self.reward = 0.0
obs, reward, terminated, truncated, info = super().step(action)
# need to augment this just like the agent, and we can hardcode a policy to follow
for adversary in self.adversaries.values():
blocked_positions = [adv.cur_pos for adv in self.adversaries.values()]
agent_pos = self.agent_pos
advsersary_action = self.get_adversary_action(adversary)
self.move_adversary(adversary, advsersary_action, blocked_positions, agent_pos)
if self.reward_type == 'Dense':
# starting_pos = self.agent_pos
best_action = self.learning_agent_manager.get_best_action(self.agent_pos, self.dir_vec, self.carrying, self)
if action == best_action:
self.reward += 0.1
else:
self.reward -= 0.1
# reward function and done function are custom
reward = self.reward
if self.reward_type == 'Dense':
# current_pos = self.agent_pos
# goal_pos = self.learning_agent_manager.tasks[0].obj_position
# starting_distance = abs(starting_pos[0] - goal_pos[0]) + abs(starting_pos[1] - goal_pos[1])
# ending_distance = abs(current_pos[0] - goal_pos[0]) + abs(current_pos[1] - goal_pos[1])
# reward += 0.1 * (starting_distance - ending_distance)
# if self.learning_agent_manager.tasks[0].completed(self.agent_pos, self.dir_vec, self.carrying, self):
# self.learning_agent_manager.tasks.pop(0)
if self.learning_agent_manager.tasks[0].completed(self.agent_pos, self.dir_vec, self.carrying, self):
self.learning_agent_manager.tasks.pop(0)
# respawn boxes as needed
maybe_red_box = self.grid.get(*self.red_delivery_station)
if maybe_red_box and isinstance(maybe_red_box, Box) and maybe_red_box.color == 'red':
self.grid.set(*self.red_delivery_station, None)
self.add_red_box()
# respawn green box
if self.use_green_adversary:
maybe_green_box = self.grid.get(*self.green_delivery_station)
if maybe_green_box and isinstance(maybe_green_box, Box) and maybe_green_box.color == 'green':
self.grid.set(*self.green_delivery_station, None)
self.add_green_box()
# respawn blue box
if self.use_blue_adversary:
maybe_blue_box = self.grid.get(*self.blue_delivery_station)
if maybe_blue_box and isinstance(maybe_blue_box, Box) and maybe_blue_box.color == 'blue':
self.grid.set(*self.blue_delivery_station, None)
self.add_blue_box()
return obs, reward, terminated, truncated, info
def seed(self, seed):
np.random.seed(seed)
return seed
def get_adversary_action(self, adversary):
return adversary.task_manager.get_best_action(adversary.cur_pos, adversary.dir_vec(), adversary.carrying, self)
def get_viable_location(self, locations):
viable = False
while not viable:
location = locations[np.random.randint(low=0, high=len(locations))]
if self.grid.get(*location) is None and self.agent_pos != location:
viable = True
return location
# Moves the adversary according to current policy, code copy pasted from minigrid.step
def move_adversary(self, adversary, action, blocked_positions, agent_pos):
# fetch current location and forward location
cur_pos = adversary.cur_pos
current_cell = self.grid.get(*adversary.cur_pos)
fwd_pos = cur_pos + adversary.dir_vec()
fwd_cell = self.grid.get(*fwd_pos)
if action == self.actions.left:
adversary.adversary_dir -= 1
if adversary.adversary_dir < 0:
adversary.adversary_dir += 4
# Rotate right
elif action == self.actions.right:
adversary.adversary_dir = (adversary.adversary_dir + 1) % 4
# Move forward
elif action == self.actions.forward and isinstance(current_cell, SlipperyNorth):
print("TODO: actual slippery obs, for now: Teleporting the agent")
# TODO also what if blocked, see below
adversary.cur_pos = (3, 3)
elif action == self.actions.forward and not isinstance(current_cell, SlipperyNorth):
if tuple(fwd_pos) == agent_pos:
self.reward -= self.collision_penalty
self.safety_violations_this_episode += 1
elif (fwd_cell is None or fwd_cell.can_overlap()) and not tuple(fwd_pos) in blocked_positions:
if isinstance(fwd_cell, Box):
print("set background: ", fwd_cell)
self.grid.set_background(*fwd_pos,fwd_cell)
self.background_boxes[tuple(fwd_pos)] = fwd_cell # np.array is not hashable
adversary.cur_pos = tuple(fwd_pos)
# Pick up an object
elif action == self.actions.pickup:
if fwd_cell and fwd_cell.can_pickup():
if adversary.carrying is None:
adversary.carrying = fwd_cell
adversary.carrying.cur_pos = np.array([-1, -1])
self.grid.set(fwd_pos[0], fwd_pos[1], None)
# Drop an object
elif action == self.actions.drop:
if not fwd_cell and adversary.carrying:
self.grid.set(fwd_pos[0], fwd_pos[1], adversary.carrying)
adversary.carrying.cur_pos = fwd_pos
adversary.carrying = None
# Toggle/activate an object
elif action == self.actions.toggle:
if fwd_cell:
fwd_cell.toggle(self, fwd_pos)
# Done action (not used by default)
elif action == self.actions.done:
pass
else:
raise ValueError(f"Unknown action: {action}")
# finally update the env with these changes
self.grid.set(*cur_pos, None)
self.grid.set(*adversary.cur_pos, adversary)
def get_adversaries(self):
return [adversary.color for adversary in self.adversaries.values()]
def get_property_map(self):
return { "blue" : ("SafetyAGBlue", 'concat(<_, PreSafety, gamma={}> <<Blue>> Pmax=? [ G !"BlueOnGreen" ], <SafetyAGBlue, PreSafety, gamma={}> <<Agent>> Pmax=? [G<{} !"crash" ] );'.format(self.shield_gamma, self.shield_gamma, self.shield_horizon)),
"green": ("SafetyAGGreen", 'concat(<_, PreSafety, gamma={}> <<Green>> Pmax=? [ G !"GreenOnBlue" ], <SafetyAGGreen, PreSafety, gamma={}> <<Agent>> Pmax=? [G<{} !"crash" ] );'.format(self.shield_gamma, self.shield_gamma, self.shield_horizon))
}
def get_shield_info(self):
adversary_info = {color : ((adv.cur_pos[1], adv.cur_pos[0]), adv.adversary_dir) for (color,adv) in self.adversaries.items()}
return self.agent_pos, self.agent_dir, adversary_info
class DeliveryStationsWithRows(MiniGridEnv):
"""
### Description
This environment is an empty room, and the goal of the agent is to reach the
green goal square, which provides a sparse reward. A small penalty is
subtracted for the number of steps to reach the goal. This environment is
useful, with small rooms, to validate that your RL algorithm works
correctly, and with large rooms to experiment with sparse rewards and
exploration. The random variants of the environment have the agent starting
at a random position for each episode, while the regular variants have the
agent always starting in the corner opposite to the goal.
### Mission Space
"get to the green goal square"
### Action Space
| Num | Name | Action |
|-----|--------------|--------------|
| 0 | left | Turn left |
| 1 | right | Turn right |
| 2 | forward | Move forward |
| 3 | pickup | Unused |
| 4 | drop | Unused |
| 5 | toggle | Unused |
| 6 | done | Unused |
### Observation Encoding
- Each tile is encoded as a 3 dimensional tuple:
`(OBJECT_IDX, COLOR_IDX, STATE)`
- `OBJECT_TO_IDX` and `COLOR_TO_IDX` mapping can be found in
[gym_minigrid/minigrid.py](gym_minigrid/minigrid.py)
- `STATE` refers to the door state with 0=open, 1=closed and 2=locked
### Rewards
A reward of '1' is given for success, and '0' for failure.
### Termination
The episode ends if any one of the following conditions is met:
1. The agent reaches the goal.
2. Timeout (see `max_steps`).
### Registered Configurations
- `MiniGrid-Empty-5x5-v0`
- `MiniGrid-Empty-Random-5x5-v0`
- `MiniGrid-Empty-6x6-v0`
- `MiniGrid-Empty-Random-6x6-v0`
- `MiniGrid-Empty-8x8-v0`
- `MiniGrid-Empty-16x16-v0`
"""
def __init__(self, size=8, agent_start_pos=(1, 1), agent_start_dir=0, **kwargs):
self.agent_start_pos = agent_start_pos
self.agent_start_dir = agent_start_dir
mission_space = MissionSpace(
mission_func=lambda: "Delivery packages while avoiding crashes."
)
super().__init__(
mission_space=mission_space,
width=13,
height=13,
max_steps=400000,
# Set this to True for maximum speed
see_through_walls=True,
**kwargs
)
def _gen_grid(self, width, height):
# Create an empty grid
self.grid = Grid(width, height)
# Generate the surrounding walls
self.grid.wall_rect(0, 0, width, height)
for j in range(2, height - 2):
if j % 3 == 1: continue
if j % 3 == 2: continue
self.grid.horz_wall(2, j, width - 4)
self.grid.set(4,1,deliveryStationRLTile)
self.grid.set(5,1,deliveryStationRLTile)
self.grid.set(8,1,deliveryStation1Tile)
self.grid.set(9,1,deliveryStation1Tile)
self.grid.set(5,height - 2,deliveryStation2Tile)
self.grid.set(6,height - 2,deliveryStation2Tile)
self.grid.set(5,7,Adversary(2,"blue"))
self.grid.set(3,4,Adversary(1,"green"))
self.grid.set(3,7,Box("blue"))
self.grid.set(4,7,Box("green"))
self.grid.set(6,5,Box("blue"))
self.grid.set(8,5,Box("green"))
self.grid.set(7,5,Box("red"))
self.grid.set(8,7,Box("green"))
self.grid.set(4,4,Box("red"))
# Place the agent
if self.agent_start_pos is not None:
self.agent_pos = self.agent_start_pos
self.agent_dir = self.agent_start_dir
else:
self.place_agent()
self.mission = "Delivery packages while avoiding crashes."

439
gym_minigrid/gym_minigrid/envs/agSmall.py

@ -0,0 +1,439 @@
import numpy as np
from gym import spaces
from gym_minigrid.minigrid import Goal, Grid, MiniGridEnv, MissionSpace, Floor, Adversary, Box, SlipperyNorth, run_BFS_reward
from gym_minigrid.Task import DoRandom, TaskManager, DoNothing, GoTo, PlaceObject, PickUpObject, Task
from copy import deepcopy
import sys
deliveryStation1Tile = Floor("blue")
deliveryStation2Tile = Floor("green")
deliveryStation3Tile = Floor("purple")
deliveryStationRLTile = Floor("red")
deliveryRegion1Tile = Floor("lightblue")
deliveryRegion2Tile = Floor("lightgreen")
deliveryRegion3Tile = Floor("lightpurple")
class DeliveryStationsSmall(MiniGridEnv):
def __init__(self, agent_start_pos=(1, 1), agent_start_dir=0, highlight:bool=False,
reward_type:str='Dense', number_adversaries:int=3, max_steps=200,
shield_gamma=1.0, shield_horizon=30, collision_penalty=0.1, **kwargs):
assert reward_type == 'Sparse' or reward_type == 'Dense', "Must select either 'Sparse' or 'Dense' reward"
assert 0 <= number_adversaries <= 3, "Must select either 0, 1, 2 or 3 adversaries"
self.collision_penalty = collision_penalty
self.shield_gamma = shield_gamma
self.shield_horizon = shield_horizon
self.agent_start_pos = agent_start_pos
self.agent_start_dir = agent_start_dir
self.number_adversaries = number_adversaries
self.reward_type = reward_type
mission_space = MissionSpace(
mission_func=lambda: "Avoid crashing into the other agents."
)
super().__init__(
mission_space=mission_space,
width=13,
height=13,
# Set this to True for maximum speed
highlight=highlight,
see_through_walls=True,
max_steps=max_steps,
**kwargs
)
def _gen_grid(self, width, height):
self.use_purple_adversary = self.number_adversaries >= 3
self.use_blue_adversary = self.number_adversaries >= 2
self.use_green_adversary = self.number_adversaries >= 1
# Create an empty grid
self.grid = Grid(width, height)
# add walls
self.grid.wall_rect(0, 0, width, height) # outside border
self.grid.horz_wall(2, 2, width - 4) # top wall
self.grid.horz_wall(2, height - 3, width - 4) # bottom wall
#self.grid.horz_wall(2, int(height/2), width - 4) # middle wall
# find where to spawn boxes
self.potential_box_locations_red = []
self.potential_box_locations_green = []
self.potential_box_locations_blue = []
self.potential_box_locations_purple = []
for i in range(1,width-1):
for j in range(1,4):
if j != 2 or (i == 1 or i == width-2):
self.grid.set_background(i,j,deliveryRegion1Tile)
for j in range(height - 4, height-1):
if j != height-3 or (i == 1 or i == width-2):
self.grid.set_background(i,j,deliveryRegion2Tile)
#if i != 1 and i != width-2:
# if i == 2 or i == 3 or i == 4:
# self.potential_box_locations_red.append((i, int(height/2)+1))
# self.potential_box_locations_red.append((i, int(height/2)-1))
self.potential_box_locations_red.append((3, int(height/2)+1))
self.potential_box_locations_red.append((3, int(height/2)-1))
self.potential_box_locations_red.append((5, int(height/2)-1))
self.potential_box_locations_red.append((5, int(height/2)+1))
self.potential_box_locations_red.append((4, int(height/2)-1))
self.potential_box_locations_red.append((4, int(height/2)+1))
self.potential_box_locations_blue.append((2, int(height/2)-2))
self.potential_box_locations_blue.append((2, int(height/2)-1))
self.potential_box_locations_blue.append((2, int(height/2)+1))
self.potential_box_locations_blue.append((2, int(height/2)+2))
self.potential_box_locations_blue.append((4, int(height/2)-2))
self.potential_box_locations_blue.append((4, int(height/2)-1))
self.potential_box_locations_blue.append((4, int(height/2)+1))
self.potential_box_locations_blue.append((4, int(height/2)+2))
self.potential_box_locations_blue.append((6, int(height/2)-2))
self.potential_box_locations_blue.append((6, int(height/2)-1))
self.potential_box_locations_blue.append((6, int(height/2)+1))
self.potential_box_locations_blue.append((6, int(height/2)+2))
self.potential_box_locations_blue.append((8, int(height/2)-2))
self.potential_box_locations_blue.append((8, int(height/2)-1))
self.potential_box_locations_blue.append((8, int(height/2)+1))
self.potential_box_locations_blue.append((8, int(height/2)+2))
self.potential_box_locations_green.append((2, int(height/2)-2))
self.potential_box_locations_green.append((2, int(height/2)-1))
self.potential_box_locations_green.append((2, int(height/2)+1))
self.potential_box_locations_green.append((2, int(height/2)+2))
self.potential_box_locations_green.append((4, int(height/2)-2))
self.potential_box_locations_green.append((4, int(height/2)-1))
self.potential_box_locations_green.append((4, int(height/2)+1))
self.potential_box_locations_green.append((4, int(height/2)+2))
#self.potential_box_locations_green.append((6, int(height/2)-2))
#self.potential_box_locations_green.append((6, int(height/2)-1))
#self.potential_box_locations_green.append((6, int(height/2)+1))
#self.potential_box_locations_green.append((6, int(height/2)+2))
#self.potential_box_locations_green.append((8, int(height/2)-2))
#self.potential_box_locations_green.append((8, int(height/2)-1))
#self.potential_box_locations_green.append((8, int(height/2)+1))
#self.potential_box_locations_green.append((8, int(height/2)+2))
#self.potential_box_locations_purple.append((2, int(height/2)-2))
#self.potential_box_locations_purple.append((2, int(height/2)-1))
#self.potential_box_locations_purple.append((2, int(height/2)+1))
#self.potential_box_locations_purple.append((2, int(height/2)+2))
#self.potential_box_locations_purple.append((4, int(height/2)-2))
#self.potential_box_locations_purple.append((4, int(height/2)-1))
#self.potential_box_locations_purple.append((4, int(height/2)+1))
#self.potential_box_locations_purple.append((4, int(height/2)+2))
self.potential_box_locations_purple.append((6, int(height/2)-2))
self.potential_box_locations_purple.append((6, int(height/2)-1))
self.potential_box_locations_purple.append((6, int(height/2)+1))
self.potential_box_locations_purple.append((6, int(height/2)+2))
self.potential_box_locations_purple.append((8, int(height/2)-2))
self.potential_box_locations_purple.append((8, int(height/2)-1))
self.potential_box_locations_purple.append((8, int(height/2)+1))
self.potential_box_locations_purple.append((8, int(height/2)+2))
# get all possible spawn locations
self.potential_spawn_locations_blue = []
self.potential_spawn_locations_green = []
self.potential_spawn_locations_purple = []
for i in range(1,width-1):
for j in range(1, height-1):
# add a buffer around the agent spawn location
if abs(i - self.agent_start_pos[0]) <= 1 or abs(j - self.agent_start_pos[1]) <= 1:
continue
obj = self.grid.get(i,j)
bg = self.grid.get_background(i, j)
if obj is None:
if bg is None or bg.color == 'lightblue':
self.potential_spawn_locations_blue.append((i,j))
if bg is None or bg.color == 'lightgreen':
self.potential_spawn_locations_green.append((i,j))
self.potential_spawn_locations_purple.append((i,j))
self.red_delivery_station = (2,1)
self.grid.set_background(*self.red_delivery_station,deliveryStationRLTile)
self.blue_delivery_station = (8,1)
self.grid.set_background(*self.blue_delivery_station,deliveryStation1Tile)
self.green_delivery_station = (2,height - 2)
self.grid.set_background(*self.green_delivery_station,deliveryStation2Tile)
self.purple_delivery_station = (8,height - 2)
self.grid.set_background(*self.purple_delivery_station,deliveryStation3Tile)
self.adversaries = {}
if self.use_blue_adversary:
random_start = self.get_viable_location(self.potential_spawn_locations_blue)
self.add_adversary(*random_start, "blue", np.random.randint(low=0, high=4), [DoNothing()])
self.add_blue_box()
if self.use_green_adversary:
random_start = self.get_viable_location(self.potential_spawn_locations_green)
self.add_adversary(*random_start, "green", np.random.randint(low=0, high=4), [DoNothing()])
self.add_green_box()
if self.use_purple_adversary:
random_start = self.get_viable_location(self.potential_spawn_locations_purple)
self.add_adversary(*random_start, "purple", np.random.randint(low=0, high=4), [DoNothing()])
self.add_purple_box()
# learning agent boxes
red_random_box_location1 = self.get_viable_location(self.potential_box_locations_red)
self.grid.set(*red_random_box_location1,Box("red"))
if self.reward_type == 'Dense':
self.learning_agent_manager = TaskManager([
PickUpObject(red_random_box_location1, self.grid.get(*red_random_box_location1)),
PlaceObject((2, 1), self.grid.get(*red_random_box_location1)),
DoNothing()
])
current_objective = self.learning_agent_manager.tasks[0].obj_position
self.bfs_reward = run_BFS_reward(self.grid, current_objective)
# Place the agent
if self.agent_start_pos is not None:
self.agent_pos = self.agent_start_pos
self.agent_dir = self.agent_start_dir
else:
self.place_agent()
self.mission = "Avoid crashing into the other agents."
def add_blue_box(self):
random_box_location1 = self.get_viable_location(self.potential_box_locations_blue)
self.grid.set(*random_box_location1, Box("blue"))
self.adversaries["blue"].task_manager.tasks.insert(0,PickUpObject(random_box_location1, self.grid.get(*random_box_location1)))
self.adversaries["blue"].task_manager.tasks.insert(1, PlaceObject(self.blue_delivery_station, self.grid.get(*random_box_location1)))
def add_green_box(self):
random_box_location1 = self.get_viable_location(self.potential_box_locations_green)
self.grid.set(*random_box_location1, Box("green"))
self.adversaries["green"].task_manager.tasks.insert(0,PickUpObject(random_box_location1, self.grid.get(*random_box_location1)))
self.adversaries["green"].task_manager.tasks.insert(1, PlaceObject(self.green_delivery_station, self.grid.get(*random_box_location1)))
def add_purple_box(self):
random_box_location1 = self.get_viable_location(self.potential_box_locations_purple)
self.grid.set(*random_box_location1, Box("purple"))
self.adversaries["purple"].task_manager.tasks.insert(0,PickUpObject(random_box_location1, self.grid.get(*random_box_location1)))
self.adversaries["purple"].task_manager.tasks.insert(1, PlaceObject(self.purple_delivery_station, self.grid.get(*random_box_location1)))
def add_red_box(self):
#sys.exit("adding additional red boxes, even though this should terminate the episode. \n Remove if multiple boxes should be picked up")
print("WARN: Adding red box after {} steps.".format(self.step_count))
random_box_location1 = self.get_viable_location(self.potential_box_locations_red)
self.grid.set(*random_box_location1, Box("red"))
if self.reward_type == 'Dense':
self.learning_agent_manager.tasks.insert(0, PickUpObject(random_box_location1, self.grid.get(*random_box_location1)))
self.learning_agent_manager.tasks.insert(1, PlaceObject(self.red_delivery_station, self.grid.get(*random_box_location1)))
def step(self, action):
delete_list = list()
for position, box in self.background_boxes.items():
if self.grid.get(*position) is None:
self.grid.set(*position, box)
self.grid.set_background(*position, None)
delete_list.append(tuple(position))
#else:
# print("Cannot remove box at {}, {} from backgroud".format(*position))
for position in delete_list:
#print("Removed box at {}, {} from backgroud".format(*position))
del self.background_boxes[position]
self.reward = 0.0
obs, reward, terminated, truncated, info = super().step(action)
self.violation_deque.appendleft("Agent Movement:\n{}".format(self.printGrid()))
# need to augment this just like the agent, and we can hardcode a policy to follow
for adversary in self.adversaries.values():
blocked_positions = [adv.cur_pos for adv in self.adversaries.values()]
agent_pos = self.agent_pos
advsersary_action = self.get_adversary_action(adversary)
self.move_adversary(adversary, advsersary_action, blocked_positions, agent_pos)
if self.reward_type == 'Dense':
#starting_pos = self.agent_pos
#best_action = self.learning_agent_manager.get_best_action(self.agent_pos, self.dir_vec, self.carrying, self)
#if action == best_action:
# self.reward += 0.1
#else:
# self.reward -= 0.1
self.reward += self.bfs_reward[self.agent_pos[0] + self.grid.width * self.agent_pos[1]]
# get obs from env
#obs, reward, terminated, truncated, info = super().step(action)
# reward function and done function are custom
reward = self.reward
#print("Task[0]: {}".format(self.learning_agent_manager.tasks[0]))
if self.reward_type == 'Dense':
# current_pos = self.agent_pos
# goal_pos = self.learning_agent_manager.tasks[0].obj_position
# starting_distance = abs(starting_pos[0] - goal_pos[0]) + abs(starting_pos[1] - goal_pos[1])
# ending_distance = abs(current_pos[0] - goal_pos[0]) + abs(current_pos[1] - goal_pos[1])
# reward += 0.1 * (starting_distance - ending_distance)
# if self.learning_agent_manager.tasks[0].completed(self.agent_pos, self.dir_vec, self.carrying, self):
# self.learning_agent_manager.tasks.pop(0)
if self.learning_agent_manager.tasks[0].completed(self.agent_pos, self.dir_vec, self.carrying, self):
self.learning_agent_manager.tasks.pop(0)
current_objective = self.learning_agent_manager.tasks[0]
if hasattr(current_objective, 'obj_position'):
self.bfs_reward = run_BFS_reward(self.grid, current_objective.obj_position)
# respawn boxes as needed
maybe_red_box = self.grid.get(*self.red_delivery_station)
if maybe_red_box and isinstance(maybe_red_box, Box) and maybe_red_box.color == 'red':
self.grid.set(*self.red_delivery_station, None)
self.add_red_box()
# respawn green box
if self.use_green_adversary:
maybe_green_box = self.grid.get(*self.green_delivery_station)
if maybe_green_box and isinstance(maybe_green_box, Box) and maybe_green_box.color == 'green':
self.grid.set(*self.green_delivery_station, None)
self.add_green_box()
# respawn blue box
if self.use_blue_adversary:
maybe_blue_box = self.grid.get(*self.blue_delivery_station)
if maybe_blue_box and isinstance(maybe_blue_box, Box) and maybe_blue_box.color == 'blue':
self.grid.set(*self.blue_delivery_station, None)
self.add_blue_box()
# respawn purple box
if self.use_purple_adversary:
maybe_purple_box = self.grid.get(*self.purple_delivery_station)
if maybe_purple_box and isinstance(maybe_purple_box, Box) and maybe_purple_box.color == 'purple':
self.grid.set(*self.purple_delivery_station, None)
self.add_purple_box()
#if terminated:
# print("Terminated true @ {}".format(self.step_count))
return obs, reward, terminated, truncated, info
def seed(self, seed):
np.random.seed(seed)
return seed
def get_adversary_action(self, adversary):
return adversary.task_manager.get_best_action(adversary.cur_pos, adversary.dir_vec(), adversary.carrying, self)
def get_viable_location(self, locs):
tried = list()
locations = deepcopy(locs)
viable = False
counter = 0
while not viable:
if len(locations) == 0:
print("All locations: ", locs)
print("Tried: ", tried)
print(self.printGrid())
sys.exit("No viable locations.")
location = locations[np.random.randint(low=0, high=len(locations))]
tried.append(location)
if self.grid.get(*location) is None and self.agent_pos != location:
viable = True
else:
locations.remove(location)
counter += 1
if counter >= 10:
print(location)
print(locations)
print(self.printGrid())
input("")
return location
# Moves the adversary according to current policy, code copy pasted from minigrid.step
def move_adversary(self, adversary, action, blocked_positions, agent_pos):
# fetch current location and forward location
cur_pos = adversary.cur_pos
current_cell = self.grid.get(*adversary.cur_pos)
fwd_pos = cur_pos + adversary.dir_vec()
fwd_cell = self.grid.get(*fwd_pos)
if action == self.actions.left:
adversary.adversary_dir -= 1
if adversary.adversary_dir < 0:
adversary.adversary_dir += 4
# Rotate right
elif action == self.actions.right:
adversary.adversary_dir = (adversary.adversary_dir + 1) % 4
# Move forward
elif action == self.actions.forward and isinstance(current_cell, SlipperyNorth):
print("TODO: actual slippery obs, for now: Teleporting the agent")
# TODO also what if blocked, see below
adversary.cur_pos = (3, 3)
elif action == self.actions.forward and not isinstance(current_cell, SlipperyNorth):
if tuple(fwd_pos) == agent_pos:
self.reward -= self.collision_penalty
self.safety_violations_this_episode += 1
#print("Safety Violation @ {},{}, by adversary".format(*fwd_pos))
#for g in self.violation_deque:
# print(g)
#input("Hit Enter.")
self.violation_deque.clear()
elif (fwd_cell is None or fwd_cell.can_overlap()) and not tuple(fwd_pos) in blocked_positions:
if isinstance(fwd_cell, Box):
self.grid.set_background(*fwd_pos,fwd_cell)
self.background_boxes[tuple(fwd_pos)] = fwd_cell # np.array is not hashable
adversary.cur_pos = tuple(fwd_pos)
# Pick up an object
elif action == self.actions.pickup:
if fwd_cell and fwd_cell.can_pickup():
if adversary.carrying is None:
adversary.carrying = fwd_cell
adversary.carrying.cur_pos = np.array([-1, -1])
self.grid.set(fwd_pos[0], fwd_pos[1], None)
# Drop an object
elif action == self.actions.drop:
if not fwd_cell and adversary.carrying:
self.grid.set(fwd_pos[0], fwd_pos[1], adversary.carrying)
adversary.carrying.cur_pos = fwd_pos
adversary.carrying = None
# Toggle/activate an object
elif action == self.actions.toggle:
if fwd_cell:
fwd_cell.toggle(self, fwd_pos)
# Done action (not used by default)
elif action == self.actions.done:
pass
else:
raise ValueError(f"Unknown action: {action}")
# finally update the env with these changes
self.grid.set(*cur_pos, None)
self.grid.set(*adversary.cur_pos, adversary)
self.violation_deque.appendleft("{} Movement:\n{}".format(adversary.color, self.printGrid()))
def get_adversaries(self):
return [adversary.color for adversary in self.adversaries.values()]
def get_property_map(self, epoch_string):
return { "blue" : ("SafetyAGBlue", 'concat(<_, PreSafety, gamma={}> <<Blue>> Pmax=? [ G !"BlueOnGreen" ], <'.format(self.shield_gamma) + epoch_string + 'SafetyAGBlue, PreSafety, gamma={}> <<Agent>> Pmax=? [G<{} !"crash" ] );'.format(self.shield_gamma, self.shield_horizon)),
"green": ("SafetyAGGreen", 'concat(<_, PreSafety, gamma={}> <<Green>> Pmax=? [ G !"GreenOnBlue" ], <'.format(self.shield_gamma) + epoch_string + 'SafetyAGGreen, PreSafety, gamma={}> <<Agent>> Pmax=? [G<{} !"crash" ] );'.format(self.shield_gamma, self.shield_horizon)),
"purple": ("SafetyAGPurple", 'concat(<_, PreSafety, gamma={}> <<Purple>> Pmax=? [ G !"PurpleOnBlue" ], <'.format(self.shield_gamma) + epoch_string + 'SafetyAGPurple, PreSafety, gamma={}> <<Agent>> Pmax=? [G<{} !"crash" ] );'.format(self.shield_gamma, self.shield_horizon))
}
def get_shield_info(self):
adversary_info = {color : ((adv.cur_pos[1], adv.cur_pos[0]), adv.adversary_dir) for (color,adv) in self.adversaries.items()}
return self.agent_pos, self.agent_dir, adversary_info

103
gym_minigrid/gym_minigrid/envs/blockedunlockpickup.py

@ -0,0 +1,103 @@
from gym_minigrid.minigrid import COLOR_NAMES, Ball, MissionSpace
from gym_minigrid.roomgrid import RoomGrid
class BlockedUnlockPickupEnv(RoomGrid):
"""
### Description
The agent has to pick up a box which is placed in another room, behind a
locked door. The door is also blocked by a ball which the agent has to move
before it can unlock the door. Hence, the agent has to learn to move the
ball, pick up the key, open the door and pick up the object in the other
room. This environment can be solved without relying on language.
### Mission Space
"pick up the {color} {type}"
{color} is the color of the box. Can be "red", "green", "blue", "purple",
"yellow" or "grey".
{type} is the type of the object. Can be "box" or "key".
### Action Space
| Num | Name | Action |
|-----|--------------|-------------------|
| 0 | left | Turn left |
| 1 | right | Turn right |
| 2 | forward | Move forward |
| 3 | pickup | Pick up an object |
| 4 | drop | Unused |
| 5 | toggle | Unused |
| 6 | done | Unused |
### Observation Encoding
- Each tile is encoded as a 3 dimensional tuple:
`(OBJECT_IDX, COLOR_IDX, STATE)`
- `OBJECT_TO_IDX` and `COLOR_TO_IDX` mapping can be found in
[gym_minigrid/minigrid.py](gym_minigrid/minigrid.py)
- `STATE` refers to the door state with 0=open, 1=closed and 2=locked
### Rewards
A reward of '1' is given for success, and '0' for failure.
### Termination
The episode ends if any one of the following conditions is met:
1. The agent picks up the correct box.
2. Timeout (see `max_steps`).
### Registered Configurations
- `MiniGrid-BlockedUnlockPickup-v0`
"""
def __init__(self, **kwargs):
room_size = 6
mission_space = MissionSpace(
mission_func=lambda color, type: f"pick up the {color} {type}",
ordered_placeholders=[COLOR_NAMES, ["box", "key"]],
)
super().__init__(
mission_space=mission_space,
num_rows=1,
num_cols=2,
room_size=room_size,
max_steps=16 * room_size**2,
**kwargs,
)
def _gen_grid(self, width, height):
super()._gen_grid(width, height)
# Add a box to the room on the right
obj, _ = self.add_object(1, 0, kind="box")
# Make sure the two rooms are directly connected by a locked door
door, pos = self.add_door(0, 0, 0, locked=True)
# Block the door with a ball
color = self._rand_color()
self.grid.set(pos[0] - 1, pos[1], Ball(color))
# Add a key to unlock the door
self.add_object(0, 0, "key", door.color)
self.place_agent(0, 0)
self.obj = obj
self.mission = f"pick up the {obj.color} {obj.type}"
def step(self, action):
obs, reward, terminated, truncated, info = super().step(action)
if action == self.actions.pickup:
if self.carrying and self.carrying == self.obj:
reward = self._reward()
terminated = True
return obs, reward, terminated, truncated, info

76
gym_minigrid/gym_minigrid/envs/cliffWalking.py

@ -0,0 +1,76 @@
from gym_minigrid.minigrid import Goal, Grid, MiniGridEnv, MissionSpace, SlipperyNorth, SlipperySouth, SlipperyEast, SlipperyWest, Wall, HeatMapTile, Lava
from gym_minigrid.policyRepairEnv import PolicyRepairEnv
from gym_minigrid.minigrid import run_BFS_reward
class CliffWalking(PolicyRepairEnv):
def __init__(self, size=8, nr_cliffs=1, agent_start_pos=(1, 4), agent_start_dir=0, **kwargs):
self.nr_cliffs = nr_cliffs
super().__init__(
size=size,
agent_start_pos=agent_start_pos,
agent_start_dir=agent_start_dir,
**kwargs
)
def _gen_grid(self, width, height):
# Create an empty grid
self.grid = Grid(width, height)
# Generate the surrounding walls
self.grid.wall_rect(0, 0, width, height)
self.grid.horz_wall(1,7)
#north cliffs
lava_pos = [4, 8, 13, 17, 22]
for i in range(self.nr_cliffs):
self.put_obj(Lava(), lava_pos[i], 1)
self.put_obj(SlipperySouth(), lava_pos[i], 2)
self.put_obj(SlipperySouth(), lava_pos[i]+1, 2)
self.put_obj(SlipperySouth(), lava_pos[i]-1, 2)
self.put_obj(SlipperyEast(), lava_pos[i]+1, 1)
self.put_obj(SlipperyWest(), lava_pos[i]-1, 1)
#nsouth cliffs
lava_pos = [3, 8, 12, 17, 21]
for i in range(self.nr_cliffs):
self.put_obj(Lava(), lava_pos[i], 6)
self.put_obj(SlipperyNorth(), lava_pos[i], 5)
self.put_obj(SlipperyNorth(), lava_pos[i]+1, 5)
self.put_obj(SlipperyNorth(), lava_pos[i]-1, 5)
self.put_obj(SlipperyEast(), lava_pos[i]+1, 6)
self.put_obj(SlipperyWest(), lava_pos[i]-1, 6)
goalPos = (width-2, 3)
self.put_obj(Goal(), *goalPos)
# Place the agent
if not self.agent_pos or (self.agent_pos[0] == -1 and self.agent_pos[1] == -1 and self.agent_dir == -1):
self.agent_pos = self.agent_start_pos
self.agent_dir = self.agent_start_dir
self.bfs_reward = run_BFS_reward(self.grid, goalPos)
self.mission = "get to the green goal square"
def step(self, action):
# Get the position in front of the agent
fwd_pos = self.front_pos
# Get the contents of the cell in front of the agent
fwd_cell = self.grid.get(*fwd_pos)
obs, reward, terminated, truncated, info = super().step(action)
#bfs reward
#reward = self.bfs_reward[self.agent_pos[0] + self.grid.width * self.agent_pos[1]]
#negative reward for stepping in lava, positive reward for reaching goal
if action == self.actions.forward:
if fwd_cell is not None and fwd_cell.type == "goal":
reward += 100
elif fwd_cell is not None and fwd_cell.type == "lava":
reward -=100
if self.render_mode == "human":
print("step: {}, reward: {}, info: {}\t\t\tthat terminated: {}".format(self.total_timesteps, reward, info, terminated or truncated))
return obs, reward, terminated, truncated, info

65
gym_minigrid/gym_minigrid/envs/columnsMini.py

@ -0,0 +1,65 @@
from gym_minigrid.minigrid import Goal, Grid, MiniGridEnv, MissionSpace, SlipperyNorth, Wall, HeatMapTile, Lava
from gym_minigrid.policyRepairEnv import PolicyRepairEnv
from gym_minigrid.minigrid import run_BFS_reward
class ColumnsMini(PolicyRepairEnv):
def __init__(self, size=9, agent_start_pos=(1, 1), agent_start_dir=0, **kwargs):
super().__init__(
size=size,
agent_start_pos=agent_start_pos,
agent_start_dir=agent_start_dir,
**kwargs
)
def _gen_grid(self, width, height):
# Create an empty grid
self.grid = Grid(width, height)
# Generate the surrounding walls
self.grid.wall_rect(0, 0, width, height)
# Place a goal square in the bottom-right corner
#self.put_obj(Slippery(), 4, 1)
for x in range(1,4):
for y in range(2,8):
self.put_obj(SlipperyNorth(), x, y)
self.put_obj(Lava(), 1, 3)
self.put_obj(Lava(), 1, 4)
self.put_obj(Lava(), 1, 5)
self.grid.wall_rect(4, 2, 2, 4)
goalPos = (6, height - 2)
self.put_obj(Goal(), *goalPos)
# Place the agent
if not self.agent_pos or (self.agent_pos[0] == -1 and self.agent_pos[1] == -1 and self.agent_dir == -1):
self.agent_pos = self.agent_start_pos
self.agent_dir = self.agent_start_dir
self.bfs_reward = run_BFS_reward(self.grid, goalPos)
self.mission = "get to the green goal square"
def step(self, action):
# Get the position in front of the agent
fwd_pos = self.front_pos
# Get the contents of the cell in front of the agent
fwd_cell = self.grid.get(*fwd_pos)
obs, reward, terminated, truncated, info = super().step(action)
#bfs reward
#reward = self.bfs_reward[self.agent_pos[0] + self.grid.width * self.agent_pos[1]]
#negative reward for stepping in lava, positive reward for reaching goal
if action == self.actions.forward:
if fwd_cell is not None and fwd_cell.type == "goal":
reward += 100
elif fwd_cell is not None and fwd_cell.type == "lava":
reward -=100
if self.render_mode == "human":
print("step: {}, reward: {}, info: {}\t\t\tthat terminated: {}".format(self.total_timesteps, reward, info, terminated or truncated))
return obs, reward, terminated, truncated, info

166
gym_minigrid/gym_minigrid/envs/crossing.py

@ -0,0 +1,166 @@
import itertools as itt
import numpy as np
from gym_minigrid.minigrid import Goal, Grid, Lava, MiniGridEnv, MissionSpace
class CrossingEnv(MiniGridEnv):
"""
### Description
Depending on the `obstacle_type` parameter:
- `Lava` - The agent has to reach the green goal square on the other corner
of the room while avoiding rivers of deadly lava which terminate the
episode in failure. Each lava stream runs across the room either
horizontally or vertically, and has a single crossing point which can be
safely used; Luckily, a path to the goal is guaranteed to exist. This
environment is useful for studying safety and safe exploration.
- otherwise - Similar to the `LavaCrossing` environment, the agent has to
reach the green goal square on the other corner of the room, however
lava is replaced by walls. This MDP is therefore much easier and maybe
useful for quickly testing your algorithms.
### Mission Space
Depending on the `obstacle_type` parameter:
- `Lava` - "avoid the lava and get to the green goal square"
- otherwise - "find the opening and get to the green goal square"
### Action Space
| Num | Name | Action |
|-----|--------------|--------------|
| 0 | left | Turn left |
| 1 | right | Turn right |
| 2 | forward | Move forward |
| 3 | pickup | Unused |
| 4 | drop | Unused |
| 5 | toggle | Unused |
| 6 | done | Unused |
### Observation Encoding
- Each tile is encoded as a 3 dimensional tuple:
`(OBJECT_IDX, COLOR_IDX, STATE)`
- `OBJECT_TO_IDX` and `COLOR_TO_IDX` mapping can be found in
[gym_minigrid/minigrid.py](gym_minigrid/minigrid.py)
- `STATE` refers to the door state with 0=open, 1=closed and 2=locked
### Rewards
A reward of '1' is given for success, and '0' for failure.
### Termination
The episode ends if any one of the following conditions is met:
1. The agent reaches the goal.
2. The agent falls into lava.
3. Timeout (see `max_steps`).
### Registered Configurations
S: size of the map SxS.
N: number of valid crossings across lava or walls from the starting position
to the goal
- `Lava` :
- `MiniGrid-LavaCrossingS9N1-v0`
- `MiniGrid-LavaCrossingS9N2-v0`
- `MiniGrid-LavaCrossingS9N3-v0`
- `MiniGrid-LavaCrossingS11N5-v0`
- otherwise :
- `MiniGrid-SimpleCrossingS9N1-v0`
- `MiniGrid-SimpleCrossingS9N2-v0`
- `MiniGrid-SimpleCrossingS9N3-v0`
- `MiniGrid-SimpleCrossingS11N5-v0`
"""
def __init__(self, size=9, num_crossings=1, obstacle_type=Lava, **kwargs):
self.num_crossings = num_crossings
self.obstacle_type = obstacle_type
if obstacle_type == Lava:
mission_space = MissionSpace(
mission_func=lambda: "avoid the lava and get to the green goal square"
)
else:
mission_space = MissionSpace(
mission_func=lambda: "find the opening and get to the green goal square"
)
super().__init__(
mission_space=mission_space,
grid_size=size,
max_steps=4 * size * size,
# Set this to True for maximum speed
see_through_walls=False,
**kwargs
)
def _gen_grid(self, width, height):
assert width % 2 == 1 and height % 2 == 1 # odd size
# Create an empty grid
self.grid = Grid(width, height)
# Generate the surrounding walls
self.grid.wall_rect(0, 0, width, height)
# Place the agent in the top-left corner
self.agent_pos = np.array((1, 1))
self.agent_dir = 0
# Place a goal square in the bottom-right corner
self.put_obj(Goal(), width - 2, height - 2)
# Place obstacles (lava or walls)
v, h = object(), object() # singleton `vertical` and `horizontal` objects
# Lava rivers or walls specified by direction and position in grid
rivers = [(v, i) for i in range(2, height - 2, 2)]
rivers += [(h, j) for j in range(2, width - 2, 2)]
self.np_random.shuffle(rivers)
rivers = rivers[: self.num_crossings] # sample random rivers
rivers_v = sorted(pos for direction, pos in rivers if direction is v)
rivers_h = sorted(pos for direction, pos in rivers if direction is h)
obstacle_pos = itt.chain(
itt.product(range(1, width - 1), rivers_h),
itt.product(rivers_v, range(1, height - 1)),
)
for i, j in obstacle_pos:
self.put_obj(self.obstacle_type(), i, j)
# Sample path to goal
path = [h] * len(rivers_v) + [v] * len(rivers_h)
self.np_random.shuffle(path)
# Create openings
limits_v = [0] + rivers_v + [height - 1]
limits_h = [0] + rivers_h + [width - 1]
room_i, room_j = 0, 0
for direction in path:
if direction is h:
i = limits_v[room_i + 1]
j = self.np_random.choice(
range(limits_h[room_j] + 1, limits_h[room_j + 1])
)
room_i += 1
elif direction is v:
i = self.np_random.choice(
range(limits_v[room_i] + 1, limits_v[room_i + 1])
)
j = limits_h[room_j + 1]
room_j += 1
else:
assert False
self.grid.set(i, j, None)
self.mission = (
"avoid the lava and get to the green goal square"
if self.obstacle_type == Lava
else "find the opening and get to the green goal square"
)

110
gym_minigrid/gym_minigrid/envs/distshift.py

@ -0,0 +1,110 @@
from gym_minigrid.minigrid import Goal, Grid, Lava, MiniGridEnv, MissionSpace
class DistShiftEnv(MiniGridEnv):
"""
### Description
This environment is based on one of the DeepMind [AI safety gridworlds]
(https://github.com/deepmind/ai-safety-gridworlds). The agent starts in the
top-left corner and must reach the goal which is in the top-right corner,
but has to avoid stepping into lava on its way. The aim of this environment
is to test an agent's ability to generalize. There are two slightly
different variants of the environment, so that the agent can be trained on
one variant and tested on the other.
### Mission Space
"get to the green goal square"
### Action Space
| Num | Name | Action |
|-----|--------------|--------------|
| 0 | left | Turn left |
| 1 | right | Turn right |
| 2 | forward | Move forward |
| 3 | pickup | Unused |
| 4 | drop | Unused |
| 5 | toggle | Unused |
| 6 | done | Unused |
### Observation Encoding
- Each tile is encoded as a 3 dimensional tuple:
`(OBJECT_IDX, COLOR_IDX, STATE)`
- `OBJECT_TO_IDX` and `COLOR_TO_IDX` mapping can be found in
[gym_minigrid/minigrid.py](gym_minigrid/minigrid.py)
- `STATE` refers to the door state with 0=open, 1=closed and 2=locked
### Rewards
A reward of '1' is given for success, and '0' for failure.
### Termination
The episode ends if any one of the following conditions is met:
1. The agent reaches the goal.
2. The agent falls into lava.
3. Timeout (see `max_steps`).
### Registered Configurations
- `MiniGrid-DistShift1-v0`
- `MiniGrid-DistShift2-v0`
"""
def __init__(
self,
width=9,
height=7,
agent_start_pos=(1, 1),
agent_start_dir=0,
strip2_row=2,
**kwargs
):
self.agent_start_pos = agent_start_pos
self.agent_start_dir = agent_start_dir
self.goal_pos = (width - 2, 1)
self.strip2_row = strip2_row
mission_space = MissionSpace(
mission_func=lambda: "get to the green goal square"
)
super().__init__(
mission_space=mission_space,
width=width,
height=height,
max_steps=4 * width * height,
# Set this to True for maximum speed
see_through_walls=True,
**kwargs
)
def _gen_grid(self, width, height):
# Create an empty grid
self.grid = Grid(width, height)
# Generate the surrounding walls
self.grid.wall_rect(0, 0, width, height)
# Place a goal square in the bottom-right corner
self.put_obj(Goal(), *self.goal_pos)
# Place the lava rows
for i in range(self.width - 6):
self.grid.set(3 + i, 1, Lava())
self.grid.set(3 + i, self.strip2_row, Lava())
# Place the agent
if self.agent_start_pos is not None:
self.agent_pos = self.agent_start_pos
self.agent_dir = self.agent_start_dir
else:
self.place_agent()
self.mission = "get to the green goal square"

91
gym_minigrid/gym_minigrid/envs/doorkey.py

@ -0,0 +1,91 @@
from gym_minigrid.minigrid import Door, Goal, Grid, Key, MiniGridEnv, MissionSpace
class DoorKeyEnv(MiniGridEnv):
"""
### Description
This environment has a key that the agent must pick up in order to unlock a
goal and then get to the green goal square. This environment is difficult,
because of the sparse reward, to solve using classical RL algorithms. It is
useful to experiment with curiosity or curriculum learning.
### Mission Space
"use the key to open the door and then get to the goal"
### Action Space
| Num | Name | Action |
|-----|--------------|---------------------------|
| 0 | left | Turn left |
| 1 | right | Turn right |
| 2 | forward | Move forward |
| 3 | pickup | Pick up an object |
| 4 | drop | Unused |
| 5 | toggle | Toggle/activate an object |
| 6 | done | Unused |
### Observation Encoding
- Each tile is encoded as a 3 dimensional tuple:
`(OBJECT_IDX, COLOR_IDX, STATE)`
- `OBJECT_TO_IDX` and `COLOR_TO_IDX` mapping can be found in
[gym_minigrid/minigrid.py](gym_minigrid/minigrid.py)
- `STATE` refers to the door state with 0=open, 1=closed and 2=locked
### Rewards
A reward of '1' is given for success, and '0' for failure.
### Termination
The episode ends if any one of the following conditions is met:
1. The agent reaches the goal.
2. Timeout (see `max_steps`).
### Registered Configurations
- `MiniGrid-DoorKey-5x5-v0`
- `MiniGrid-DoorKey-6x6-v0`
- `MiniGrid-DoorKey-8x8-v0`
- `MiniGrid-DoorKey-16x16-v0`
"""
def __init__(self, size=8, **kwargs):
if "max_steps" not in kwargs:
kwargs["max_steps"] = 10 * size * size
mission_space = MissionSpace(
mission_func=lambda: "use the key to open the door and then get to the goal"
)
super().__init__(mission_space=mission_space, grid_size=size, **kwargs)
def _gen_grid(self, width, height):
# Create an empty grid
self.grid = Grid(width, height)
# Generate the surrounding walls
self.grid.wall_rect(0, 0, width, height)
# Place a goal in the bottom-right corner
self.put_obj(Goal(), width - 2, height - 2)
# Create a vertical splitting wall
splitIdx = self._rand_int(2, width - 2)
self.grid.vert_wall(splitIdx, 0)
# Place the agent at a random position and orientation
# on the left side of the splitting wall
self.place_agent(size=(splitIdx, height))
# Place a door in the wall
doorIdx = self._rand_int(1, width - 2)
self.put_obj(Door("yellow", is_locked=True), splitIdx, doorIdx)
# Place a yellow key on the left side
self.place_obj(obj=Key("yellow"), top=(0, 0), size=(splitIdx, height))
self.mission = "use the key to open the door and then get to the goal"

151
gym_minigrid/gym_minigrid/envs/dynamicobstacles.py

@ -0,0 +1,151 @@
from operator import add
from gym.spaces import Discrete
from gym_minigrid.minigrid import Ball, Goal, Grid, MiniGridEnv, MissionSpace
class DynamicObstaclesEnv(MiniGridEnv):
"""
### Description
This environment is an empty room with moving obstacles.
The goal of the agent is to reach the green goal square without colliding
with any obstacle. A large penalty is subtracted if the agent collides with
an obstacle and the episode finishes. This environment is useful to test
Dynamic Obstacle Avoidance for mobile robots with Reinforcement Learning in
Partial Observability.
### Mission Space
"get to the green goal square"
### Action Space
| Num | Name | Action |
|-----|--------------|--------------|
| 0 | left | Turn left |
| 1 | right | Turn right |
| 2 | forward | Move forward |
| 3 | pickup | Unused |
| 4 | drop | Unused |
| 5 | toggle | Unused |
| 6 | done | Unused |
### Observation Encoding
- Each tile is encoded as a 3 dimensional tuple:
`(OBJECT_IDX, COLOR_IDX, STATE)`
- `OBJECT_TO_IDX` and `COLOR_TO_IDX` mapping can be found in
[gym_minigrid/minigrid.py](gym_minigrid/minigrid.py)
- `STATE` refers to the door state with 0=open, 1=closed and 2=locked
### Rewards
A reward of '1' is given for success, and '0' for failure. A '-1' penalty is
subtracted if the agent collides with an obstacle.
### Termination
The episode ends if any one of the following conditions is met:
1. The agent reaches the goal.
2. The agent collides with an obstacle.
3. Timeout (see `max_steps`).
### Registered Configurations
- `MiniGrid-Dynamic-Obstacles-5x5-v0`
- `MiniGrid-Dynamic-Obstacles-Random-5x5-v0`
- `MiniGrid-Dynamic-Obstacles-6x6-v0`
- `MiniGrid-Dynamic-Obstacles-Random-6x6-v0`
- `MiniGrid-Dynamic-Obstacles-8x8-v0`
- `MiniGrid-Dynamic-Obstacles-16x16-v0`
"""
def __init__(
self, size=8, agent_start_pos=(1, 1), agent_start_dir=0, n_obstacles=4, **kwargs
):
self.agent_start_pos = agent_start_pos
self.agent_start_dir = agent_start_dir
# Reduce obstacles if there are too many
if n_obstacles <= size / 2 + 1:
self.n_obstacles = int(n_obstacles)
else:
self.n_obstacles = int(size / 2)
mission_space = MissionSpace(
mission_func=lambda: "get to the green goal square"
)
super().__init__(
mission_space=mission_space,
grid_size=size,
max_steps=4 * size * size,
# Set this to True for maximum speed
see_through_walls=True,
**kwargs
)
# Allow only 3 actions permitted: left, right, forward
self.action_space = Discrete(self.actions.forward + 1)
self.reward_range = (-1, 1)
def _gen_grid(self, width, height):
# Create an empty grid
self.grid = Grid(width, height)
# Generate the surrounding walls
self.grid.wall_rect(0, 0, width, height)
# Place a goal square in the bottom-right corner
self.grid.set(width - 2, height - 2, Goal())
# Place the agent
if self.agent_start_pos is not None:
self.agent_pos = self.agent_start_pos
self.agent_dir = self.agent_start_dir
else:
self.place_agent()
# Place obstacles
self.obstacles = []
for i_obst in range(self.n_obstacles):
self.obstacles.append(Ball())
self.place_obj(self.obstacles[i_obst], max_tries=100)
self.mission = "get to the green goal square"
def step(self, action):
# Invalid action
if action >= self.action_space.n:
action = 0
# Check if there is an obstacle in front of the agent
front_cell = self.grid.get(*self.front_pos)
not_clear = front_cell and front_cell.type != "goal"
# Update obstacle positions
for i_obst in range(len(self.obstacles)):
old_pos = self.obstacles[i_obst].cur_pos
top = tuple(map(add, old_pos, (-1, -1)))
try:
self.place_obj(
self.obstacles[i_obst], top=top, size=(3, 3), max_tries=100
)
self.grid.set(old_pos[0], old_pos[1], None)
except Exception:
pass
# Update the agent's position/direction
obs, reward, terminated, truncated, info = super().step(action)
# If the agent tried to walk over an obstacle or wall
if action == self.actions.forward and not_clear:
reward = -1
terminated = True
return obs, reward, terminated, truncated, info
return obs, reward, terminated, truncated, info

98
gym_minigrid/gym_minigrid/envs/empty.py

@ -0,0 +1,98 @@
from gym_minigrid.minigrid import Goal, Grid, MiniGridEnv, MissionSpace, Lava
from gym_minigrid.minigrid import run_BFS_reward
class EmptyEnv(MiniGridEnv):
"""
### Registered Configurations
- `MiniGrid-Empty-5x5-v0`
- `MiniGrid-Empty-Random-5x5-v0`
- `MiniGrid-Empty-6x6-v0`
- `MiniGrid-Empty-Random-6x6-v0`
- `MiniGrid-Empty-8x8-v0`
- `MiniGrid-Empty-16x16-v0`
"""
def __init__(self, size=8, agent_start_pos=(1, 1), agent_start_dir=0, **kwargs):
self.agent_start_pos = agent_start_pos
self.agent_start_dir = agent_start_dir
mission_space = MissionSpace(
mission_func=lambda: "get to the green goal square"
)
super().__init__(
mission_space=mission_space,
grid_size=size,
max_steps=4 * size * size,
# Set this to True for maximum speed
see_through_walls=True,
**kwargs
)
def _gen_grid(self, width, height):
# Create an empty grid
self.grid = Grid(width, height)
# Generate the surrounding walls
self.grid.wall_rect(0, 0, width, height)
# Place a goal square in the bottom-right corner
self.put_obj(Goal(), width - 2, height - 2)
self.put_obj(Lava(), 3, 2)
self.put_obj(Lava(), 4, 2)
self.put_obj(Lava(), 5, 2)
self.put_obj(Lava(), 9, 3)
self.put_obj(Lava(), 5, 4)
self.put_obj(Lava(), 6, 4)
self.put_obj(Lava(), 7, 6)
self.put_obj(Lava(), 8, 6)
self.put_obj(Lava(), 2, 6)
self.put_obj(Lava(), 3, 6)
self.put_obj(Lava(), 4, 6)
self.put_obj(Lava(), 6, 8)
self.put_obj(Lava(), 7, 8)
self.put_obj(Lava(), 1, 9)
self.put_obj(Lava(), 2, 9)
self.put_obj(Lava(), 3, 9)
#self.put_obj(Lava(), 3, 6)
# Place the agent
if self.agent_start_pos is not None:
self.agent_pos = self.agent_start_pos
self.agent_dir = self.agent_start_dir
else:
self.place_agent()
self.bfs_reward = run_BFS_reward(self.grid, (width - 2, height - 2))
self.mission = "get to the green goal square"
def step(self, action):
# Get the position in front of the agent
fwd_pos = self.front_pos
# Get the contents of the cell in front of the agent
fwd_cell = self.grid.get(*fwd_pos)
obs, reward, terminated, truncated, info = super().step(action)
#if fwd_pos[0] == 4 and fwd_pos[1] == 3 and action == self.actions.forward:
# reward += 10
#bfs reward
reward += 1 * self.bfs_reward[self.agent_pos[0] + self.grid.width * self.agent_pos[1]]
#negative reward for stepping in lava, positive reward for reaching goal
if action == self.actions.forward:
if fwd_cell is not None and fwd_cell.type == "goal":
reward += 100
elif fwd_cell is not None and fwd_cell.type == "lava":
reward += -10
if self.render_mode == "human":
print("{}, rew: {}, info: {}\tterminated: {}".format(self.total_timesteps, reward, info, terminated or truncated))
return obs, reward, terminated, truncated, info

83
gym_minigrid/gym_minigrid/envs/experimentSlippery.py

@ -0,0 +1,83 @@
from gym_minigrid.minigrid import Goal, Grid, MiniGridEnv, MissionSpace, SlipperyNorth, Wall, HeatMapTile, Lava
from gym_minigrid.policyRepairEnv import PolicyRepairEnv
from gym_minigrid.minigrid import run_BFS_reward
class ExperimentSlippery(PolicyRepairEnv):
def __init__(self, size=11, agent_start_pos=(1, 1), agent_start_dir=0, **kwargs):
super().__init__(
size=size,
agent_start_pos=agent_start_pos,
agent_start_dir=agent_start_dir,
**kwargs
)
def _gen_grid(self, width, height):
# Create an empty grid
self.grid = Grid(width, height)
# Generate the surrounding walls
self.grid.wall_rect(0, 0, width, height)
# Generate the surrounding walls
self.grid.wall_rect(0, 0, width, height)
# Place a goal square in the bottom-right corner
self.put_obj(Goal(), width - 2, height - 2)
#Walls in the middle
for i in range(3,8):
self.put_obj(Wall(),3,i)
self.put_obj(Wall(),4,i)
self.put_obj(Wall(),5,i)
self.put_obj(Wall(),6,i)
self.put_obj(Wall(),7,i)
# Lava north/left
self.put_obj(Lava(), 4, 8)
self.put_obj(Lava(), 5, 8)
self.put_obj(Lava(), 6, 8)
self.put_obj(Lava(), 8, 4)
self.put_obj(Lava(), 8, 5)
self.put_obj(Lava(), 8, 6)
#Slippery Tiles north
self.put_obj(SlipperyNorth(), 3, 8)
self.put_obj(SlipperyNorth(), 7, 8)
self.put_obj(SlipperyNorth(), 3, 9)
self.put_obj(SlipperyNorth(), 4, 9)
self.put_obj(SlipperyNorth(), 5, 9)
self.put_obj(SlipperyNorth(), 6, 9)
self.put_obj(SlipperyNorth(), 7, 9)
self.put_obj(SlipperyNorth(), 7, 8)
# Place the agent
if not self.agent_pos or (self.agent_pos[0] == -1 and self.agent_pos[1] == -1 and self.agent_dir == -1):
self.agent_pos = self.agent_start_pos
self.agent_dir = self.agent_start_dir
self.bfs_reward = run_BFS_reward(self.grid, (width - 2, height - 2))
self.mission = "get to the green goal square"
def step(self, action):
# Get the position in front of the agent
fwd_pos = self.front_pos
# Get the contents of the cell in front of the agent
fwd_cell = self.grid.get(*fwd_pos)
obs, reward, terminated, truncated, info = super().step(action)
#bfs reward
reward = self.bfs_reward[self.agent_pos[0] + self.grid.width * self.agent_pos[1]]
#negative reward for stepping in lava, positive reward for reaching goal
if action == self.actions.forward:
if fwd_cell is not None and fwd_cell.type == "goal":
reward += 100
elif fwd_cell is not None and fwd_cell.type == "lava":
reward -=100
if self.render_mode == "human":
print("step: {}, reward: {}, info: {}\t\t\tthat terminated: {}".format(self.total_timesteps, reward, info, terminated or truncated))
return obs, reward, terminated, truncated, info

169
gym_minigrid/gym_minigrid/envs/fetch.py

@ -0,0 +1,169 @@
from gym_minigrid.minigrid import (
COLOR_NAMES,
Ball,
Grid,
Key,
MiniGridEnv,
MissionSpace,
)
class FetchEnv(MiniGridEnv):
"""
### Description
This environment has multiple objects of assorted types and colors. The
agent receives a textual string as part of its observation telling it which
object to pick up. Picking up the wrong object terminates the episode with
zero reward.
### Mission Space
"{syntax} {color} {type}"
{syntax} is one of the following: "get a", "go get a", "fetch a",
"go fetch a", "you must fetch a".
{color} is the color of the box. Can be "red", "green", "blue", "purple",
"yellow" or "grey".
{type} is the type of the object. Can be "key" or "ball".
### Action Space
| Num | Name | Action |
|-----|--------------|----------------------|
| 0 | left | Turn left |
| 1 | right | Turn right |
| 2 | forward | Move forward |
| 3 | pickup | Pick up an object |
| 4 | drop | Unused |
| 5 | toggle | Unused |
| 6 | done | Unused |
### Observation Encoding
- Each tile is encoded as a 3 dimensional tuple:
`(OBJECT_IDX, COLOR_IDX, STATE)`
- `OBJECT_TO_IDX` and `COLOR_TO_IDX` mapping can be found in
[gym_minigrid/minigrid.py](gym_minigrid/minigrid.py)
- `STATE` refers to the door state with 0=open, 1=closed and 2=locked
### Rewards
A reward of '1' is given for success, and '0' for failure.
### Termination
The episode ends if any one of the following conditions is met:
1. The agent picks up the correct object.
2. The agent picks up the wrong object.
2. Timeout (see `max_steps`).
### Registered Configurations
N: number of objects to be generated.
- `MiniGrid-Fetch-5x5-N2-v0`
- `MiniGrid-Fetch-6x6-N2-v0`
- `MiniGrid-Fetch-8x8-N3-v0`
"""
def __init__(self, size=8, numObjs=3, **kwargs):
self.numObjs = numObjs
self.obj_types = ["key", "ball"]
MISSION_SYNTAX = [
"get a",
"go get a",
"fetch a",
"go fetch a",
"you must fetch a",
]
self.size = size
mission_space = MissionSpace(
mission_func=lambda syntax, color, type: f"{syntax} {color} {type}",
ordered_placeholders=[MISSION_SYNTAX, COLOR_NAMES, self.obj_types],
)
super().__init__(
mission_space=mission_space,
width=size,
height=size,
max_steps=5 * size**2,
# Set this to True for maximum speed
see_through_walls=True,
**kwargs,
)
def _gen_grid(self, width, height):
self.grid = Grid(width, height)
# Generate the surrounding walls
self.grid.horz_wall(0, 0)
self.grid.horz_wall(0, height - 1)
self.grid.vert_wall(0, 0)
self.grid.vert_wall(width - 1, 0)
objs = []
# For each object to be generated
while len(objs) < self.numObjs:
objType = self._rand_elem(self.obj_types)
objColor = self._rand_elem(COLOR_NAMES)
if objType == "key":
obj = Key(objColor)
elif objType == "ball":
obj = Ball(objColor)
else:
raise ValueError(
"{} object type given. Object type can only be of values key and ball.".format(
objType
)
)
self.place_obj(obj)
objs.append(obj)
# Randomize the player start position and orientation
self.place_agent()
# Choose a random object to be picked up
target = objs[self._rand_int(0, len(objs))]
self.targetType = target.type
self.targetColor = target.color
descStr = f"{self.targetColor} {self.targetType}"
# Generate the mission string
idx = self._rand_int(0, 5)
if idx == 0:
self.mission = "get a %s" % descStr
elif idx == 1:
self.mission = "go get a %s" % descStr
elif idx == 2:
self.mission = "fetch a %s" % descStr
elif idx == 3:
self.mission = "go fetch a %s" % descStr
elif idx == 4:
self.mission = "you must fetch a %s" % descStr
assert hasattr(self, "mission")
def step(self, action):
obs, reward, terminated, truncated, info = super().step(action)
if self.carrying:
if (
self.carrying.color == self.targetColor
and self.carrying.type == self.targetType
):
reward = self._reward()
terminated = True
else:
reward = 0
terminated = True
return obs, reward, terminated, truncated, info

119
gym_minigrid/gym_minigrid/envs/fourrooms.py

@ -0,0 +1,119 @@
from gym_minigrid.minigrid import Goal, Grid, MiniGridEnv, MissionSpace
class FourRoomsEnv(MiniGridEnv):
"""
### Description
Classic four room reinforcement learning environment. The agent must
navigate in a maze composed of four rooms interconnected by 4 gaps in the
walls. To obtain a reward, the agent must reach the green goal square. Both
the agent and the goal square are randomly placed in any of the four rooms.
### Mission Space
"reach the goal"
### Action Space
| Num | Name | Action |
|-----|--------------|--------------|
| 0 | left | Turn left |
| 1 | right | Turn right |
| 2 | forward | Move forward |
| 3 | pickup | Unused |
| 4 | drop | Unused |
| 5 | toggle | Unused |
| 6 | done | Unused |
### Observation Encoding
- Each tile is encoded as a 3 dimensional tuple:
`(OBJECT_IDX, COLOR_IDX, STATE)`
- `OBJECT_TO_IDX` and `COLOR_TO_IDX` mapping can be found in
[gym_minigrid/minigrid.py](gym_minigrid/minigrid.py)
- `STATE` refers to the door state with 0=open, 1=closed and 2=locked
### Rewards
A reward of '1' is given for success, and '0' for failure.
### Termination
The episode ends if any one of the following conditions is met:
1. The agent reaches the goal.
2. Timeout (see `max_steps`).
### Registered Configurations
- `MiniGrid-FourRooms-v0`
"""
def __init__(self, agent_pos=None, goal_pos=None, **kwargs):
self._agent_default_pos = agent_pos
self._goal_default_pos = goal_pos
self.size = 19
mission_space = MissionSpace(mission_func=lambda: "reach the goal")
super().__init__(
mission_space=mission_space,
width=self.size,
height=self.size,
max_steps=100,
**kwargs
)
def _gen_grid(self, width, height):
# Create the grid
self.grid = Grid(width, height)
# Generate the surrounding walls
self.grid.horz_wall(0, 0)
self.grid.horz_wall(0, height - 1)
self.grid.vert_wall(0, 0)
self.grid.vert_wall(width - 1, 0)
room_w = width // 2
room_h = height // 2
# For each row of rooms
for j in range(0, 2):
# For each column
for i in range(0, 2):
xL = i * room_w
yT = j * room_h
xR = xL + room_w
yB = yT + room_h
# Bottom wall and door
if i + 1 < 2:
self.grid.vert_wall(xR, yT, room_h)
pos = (xR, self._rand_int(yT + 1, yB))
self.grid.set(*pos, None)
# Bottom wall and door
if j + 1 < 2:
self.grid.horz_wall(xL, yB, room_w)
pos = (self._rand_int(xL + 1, xR), yB)
self.grid.set(*pos, None)
# Randomize the player start position and orientation
if self._agent_default_pos is not None:
self.agent_pos = self._agent_default_pos
self.grid.set(*self._agent_default_pos, None)
# assuming random start direction
self.agent_dir = self._rand_int(0, 4)
else:
self.place_agent()
if self._goal_default_pos is not None:
goal = Goal()
self.put_obj(goal, *self._goal_default_pos)
goal.init_pos, goal.cur_pos = self._goal_default_pos
else:
self.place_obj(Goal())

136
gym_minigrid/gym_minigrid/envs/gotodoor.py

@ -0,0 +1,136 @@
from gym_minigrid.minigrid import COLOR_NAMES, Door, Grid, MiniGridEnv, MissionSpace
class GoToDoorEnv(MiniGridEnv):
"""
### Description
This environment is a room with four doors, one on each wall. The agent
receives a textual (mission) string as input, telling it which door to go
to, (eg: "go to the red door"). It receives a positive reward for performing
the `done` action next to the correct door, as indicated in the mission
string.
### Mission Space
"go to the {color} door"
{color} is the color of the door. Can be "red", "green", "blue", "purple",
"yellow" or "grey".
### Action Space
| Num | Name | Action |
|-----|--------------|----------------------|
| 0 | left | Turn left |
| 1 | right | Turn right |
| 2 | forward | Move forward |
| 3 | pickup | Unused |
| 4 | drop | Unused |
| 5 | toggle | Unused |
| 6 | done | Done completing task |
### Observation Encoding
- Each tile is encoded as a 3 dimensional tuple:
`(OBJECT_IDX, COLOR_IDX, STATE)`
- `OBJECT_TO_IDX` and `COLOR_TO_IDX` mapping can be found in
[gym_minigrid/minigrid.py](gym_minigrid/minigrid.py)
- `STATE` refers to the door state with 0=open, 1=closed and 2=locked
### Rewards
A reward of '1' is given for success, and '0' for failure.
### Termination
The episode ends if any one of the following conditions is met:
1. The agent stands next the correct door performing the `done` action.
2. Timeout (see `max_steps`).
### Registered Configurations
- `MiniGrid-GoToDoor-5x5-v0`
- `MiniGrid-GoToDoor-6x6-v0`
- `MiniGrid-GoToDoor-8x8-v0`
"""
def __init__(self, size=5, **kwargs):
assert size >= 5
self.size = size
mission_space = MissionSpace(
mission_func=lambda color: f"go to the {color} door",
ordered_placeholders=[COLOR_NAMES],
)
super().__init__(
mission_space=mission_space,
width=size,
height=size,
max_steps=5 * size**2,
# Set this to True for maximum speed
see_through_walls=True,
**kwargs,
)
def _gen_grid(self, width, height):
# Create the grid
self.grid = Grid(width, height)
# Randomly vary the room width and height
width = self._rand_int(5, width + 1)
height = self._rand_int(5, height + 1)
# Generate the surrounding walls
self.grid.wall_rect(0, 0, width, height)
# Generate the 4 doors at random positions
doorPos = []
doorPos.append((self._rand_int(2, width - 2), 0))
doorPos.append((self._rand_int(2, width - 2), height - 1))
doorPos.append((0, self._rand_int(2, height - 2)))
doorPos.append((width - 1, self._rand_int(2, height - 2)))
# Generate the door colors
doorColors = []
while len(doorColors) < len(doorPos):
color = self._rand_elem(COLOR_NAMES)
if color in doorColors:
continue
doorColors.append(color)
# Place the doors in the grid
for idx, pos in enumerate(doorPos):
color = doorColors[idx]
self.grid.set(*pos, Door(color))
# Randomize the agent start position and orientation
self.place_agent(size=(width, height))
# Select a random target door
doorIdx = self._rand_int(0, len(doorPos))
self.target_pos = doorPos[doorIdx]
self.target_color = doorColors[doorIdx]
# Generate the mission string
self.mission = "go to the %s door" % self.target_color
def step(self, action):
obs, reward, terminated, truncated, info = super().step(action)
ax, ay = self.agent_pos
tx, ty = self.target_pos
# Don't let the agent open any of the doors
if action == self.actions.toggle:
terminated = True
# Reward performing done action in front of the target door
if action == self.actions.done:
if (ax == tx and abs(ay - ty) == 1) or (ay == ty and abs(ax - tx) == 1):
reward = self._reward()
terminated = True
return obs, reward, terminated, truncated, info

104
gym_minigrid/gym_minigrid/envs/gotoobject.py

@ -0,0 +1,104 @@
from gym_minigrid.minigrid import (
COLOR_NAMES,
Ball,
Box,
Grid,
Key,
MiniGridEnv,
MissionSpace,
)
class GoToObjectEnv(MiniGridEnv):
"""
Environment in which the agent is instructed to go to a given object
named using an English text string
"""
def __init__(self, size=6, numObjs=2, **kwargs):
self.numObjs = numObjs
self.size = size
# Types of objects to be generated
self.obj_types = ["key", "ball", "box"]
mission_space = MissionSpace(
mission_func=lambda color, type: f"go to the {color} {type}",
ordered_placeholders=[COLOR_NAMES, self.obj_types],
)
super().__init__(
mission_space=mission_space,
width=size,
height=size,
max_steps=5 * size**2,
# Set this to True for maximum speed
see_through_walls=True,
**kwargs,
)
def _gen_grid(self, width, height):
self.grid = Grid(width, height)
# Generate the surrounding walls
self.grid.wall_rect(0, 0, width, height)
# Types and colors of objects we can generate
types = ["key", "ball", "box"]
objs = []
objPos = []
# Until we have generated all the objects
while len(objs) < self.numObjs:
objType = self._rand_elem(types)
objColor = self._rand_elem(COLOR_NAMES)
# If this object already exists, try again
if (objType, objColor) in objs:
continue
if objType == "key":
obj = Key(objColor)
elif objType == "ball":
obj = Ball(objColor)
elif objType == "box":
obj = Box(objColor)
else:
raise ValueError(
"{} object type given. Object type can only be of values key, ball and box.".format(
objType
)
)
pos = self.place_obj(obj)
objs.append((objType, objColor))
objPos.append(pos)
# Randomize the agent start position and orientation
self.place_agent()
# Choose a random object to be picked up
objIdx = self._rand_int(0, len(objs))
self.targetType, self.target_color = objs[objIdx]
self.target_pos = objPos[objIdx]
descStr = f"{self.target_color} {self.targetType}"
self.mission = "go to the %s" % descStr
# print(self.mission)
def step(self, action):
obs, reward, terminated, truncated, info = super().step(action)
ax, ay = self.agent_pos
tx, ty = self.target_pos
# Toggle/pickup action terminates the episode
if action == self.actions.toggle:
terminated = True
# Reward performing the done action next to the target object
if action == self.actions.done:
if abs(ax - tx) <= 1 and abs(ay - ty) <= 1:
reward = self._reward()
terminated = True
return obs, reward, terminated, truncated, info

91
gym_minigrid/gym_minigrid/envs/guidedRLExperiments.py

@ -0,0 +1,91 @@
from gym_minigrid.minigrid import COLOR_NAMES, Ball, MissionSpace
from gym_minigrid.roomgrid import RoomGrid
class TwoRooms(RoomGrid):
"""
### Description
### Mission Space
### Action Space
| Num | Name | Action |
|-----|--------------|-------------------|
| 0 | left | Turn left |
| 1 | right | Turn right |
| 2 | forward | Move forward |
| 3 | pickup | Pick up an object |
| 4 | drop | Unused |
| 5 | toggle | Unused |
| 6 | done | Unused |
### Observation Encoding
- Each tile is encoded as a 3 dimensional tuple:
`(OBJECT_IDX, COLOR_IDX, STATE)`
- `OBJECT_TO_IDX` and `COLOR_TO_IDX` mapping can be found in
[gym_minigrid/minigrid.py](gym_minigrid/minigrid.py)
- `STATE` refers to the door state with 0=open, 1=closed and 2=locked
### Rewards
A reward of '1' is given for success, and '0' for failure.
### Termination
The episode ends if any one of the following conditions is met:
1. The agent picks up the correct box.
2. Timeout (see `max_steps`).
### Registered Configurations
- `MiniGrid-BlockedUnlockPickup-v0`
"""
def __init__(self, **kwargs):
room_size = 6
mission_space = MissionSpace(
mission_func=lambda color, type: f"pick up the {color} {type}",
ordered_placeholders=[COLOR_NAMES, ["box", "key"]],
)
super().__init__(
mission_space=mission_space,
num_rows=1,
num_cols=2,
room_size=room_size,
max_steps=16 * room_size**2,
**kwargs,
)
def _gen_grid(self, width, height):
super()._gen_grid(width, height)
# Add a box to the room on the right
obj, _ = self.add_object(1, 0, kind="box")
# Make sure the two rooms are directly connected by a locked door
door, pos = self.add_door(0, 0, 0, locked=True)
# Block the door with a ball
color = self._rand_color()
self.grid.set(pos[0] - 1, pos[1], Ball(color))
# Add a key to unlock the door
self.add_object(0, 0, "key", door.color)
self.place_agent(0, 0)
self.obj = obj
self.mission = f"pick up the {obj.color} {obj.type}"
def step(self, action):
obs, reward, terminated, truncated, info = super().step(action)
if action == self.actions.pickup:
if self.carrying and self.carrying == self.obj:
reward = self._reward()
terminated = True
return obs, reward, terminated, truncated, info

119
gym_minigrid/gym_minigrid/envs/keycorridor.py

@ -0,0 +1,119 @@
from gym_minigrid.minigrid import COLOR_NAMES, MissionSpace
from gym_minigrid.roomgrid import RoomGrid
class KeyCorridorEnv(RoomGrid):
"""
### Description
This environment is similar to the locked room environment, but there are
multiple registered environment configurations of increasing size,
making it easier to use curriculum learning to train an agent to solve it.
The agent has to pick up an object which is behind a locked door. The key is
hidden in another room, and the agent has to explore the environment to find
it. The mission string does not give the agent any clues as to where the
key is placed. This environment can be solved without relying on language.
### Mission Space
"pick up the {color} {obj_type}"
{color} is the color of the object. Can be "red", "green", "blue", "purple",
"yellow" or "grey".
{type} is the type of the object. Can be "ball" or "key".
### Action Space
| Num | Name | Action |
|-----|--------------|-------------------|
| 0 | left | Turn left |
| 1 | right | Turn right |
| 2 | forward | Move forward |
| 3 | pickup | Pick up an object |
| 4 | drop | Unused |
| 5 | toggle | Unused |
| 6 | done | Unused |
### Observation Encoding
- Each tile is encoded as a 3 dimensional tuple:
`(OBJECT_IDX, COLOR_IDX, STATE)`
- `OBJECT_TO_IDX` and `COLOR_TO_IDX` mapping can be found in
[gym_minigrid/minigrid.py](gym_minigrid/minigrid.py)
- `STATE` refers to the door state with 0=open, 1=closed and 2=locked
### Rewards
A reward of '1' is given for success, and '0' for failure.
### Termination
The episode ends if any one of the following conditions is met:
1. The agent picks up the correct object.
2. Timeout (see `max_steps`).
### Registered Configurations
S: room size.
R: Number of rows.
- `MiniGrid-KeyCorridorS3R1-v0`
- `MiniGrid-KeyCorridorS3R2-v0`
- `MiniGrid-KeyCorridorS3R3-v0`
- `MiniGrid-KeyCorridorS4R3-v0`
- `MiniGrid-KeyCorridorS5R3-v0`
- `MiniGrid-KeyCorridorS6R3-v0`
"""
def __init__(self, num_rows=3, obj_type="ball", room_size=6, **kwargs):
self.obj_type = obj_type
mission_space = MissionSpace(
mission_func=lambda color: f"pick up the {color} {obj_type}",
ordered_placeholders=[COLOR_NAMES],
)
super().__init__(
mission_space=mission_space,
room_size=room_size,
num_rows=num_rows,
max_steps=30 * room_size**2,
**kwargs,
)
def _gen_grid(self, width, height):
super()._gen_grid(width, height)
# Connect the middle column rooms into a hallway
for j in range(1, self.num_rows):
self.remove_wall(1, j, 3)
# Add a locked door on the bottom right
# Add an object behind the locked door
room_idx = self._rand_int(0, self.num_rows)
door, _ = self.add_door(2, room_idx, 2, locked=True)
obj, _ = self.add_object(2, room_idx, kind=self.obj_type)
# Add a key in a random room on the left side
self.add_object(0, self._rand_int(0, self.num_rows), "key", door.color)
# Place the agent in the middle
self.place_agent(1, self.num_rows // 2)
# Make sure all rooms are accessible
self.connect_all()
self.obj = obj
self.mission = f"pick up the {obj.color} {obj.type}"
def step(self, action):
obs, reward, terminated, truncated, info = super().step(action)
if action == self.actions.pickup:
if self.carrying and self.carrying == self.obj:
reward = self._reward()
terminated = True
return obs, reward, terminated, truncated, info

79
gym_minigrid/gym_minigrid/envs/lavaObstaclesMini.py

@ -0,0 +1,79 @@
from gym_minigrid.minigrid import Goal, Grid, MiniGridEnv, MissionSpace, Lava, Wall, HeatMapTile
from gym_minigrid.policyRepairEnv import PolicyRepairEnv
from gym_minigrid.minigrid import run_BFS_reward
class LavaObstaclesMini(PolicyRepairEnv):
def __init__(self, size=11, agent_start_pos=(1, 1), agent_start_dir=0, **kwargs):
super().__init__(
size=size,
agent_start_pos=agent_start_pos,
agent_start_dir=agent_start_dir,
**kwargs
)
def _gen_grid(self, width, height):
# Create an empty grid
self.grid = Grid(width, height)
# Generate the surrounding walls
self.grid.wall_rect(0, 0, width, height)
# Generate the surrounding walls
self.grid.wall_rect(0, 0, width, height)
# Place a goal square in the bottom-right corner
self.put_obj(Goal(), width - 2, height - 2)
self.put_obj(Lava(), 3, 2)
self.put_obj(Lava(), 4, 2)
self.put_obj(Lava(), 5, 2)
self.put_obj(Lava(), 9, 3)
self.put_obj(Lava(), 5, 4)
self.put_obj(Lava(), 6, 4)
self.put_obj(Lava(), 7, 6)
self.put_obj(Lava(), 8, 6)
self.put_obj(Lava(), 2, 6)
self.put_obj(Lava(), 3, 6)
self.put_obj(Lava(), 4, 6)
self.put_obj(Lava(), 6, 8)
self.put_obj(Lava(), 7, 8)
self.put_obj(Lava(), 1, 9)
self.put_obj(Lava(), 2, 9)
self.put_obj(Lava(), 3, 9)
#self.put_obj(Lava(), 3, 6)
# Place the agent
if not self.agent_pos or (self.agent_pos[0] == -1 and self.agent_pos[1] == -1 and self.agent_dir == -1):
self.agent_pos = self.agent_start_pos
self.agent_dir = self.agent_start_dir
self.bfs_reward = run_BFS_reward(self.grid, (width - 2, height - 2))
self.mission = "get to the green goal square"
def step(self, action):
# Get the position in front of the agent
fwd_pos = self.front_pos
# Get the contents of the cell in front of the agent
fwd_cell = self.grid.get(*fwd_pos)
obs, reward, terminated, truncated, info = super().step(action)
#bfs reward
reward = self.bfs_reward[self.agent_pos[0] + self.grid.width * self.agent_pos[1]]
#negative reward for stepping in lava, positive reward for reaching goal
if action == self.actions.forward:
if fwd_cell is not None and fwd_cell.type == "goal":
reward += 100
elif fwd_cell is not None and fwd_cell.type == "lava":
reward -=100
if self.render_mode == "human":
print("step: {}, reward: {}, info: {}\t\t\tthat terminated: {}".format(self.total_timesteps, reward, info, terminated or truncated))
return obs, reward, terminated, truncated, info

58
gym_minigrid/gym_minigrid/envs/lavaSymmetricMini.py

@ -0,0 +1,58 @@
from gym_minigrid.minigrid import Goal, Grid, MiniGridEnv, MissionSpace, Lava, Wall, HeatMapTile
from gym_minigrid.policyRepairEnv import PolicyRepairEnv
from gym_minigrid.minigrid import run_BFS_reward
class LavaSymmetricMini(PolicyRepairEnv):
def __init__(self, size=6, agent_start_pos=(4, 4), agent_start_dir=0, **kwargs):
super().__init__(
size=size,
agent_start_pos=agent_start_pos,
agent_start_dir=agent_start_dir,
**kwargs
)
def _gen_grid(self, width, height):
# Create an empty grid
self.grid = Grid(width, height)
# Generate the surrounding walls
self.grid.wall_rect(0, 0, width, height)
# Generate the surrounding walls
self.grid.wall_rect(0, 0, width, height)
# Place a goal square in the bottom-right corner
self.put_obj(Goal(), 1, 1)
self.put_obj(Lava(), 2, 4)
self.put_obj(Lava(), 4, 2)
#self.put_obj(Lava(), 2, 2)
# Place the agent
if not self.agent_pos or (self.agent_pos[0] == -1 and self.agent_pos[1] == -1 and self.agent_dir == -1):
self.agent_pos = self.agent_start_pos
self.agent_dir = self.agent_start_dir
self.bfs_reward = run_BFS_reward(self.grid, (width - 2, height - 2))
self.mission = "get to the green goal square"
def step(self, action):
# Get the position in front of the agent
fwd_pos = self.front_pos
# Get the contents of the cell in front of the agent
fwd_cell = self.grid.get(*fwd_pos)
obs, reward, terminated, truncated, info = super().step(action)
#bfs reward
reward = self.bfs_reward[self.agent_pos[0] + self.grid.width * self.agent_pos[1]]
#negative reward for stepping in lava, positive reward for reaching goal
if action == self.actions.forward:
if fwd_cell is not None and fwd_cell.type == "goal":
reward += 100
elif fwd_cell is not None and fwd_cell.type == "lava":
reward -=100
if self.render_mode == "human":
print("step: {}, reward: {}, info: {}\t\t\tthat terminated: {}".format(self.total_timesteps, reward, info, terminated or truncated))
return obs, reward, terminated, truncated, info

122
gym_minigrid/gym_minigrid/envs/lavagap.py

@ -0,0 +1,122 @@
import numpy as np
from gym_minigrid.minigrid import Goal, Grid, Lava, MiniGridEnv, MissionSpace
class LavaGapEnv(MiniGridEnv):
"""
### Description
The agent has to reach the green goal square at the opposite corner of the
room, and must pass through a narrow gap in a vertical strip of deadly lava.
Touching the lava terminate the episode with a zero reward. This environment
is useful for studying safety and safe exploration.
### Mission Space
Depending on the `obstacle_type` parameter:
- `Lava`: "avoid the lava and get to the green goal square"
- otherwise: "find the opening and get to the green goal square"
### Action Space
| Num | Name | Action |
|-----|--------------|--------------|
| 0 | left | Turn left |
| 1 | right | Turn right |
| 2 | forward | Move forward |
| 3 | pickup | Unused |
| 4 | drop | Unused |
| 5 | toggle | Unused |
| 6 | done | Unused |
### Observation Encoding
- Each tile is encoded as a 3 dimensional tuple:
`(OBJECT_IDX, COLOR_IDX, STATE)`
- `OBJECT_TO_IDX` and `COLOR_TO_IDX` mapping can be found in
[gym_minigrid/minigrid.py](gym_minigrid/minigrid.py)
- `STATE` refers to the door state with 0=open, 1=closed and 2=locked
### Rewards
A reward of '1' is given for success, and '0' for failure.
### Termination
The episode ends if any one of the following conditions is met:
1. The agent reaches the goal.
2. The agent falls into lava.
3. Timeout (see `max_steps`).
### Registered Configurations
S: size of map SxS.
- `MiniGrid-LavaGapS5-v0`
- `MiniGrid-LavaGapS6-v0`
- `MiniGrid-LavaGapS7-v0`
"""
def __init__(self, size, obstacle_type=Lava, **kwargs):
self.obstacle_type = obstacle_type
self.size = size
if obstacle_type == Lava:
mission_space = MissionSpace(
mission_func=lambda: "avoid the lava and get to the green goal square"
)
else:
mission_space = MissionSpace(
mission_func=lambda: "find the opening and get to the green goal square"
)
super().__init__(
mission_space=mission_space,
width=size,
height=size,
max_steps=4 * size * size,
# Set this to True for maximum speed
see_through_walls=False,
**kwargs
)
def _gen_grid(self, width, height):
assert width >= 5 and height >= 5
# Create an empty grid
self.grid = Grid(width, height)
# Generate the surrounding walls
self.grid.wall_rect(0, 0, width, height)
# Place the agent in the top-left corner
self.agent_pos = np.array((1, 1))
self.agent_dir = 0
# Place a goal square in the bottom-right corner
self.goal_pos = np.array((width - 2, height - 2))
self.put_obj(Goal(), *self.goal_pos)
# Generate and store random gap position
self.gap_pos = np.array(
(
self._rand_int(2, width - 2),
self._rand_int(1, height - 1),
)
)
# Place the obstacle wall
self.grid.vert_wall(self.gap_pos[0], 1, height - 2, self.obstacle_type)
# Put a hole in the wall
self.grid.set(*self.gap_pos, None)
self.mission = (
"avoid the lava and get to the green goal square"
if self.obstacle_type == Lava
else "find the opening and get to the green goal square"
)

167
gym_minigrid/gym_minigrid/envs/lockedroom.py

@ -0,0 +1,167 @@
from gym_minigrid.minigrid import (
COLOR_NAMES,
Door,
Goal,
Grid,
Key,
MiniGridEnv,
MissionSpace,
Wall,
)
class LockedRoom:
def __init__(self, top, size, doorPos):
self.top = top
self.size = size
self.doorPos = doorPos
self.color = None
self.locked = False
def rand_pos(self, env):
topX, topY = self.top
sizeX, sizeY = self.size
return env._rand_pos(topX + 1, topX + sizeX - 1, topY + 1, topY + sizeY - 1)
class LockedRoomEnv(MiniGridEnv):
"""
### Description
The environment has six rooms, one of which is locked. The agent receives
a textual mission string as input, telling it which room to go to in order
to get the key that opens the locked room. It then has to go into the locked
room in order to reach the final goal. This environment is extremely
difficult to solve with vanilla reinforcement learning alone.
### Mission Space
"get the {lockedroom_color} key from the {keyroom_color} room, unlock the {door_color} door and go to the goal"
{lockedroom_color}, {keyroom_color}, and {door_color} can be "red", "green",
"blue", "purple", "yellow" or "grey".
### Action Space
| Num | Name | Action |
|-----|--------------|---------------------------|
| 0 | left | Turn left |
| 1 | right | Turn right |
| 2 | forward | Move forward |
| 3 | pickup | Pick up an object |
| 4 | drop | Unused |
| 5 | toggle | Toggle/activate an object |
| 6 | done | Unused |
### Observation Encoding
- Each tile is encoded as a 3 dimensional tuple:
`(OBJECT_IDX, COLOR_IDX, STATE)`
- `OBJECT_TO_IDX` and `COLOR_TO_IDX` mapping can be found in
[gym_minigrid/minigrid.py](gym_minigrid/minigrid.py)
- `STATE` refers to the door state with 0=open, 1=closed and 2=locked
### Rewards
A reward of '1' is given for success, and '0' for failure.
### Termination
The episode ends if any one of the following conditions is met:
1. The agent reaches the goal.
2. Timeout (see `max_steps`).
### Registered Configurations
- `MiniGrid-LockedRoom-v0`
"""
def __init__(self, size=19, **kwargs):
self.size = size
mission_space = MissionSpace(
mission_func=lambda lockedroom_color, keyroom_color, door_color: f"get the {lockedroom_color} key from the {keyroom_color} room, unlock the {door_color} door and go to the goal",
ordered_placeholders=[COLOR_NAMES] * 3,
)
super().__init__(
mission_space=mission_space,
width=size,
height=size,
max_steps=10 * size,
**kwargs,
)
def _gen_grid(self, width, height):
# Create the grid
self.grid = Grid(width, height)
# Generate the surrounding walls
for i in range(0, width):
self.grid.set(i, 0, Wall())
self.grid.set(i, height - 1, Wall())
for j in range(0, height):
self.grid.set(0, j, Wall())
self.grid.set(width - 1, j, Wall())
# Hallway walls
lWallIdx = width // 2 - 2
rWallIdx = width // 2 + 2
for j in range(0, height):
self.grid.set(lWallIdx, j, Wall())
self.grid.set(rWallIdx, j, Wall())
self.rooms = []
# Room splitting walls
for n in range(0, 3):
j = n * (height // 3)
for i in range(0, lWallIdx):
self.grid.set(i, j, Wall())
for i in range(rWallIdx, width):
self.grid.set(i, j, Wall())
roomW = lWallIdx + 1
roomH = height // 3 + 1
self.rooms.append(LockedRoom((0, j), (roomW, roomH), (lWallIdx, j + 3)))
self.rooms.append(
LockedRoom((rWallIdx, j), (roomW, roomH), (rWallIdx, j + 3))
)
# Choose one random room to be locked
lockedRoom = self._rand_elem(self.rooms)
lockedRoom.locked = True
goalPos = lockedRoom.rand_pos(self)
self.grid.set(*goalPos, Goal())
# Assign the door colors
colors = set(COLOR_NAMES)
for room in self.rooms:
color = self._rand_elem(sorted(colors))
colors.remove(color)
room.color = color
if room.locked:
self.grid.set(*room.doorPos, Door(color, is_locked=True))
else:
self.grid.set(*room.doorPos, Door(color))
# Select a random room to contain the key
while True:
keyRoom = self._rand_elem(self.rooms)
if keyRoom != lockedRoom:
break
keyPos = keyRoom.rand_pos(self)
self.grid.set(*keyPos, Key(lockedRoom.color))
# Randomize the player start position and orientation
self.agent_pos = self.place_agent(
top=(lWallIdx, 0), size=(rWallIdx - lWallIdx, height)
)
# Generate the mission string
self.mission = (
"get the %s key from the %s room, "
"unlock the %s door and "
"go to the goal"
) % (lockedRoom.color, keyRoom.color, lockedRoom.color)

151
gym_minigrid/gym_minigrid/envs/memory.py

@ -0,0 +1,151 @@
import numpy as np
from gym_minigrid.minigrid import Ball, Grid, Key, MiniGridEnv, MissionSpace, Wall
class MemoryEnv(MiniGridEnv):
"""
### Description
This environment is a memory test. The agent starts in a small room where it
sees an object. It then has to go through a narrow hallway which ends in a
split. At each end of the split there is an object, one of which is the same
as the object in the starting room. The agent has to remember the initial
object, and go to the matching object at split.
### Mission Space
"go to the matching object at the end of the hallway"
### Action Space
| Num | Name | Action |
|-----|--------------|---------------------------|
| 0 | left | Turn left |
| 1 | right | Turn right |
| 2 | forward | Move forward |
| 3 | pickup | Pick up an object |
| 4 | drop | Unused |
| 5 | toggle | Toggle/activate an object |
| 6 | done | Unused |
### Observation Encoding
- Each tile is encoded as a 3 dimensional tuple:
`(OBJECT_IDX, COLOR_IDX, STATE)`
- `OBJECT_TO_IDX` and `COLOR_TO_IDX` mapping can be found in
[gym_minigrid/minigrid.py](gym_minigrid/minigrid.py)
- `STATE` refers to the door state with 0=open, 1=closed and 2=locked
### Rewards
A reward of '1' is given for success, and '0' for failure.
### Termination
The episode ends if any one of the following conditions is met:
1. The agent reaches the correct matching object.
2. The agent reaches the wrong matching object.
3. Timeout (see `max_steps`).
### Registered Configurations
S: size of map SxS.
- `MiniGrid-MemoryS17Random-v0`
- `MiniGrid-MemoryS13Random-v0`
- `MiniGrid-MemoryS13-v0`
- `MiniGrid-MemoryS11-v0`
"""
def __init__(self, size=8, random_length=False, **kwargs):
self.size = size
self.random_length = random_length
mission_space = MissionSpace(
mission_func=lambda: "go to the matching object at the end of the hallway"
)
super().__init__(
mission_space=mission_space,
width=size,
height=size,
max_steps=5 * size**2,
# Set this to True for maximum speed
see_through_walls=False,
**kwargs
)
def _gen_grid(self, width, height):
self.grid = Grid(width, height)
# Generate the surrounding walls
self.grid.horz_wall(0, 0)
self.grid.horz_wall(0, height - 1)
self.grid.vert_wall(0, 0)
self.grid.vert_wall(width - 1, 0)
assert height % 2 == 1
upper_room_wall = height // 2 - 2
lower_room_wall = height // 2 + 2
if self.random_length:
hallway_end = self._rand_int(4, width - 2)
else:
hallway_end = width - 3
# Start room
for i in range(1, 5):
self.grid.set(i, upper_room_wall, Wall())
self.grid.set(i, lower_room_wall, Wall())
self.grid.set(4, upper_room_wall + 1, Wall())
self.grid.set(4, lower_room_wall - 1, Wall())
# Horizontal hallway
for i in range(5, hallway_end):
self.grid.set(i, upper_room_wall + 1, Wall())
self.grid.set(i, lower_room_wall - 1, Wall())
# Vertical hallway
for j in range(0, height):
if j != height // 2:
self.grid.set(hallway_end, j, Wall())
self.grid.set(hallway_end + 2, j, Wall())
# Fix the player's start position and orientation
self.agent_pos = np.array((self._rand_int(1, hallway_end + 1), height // 2))
self.agent_dir = 0
# Place objects
start_room_obj = self._rand_elem([Key, Ball])
self.grid.set(1, height // 2 - 1, start_room_obj("green"))
other_objs = self._rand_elem([[Ball, Key], [Key, Ball]])
pos0 = (hallway_end + 1, height // 2 - 2)
pos1 = (hallway_end + 1, height // 2 + 2)
self.grid.set(*pos0, other_objs[0]("green"))
self.grid.set(*pos1, other_objs[1]("green"))
# Choose the target objects
if start_room_obj == other_objs[0]:
self.success_pos = (pos0[0], pos0[1] + 1)
self.failure_pos = (pos1[0], pos1[1] - 1)
else:
self.success_pos = (pos1[0], pos1[1] - 1)
self.failure_pos = (pos0[0], pos0[1] + 1)
self.mission = "go to the matching object at the end of the hallway"
def step(self, action):
if action == self.Actions.pickup:
action = self.Actions.toggle
obs, reward, terminated, truncated, info = super().step(action)
if tuple(self.agent_pos) == self.success_pos:
reward = self._reward()
terminated = True
if tuple(self.agent_pos) == self.failure_pos:
reward = 0
terminated = True
return obs, reward, terminated, truncated, info

271
gym_minigrid/gym_minigrid/envs/multiroom.py

@ -0,0 +1,271 @@
from gym_minigrid.minigrid import (
COLOR_NAMES,
Door,
Goal,
Grid,
MiniGridEnv,
MissionSpace,
Wall,
)
class MultiRoom:
def __init__(self, top, size, entryDoorPos, exitDoorPos):
self.top = top
self.size = size
self.entryDoorPos = entryDoorPos
self.exitDoorPos = exitDoorPos
class MultiRoomEnv(MiniGridEnv):
"""
### Description
This environment has a series of connected rooms with doors that must be
opened in order to get to the next room. The final room has the green goal
square the agent must get to. This environment is extremely difficult to
solve using RL alone. However, by gradually increasing the number of rooms
and building a curriculum, the environment can be solved.
### Mission Space
"traverse the rooms to get to the goal"
### Action Space
| Num | Name | Action |
|-----|--------------|---------------------------|
| 0 | left | Turn left |
| 1 | right | Turn right |
| 2 | forward | Move forward |
| 3 | pickup | Unused |
| 4 | drop | Unused |
| 5 | toggle | Toggle/activate an object |
| 6 | done | Unused |
### Observation Encoding
- Each tile is encoded as a 3 dimensional tuple:
`(OBJECT_IDX, COLOR_IDX, STATE)`
- `OBJECT_TO_IDX` and `COLOR_TO_IDX` mapping can be found in
[gym_minigrid/minigrid.py](gym_minigrid/minigrid.py)
- `STATE` refers to the door state with 0=open, 1=closed and 2=locked
### Rewards
A reward of '1' is given for success, and '0' for failure.
### Termination
The episode ends if any one of the following conditions is met:
1. The agent reaches the goal.
2. Timeout (see `max_steps`).
### Registered Configurations
S: size of map SxS.
N: number of rooms.
- `MiniGrid-MultiRoom-N2-S4-v0` (two small rooms)
- `MiniGrid-MultiRoom-N4-S5-v0` (four rooms)
- `MiniGrid-MultiRoom-N6-v0` (six rooms)
"""
def __init__(self, minNumRooms, maxNumRooms, maxRoomSize=10, **kwargs):
assert minNumRooms > 0
assert maxNumRooms >= minNumRooms
assert maxRoomSize >= 4
self.minNumRooms = minNumRooms
self.maxNumRooms = maxNumRooms
self.maxRoomSize = maxRoomSize
self.rooms = []
mission_space = MissionSpace(
mission_func=lambda: "traverse the rooms to get to the goal"
)
self.size = 25
super().__init__(
mission_space=mission_space,
width=self.size,
height=self.size,
max_steps=self.maxNumRooms * 20,
**kwargs
)
def _gen_grid(self, width, height):
roomList = []
# Choose a random number of rooms to generate
numRooms = self._rand_int(self.minNumRooms, self.maxNumRooms + 1)
while len(roomList) < numRooms:
curRoomList = []
entryDoorPos = (self._rand_int(0, width - 2), self._rand_int(0, width - 2))
# Recursively place the rooms
self._placeRoom(
numRooms,
roomList=curRoomList,
minSz=4,
maxSz=self.maxRoomSize,
entryDoorWall=2,
entryDoorPos=entryDoorPos,
)
if len(curRoomList) > len(roomList):
roomList = curRoomList
# Store the list of rooms in this environment
assert len(roomList) > 0
self.rooms = roomList
# Create the grid
self.grid = Grid(width, height)
wall = Wall()
prevDoorColor = None
# For each room
for idx, room in enumerate(roomList):
topX, topY = room.top
sizeX, sizeY = room.size
# Draw the top and bottom walls
for i in range(0, sizeX):
self.grid.set(topX + i, topY, wall)
self.grid.set(topX + i, topY + sizeY - 1, wall)
# Draw the left and right walls
for j in range(0, sizeY):
self.grid.set(topX, topY + j, wall)
self.grid.set(topX + sizeX - 1, topY + j, wall)
# If this isn't the first room, place the entry door
if idx > 0:
# Pick a door color different from the previous one
doorColors = set(COLOR_NAMES)
if prevDoorColor:
doorColors.remove(prevDoorColor)
# Note: the use of sorting here guarantees determinism,
# This is needed because Python's set is not deterministic
doorColor = self._rand_elem(sorted(doorColors))
entryDoor = Door(doorColor)
self.grid.set(room.entryDoorPos[0], room.entryDoorPos[1], entryDoor)
prevDoorColor = doorColor
prevRoom = roomList[idx - 1]
prevRoom.exitDoorPos = room.entryDoorPos
# Randomize the starting agent position and direction
self.place_agent(roomList[0].top, roomList[0].size)
# Place the final goal in the last room
self.goal_pos = self.place_obj(Goal(), roomList[-1].top, roomList[-1].size)
self.mission = "traverse the rooms to get to the goal"
def _placeRoom(self, numLeft, roomList, minSz, maxSz, entryDoorWall, entryDoorPos):
# Choose the room size randomly
sizeX = self._rand_int(minSz, maxSz + 1)
sizeY = self._rand_int(minSz, maxSz + 1)
# The first room will be at the door position
if len(roomList) == 0:
topX, topY = entryDoorPos
# Entry on the right
elif entryDoorWall == 0:
topX = entryDoorPos[0] - sizeX + 1
y = entryDoorPos[1]
topY = self._rand_int(y - sizeY + 2, y)
# Entry wall on the south
elif entryDoorWall == 1:
x = entryDoorPos[0]
topX = self._rand_int(x - sizeX + 2, x)
topY = entryDoorPos[1] - sizeY + 1
# Entry wall on the left
elif entryDoorWall == 2:
topX = entryDoorPos[0]
y = entryDoorPos[1]
topY = self._rand_int(y - sizeY + 2, y)
# Entry wall on the top
elif entryDoorWall == 3:
x = entryDoorPos[0]
topX = self._rand_int(x - sizeX + 2, x)
topY = entryDoorPos[1]
else:
assert False, entryDoorWall
# If the room is out of the grid, can't place a room here
if topX < 0 or topY < 0:
return False
if topX + sizeX > self.width or topY + sizeY >= self.height:
return False
# If the room intersects with previous rooms, can't place it here
for room in roomList[:-1]:
nonOverlap = (
topX + sizeX < room.top[0]
or room.top[0] + room.size[0] <= topX
or topY + sizeY < room.top[1]
or room.top[1] + room.size[1] <= topY
)
if not nonOverlap:
return False
# Add this room to the list
roomList.append(MultiRoom((topX, topY), (sizeX, sizeY), entryDoorPos, None))
# If this was the last room, stop
if numLeft == 1:
return True
# Try placing the next room
for i in range(0, 8):
# Pick which wall to place the out door on
wallSet = {0, 1, 2, 3}
wallSet.remove(entryDoorWall)
exitDoorWall = self._rand_elem(sorted(wallSet))
nextEntryWall = (exitDoorWall + 2) % 4
# Pick the exit door position
# Exit on right wall
if exitDoorWall == 0:
exitDoorPos = (topX + sizeX - 1, topY + self._rand_int(1, sizeY - 1))
# Exit on south wall
elif exitDoorWall == 1:
exitDoorPos = (topX + self._rand_int(1, sizeX - 1), topY + sizeY - 1)
# Exit on left wall
elif exitDoorWall == 2:
exitDoorPos = (topX, topY + self._rand_int(1, sizeY - 1))
# Exit on north wall
elif exitDoorWall == 3:
exitDoorPos = (topX + self._rand_int(1, sizeX - 1), topY)
else:
assert False
# Recursively create the other rooms
success = self._placeRoom(
numLeft - 1,
roomList=roomList,
minSz=minSz,
maxSz=maxSz,
entryDoorWall=nextEntryWall,
entryDoorPos=exitDoorPos,
)
if success:
break
return True

246
gym_minigrid/gym_minigrid/envs/obstructedmaze.py

@ -0,0 +1,246 @@
from gym_minigrid.minigrid import COLOR_NAMES, DIR_TO_VEC, Ball, Box, Key, MissionSpace
from gym_minigrid.roomgrid import RoomGrid
class ObstructedMazeEnv(RoomGrid):
"""
### Description
The agent has to pick up a box which is placed in a corner of a 3x3 maze.
The doors are locked, the keys are hidden in boxes and doors are obstructed
by balls. This environment can be solved without relying on language.
### Mission Space
"pick up the {COLOR_NAMES[0]} ball"
### Action Space
| Num | Name | Action |
|-----|--------------|---------------------------|
| 0 | left | Turn left |
| 1 | right | Turn right |
| 2 | forward | Move forward |
| 3 | pickup | Pick up an object |
| 4 | drop | Unused |
| 5 | toggle | Toggle/activate an object |
| 6 | done | Unused |
### Observation Encoding
- Each tile is encoded as a 3 dimensional tuple:
`(OBJECT_IDX, COLOR_IDX, STATE)`
- `OBJECT_TO_IDX` and `COLOR_TO_IDX` mapping can be found in
[gym_minigrid/minigrid.py](gym_minigrid/minigrid.py)
- `STATE` refers to the door state with 0=open, 1=closed and 2=locked
### Rewards
A reward of '1' is given for success, and '0' for failure.
### Termination
The episode ends if any one of the following conditions is met:
1. The agent picks up the blue ball.
2. Timeout (see `max_steps`).
### Registered Configurations
"NDl" are the number of doors locked.
"h" if the key is hidden in a box.
"b" if the door is obstructed by a ball.
"Q" number of quarters that will have doors and keys out of the 9 that the
map already has.
"Full" 3x3 maze with "h" and "b" options.
- `MiniGrid-ObstructedMaze-1Dl-v0`
- `MiniGrid-ObstructedMaze-1Dlh-v0`
- `MiniGrid-ObstructedMaze-1Dlhb-v0`
- `MiniGrid-ObstructedMaze-2Dl-v0`
- `MiniGrid-ObstructedMaze-2Dlh-v0`
- `MiniGrid-ObstructedMaze-2Dlhb-v0`
- `MiniGrid-ObstructedMaze-1Q-v0`
- `MiniGrid-ObstructedMaze-2Q-v0`
- `MiniGrid-ObstructedMaze-Full-v0`
"""
def __init__(self, num_rows, num_cols, num_rooms_visited, **kwargs):
room_size = 6
max_steps = 4 * num_rooms_visited * room_size**2
mission_space = MissionSpace(
mission_func=lambda: f"pick up the {COLOR_NAMES[0]} ball",
)
super().__init__(
mission_space=mission_space,
room_size=room_size,
num_rows=num_rows,
num_cols=num_cols,
max_steps=max_steps,
**kwargs,
)
self.obj = Ball() # initialize the obj attribute, that will be changed later on
def _gen_grid(self, width, height):
super()._gen_grid(width, height)
# Define all possible colors for doors
self.door_colors = self._rand_subset(COLOR_NAMES, len(COLOR_NAMES))
# Define the color of the ball to pick up
self.ball_to_find_color = COLOR_NAMES[0]
# Define the color of the balls that obstruct doors
self.blocking_ball_color = COLOR_NAMES[1]
# Define the color of boxes in which keys are hidden
self.box_color = COLOR_NAMES[2]
self.mission = "pick up the %s ball" % self.ball_to_find_color
def step(self, action):
obs, reward, terminated, truncated, info = super().step(action)
if action == self.actions.pickup:
if self.carrying and self.carrying == self.obj:
reward = self._reward()
terminated = True
return obs, reward, terminated, truncated, info
def add_door(
self,
i,
j,
door_idx=0,
color=None,
locked=False,
key_in_box=False,
blocked=False,
):
"""
Add a door. If the door must be locked, it also adds the key.
If the key must be hidden, it is put in a box. If the door must
be obstructed, it adds a ball in front of the door.
"""
door, door_pos = super().add_door(i, j, door_idx, color, locked=locked)
if blocked:
vec = DIR_TO_VEC[door_idx]
blocking_ball = Ball(self.blocking_ball_color) if blocked else None
self.grid.set(door_pos[0] - vec[0], door_pos[1] - vec[1], blocking_ball)
if locked:
obj = Key(door.color)
if key_in_box:
box = Box(self.box_color)
box.contains = obj
obj = box
self.place_in_room(i, j, obj)
return door, door_pos
class ObstructedMaze_1Dlhb(ObstructedMazeEnv):
"""
A blue ball is hidden in a 2x1 maze. A locked door separates
rooms. Doors are obstructed by a ball and keys are hidden in boxes.
"""
def __init__(self, key_in_box=True, blocked=True, **kwargs):
self.key_in_box = key_in_box
self.blocked = blocked
super().__init__(num_rows=1, num_cols=2, num_rooms_visited=2, **kwargs)
def _gen_grid(self, width, height):
super()._gen_grid(width, height)
self.add_door(
0,
0,
door_idx=0,
color=self.door_colors[0],
locked=True,
key_in_box=self.key_in_box,
blocked=self.blocked,
)
self.obj, _ = self.add_object(1, 0, "ball", color=self.ball_to_find_color)
self.place_agent(0, 0)
class ObstructedMaze_Full(ObstructedMazeEnv):
"""
A blue ball is hidden in one of the 4 corners of a 3x3 maze. Doors
are locked, doors are obstructed by a ball and keys are hidden in
boxes.
"""
def __init__(
self,
agent_room=(1, 1),
key_in_box=True,
blocked=True,
num_quarters=4,
num_rooms_visited=25,
**kwargs,
):
self.agent_room = agent_room
self.key_in_box = key_in_box
self.blocked = blocked
self.num_quarters = num_quarters
super().__init__(
num_rows=3, num_cols=3, num_rooms_visited=num_rooms_visited, **kwargs
)
def _gen_grid(self, width, height):
super()._gen_grid(width, height)
middle_room = (1, 1)
# Define positions of "side rooms" i.e. rooms that are neither
# corners nor the center.
side_rooms = [(2, 1), (1, 2), (0, 1), (1, 0)][: self.num_quarters]
for i in range(len(side_rooms)):
side_room = side_rooms[i]
# Add a door between the center room and the side room
self.add_door(
*middle_room, door_idx=i, color=self.door_colors[i], locked=False
)
for k in [-1, 1]:
# Add a door to each side of the side room
self.add_door(
*side_room,
locked=True,
door_idx=(i + k) % 4,
color=self.door_colors[(i + k) % len(self.door_colors)],
key_in_box=self.key_in_box,
blocked=self.blocked,
)
corners = [(2, 0), (2, 2), (0, 2), (0, 0)][: self.num_quarters]
ball_room = self._rand_elem(corners)
self.obj, _ = self.add_object(
ball_room[0], ball_room[1], "ball", color=self.ball_to_find_color
)
self.place_agent(*self.agent_room)
class ObstructedMaze_2Dl(ObstructedMaze_Full):
def __init__(self, **kwargs):
super().__init__((2, 1), False, False, 1, 4, **kwargs)
class ObstructedMaze_2Dlh(ObstructedMaze_Full):
def __init__(self, **kwargs):
super().__init__((2, 1), True, False, 1, 4, **kwargs)
class ObstructedMaze_2Dlhb(ObstructedMaze_Full):
def __init__(self, **kwargs):
super().__init__((2, 1), True, True, 1, 4, **kwargs)

90
gym_minigrid/gym_minigrid/envs/playground.py

@ -0,0 +1,90 @@
from gym_minigrid.minigrid import (
COLOR_NAMES,
Ball,
Box,
Door,
Grid,
Key,
MiniGridEnv,
MissionSpace,
)
class PlaygroundEnv(MiniGridEnv):
"""
Environment with multiple rooms and random objects.
This environment has no specific goals or rewards.
"""
def __init__(self, **kwargs):
mission_space = MissionSpace(mission_func=lambda: "")
self.size = 19
super().__init__(
mission_space=mission_space,
width=self.size,
height=self.size,
max_steps=100,
**kwargs
)
def _gen_grid(self, width, height):
# Create the grid
self.grid = Grid(width, height)
# Generate the surrounding walls
self.grid.horz_wall(0, 0)
self.grid.horz_wall(0, height - 1)
self.grid.vert_wall(0, 0)
self.grid.vert_wall(width - 1, 0)
roomW = width // 3
roomH = height // 3
# For each row of rooms
for j in range(0, 3):
# For each column
for i in range(0, 3):
xL = i * roomW
yT = j * roomH
xR = xL + roomW
yB = yT + roomH
# Bottom wall and door
if i + 1 < 3:
self.grid.vert_wall(xR, yT, roomH)
pos = (xR, self._rand_int(yT + 1, yB - 1))
color = self._rand_elem(COLOR_NAMES)
self.grid.set(*pos, Door(color))
# Bottom wall and door
if j + 1 < 3:
self.grid.horz_wall(xL, yB, roomW)
pos = (self._rand_int(xL + 1, xR - 1), yB)
color = self._rand_elem(COLOR_NAMES)
self.grid.set(*pos, Door(color))
# Randomize the player start position and orientation
self.place_agent()
# Place random objects in the world
types = ["key", "ball", "box"]
for i in range(0, 12):
objType = self._rand_elem(types)
objColor = self._rand_elem(COLOR_NAMES)
if objType == "key":
obj = Key(objColor)
elif objType == "ball":
obj = Ball(objColor)
elif objType == "box":
obj = Box(objColor)
else:
raise ValueError(
"{} object type given. Object type can only be of values key, ball and box.".format(
objType
)
)
self.place_obj(obj)
# No explicit mission in this environment
self.mission = ""

192
gym_minigrid/gym_minigrid/envs/putnear.py

@ -0,0 +1,192 @@
from gym_minigrid.minigrid import (
COLOR_NAMES,
Ball,
Box,
Grid,
Key,
MiniGridEnv,
MissionSpace,
)
class PutNearEnv(MiniGridEnv):
"""
### Description
The agent is instructed through a textual string to pick up an object and
place it next to another object. This environment is easy to solve with two
objects, but difficult to solve with more, as it involves both textual
understanding and spatial reasoning involving multiple objects.
### Mission Space
"put the {move_color} {move_type} near the {target_color} {target_type}"
{move_color} and {target_color} can be "red", "green", "blue", "purple",
"yellow" or "grey".
{move_type} and {target_type} Can be "box", "ball" or "key".
### Action Space
| Num | Name | Action |
|-----|--------------|-------------------|
| 0 | left | Turn left |
| 1 | right | Turn right |
| 2 | forward | Move forward |
| 3 | pickup | Pick up an object |
| 4 | drop | Drop an object |
| 5 | toggle | Unused |
| 6 | done | Unused |
### Observation Encoding
- Each tile is encoded as a 3 dimensional tuple:
`(OBJECT_IDX, COLOR_IDX, STATE)`
- `OBJECT_TO_IDX` and `COLOR_TO_IDX` mapping can be found in
[gym_minigrid/minigrid.py](gym_minigrid/minigrid.py)
- `STATE` refers to the door state with 0=open, 1=closed and 2=locked
### Rewards
A reward of '1' is given for success, and '0' for failure.
### Termination
The episode ends if any one of the following conditions is met:
1. The agent picks up the wrong object.
2. The agent drop the correct object near the target.
3. Timeout (see `max_steps`).
### Registered Configurations
N: number of objects.
- `MiniGrid-PutNear-6x6-N2-v0`
- `MiniGrid-PutNear-8x8-N3-v0`
"""
def __init__(self, size=6, numObjs=2, **kwargs):
self.size = size
self.numObjs = numObjs
self.obj_types = ["key", "ball", "box"]
mission_space = MissionSpace(
mission_func=lambda move_color, move_type, target_color, target_type: f"put the {move_color} {move_type} near the {target_color} {target_type}",
ordered_placeholders=[
COLOR_NAMES,
self.obj_types,
COLOR_NAMES,
self.obj_types,
],
)
super().__init__(
mission_space=mission_space,
width=size,
height=size,
max_steps=5 * size,
# Set this to True for maximum speed
see_through_walls=True,
**kwargs,
)
def _gen_grid(self, width, height):
self.grid = Grid(width, height)
# Generate the surrounding walls
self.grid.horz_wall(0, 0)
self.grid.horz_wall(0, height - 1)
self.grid.vert_wall(0, 0)
self.grid.vert_wall(width - 1, 0)
# Types and colors of objects we can generate
types = ["key", "ball", "box"]
objs = []
objPos = []
def near_obj(env, p1):
for p2 in objPos:
dx = p1[0] - p2[0]
dy = p1[1] - p2[1]
if abs(dx) <= 1 and abs(dy) <= 1:
return True
return False
# Until we have generated all the objects
while len(objs) < self.numObjs:
objType = self._rand_elem(types)
objColor = self._rand_elem(COLOR_NAMES)
# If this object already exists, try again
if (objType, objColor) in objs:
continue
if objType == "key":
obj = Key(objColor)
elif objType == "ball":
obj = Ball(objColor)
elif objType == "box":
obj = Box(objColor)
else:
raise ValueError(
"{} object type given. Object type can only be of values key, ball and box.".format(
objType
)
)
pos = self.place_obj(obj, reject_fn=near_obj)
objs.append((objType, objColor))
objPos.append(pos)
# Randomize the agent start position and orientation
self.place_agent()
# Choose a random object to be moved
objIdx = self._rand_int(0, len(objs))
self.move_type, self.moveColor = objs[objIdx]
self.move_pos = objPos[objIdx]
# Choose a target object (to put the first object next to)
while True:
targetIdx = self._rand_int(0, len(objs))
if targetIdx != objIdx:
break
self.target_type, self.target_color = objs[targetIdx]
self.target_pos = objPos[targetIdx]
self.mission = "put the {} {} near the {} {}".format(
self.moveColor,
self.move_type,
self.target_color,
self.target_type,
)
def step(self, action):
preCarrying = self.carrying
obs, reward, terminated, truncated, info = super().step(action)
u, v = self.dir_vec
ox, oy = (self.agent_pos[0] + u, self.agent_pos[1] + v)
tx, ty = self.target_pos
# If we picked up the wrong object, terminate the episode
if action == self.actions.pickup and self.carrying:
if (
self.carrying.type != self.move_type
or self.carrying.color != self.moveColor
):
terminated = True
# If successfully dropping an object near the target
if action == self.actions.drop and preCarrying:
if self.grid.get(ox, oy) is preCarrying:
if abs(ox - tx) <= 1 and abs(oy - ty) <= 1:
reward = self._reward()
terminated = True
return obs, reward, terminated, truncated, info

Some files were not shown because too many files changed in this diff

|||||||
100:0
Loading…
Cancel
Save