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

98 lines
2.8 KiB

2 months ago
  1. pomdp
  2. observables
  3. start, fuel
  4. endobservables
  5. const int N;
  6. const int fuelCAP = N-1;
  7. const int axMAX = N;
  8. const int ayMAX = N;
  9. const int axMIN = 0;
  10. const int ayMIN = 0;
  11. const double slippery = 0.4;
  12. const int ob1x = axMAX-1;
  13. const int ob1y = ayMAX-1;
  14. const int rf1x = axMIN;
  15. const int rf1y = ayMIN;
  16. const int rf2x = axMIN + ceil((axMAX - axMIN) / 3);
  17. const int rf2y = ayMIN + ceil((ayMAX - ayMIN) / 3);
  18. const int rf3x = axMIN + floor(2 * (axMAX - axMIN) / 3);
  19. const int rf3y = ayMIN + floor(2 * (ayMAX - ayMIN) / 3);
  20. formula northenabled = ax != axMIN;
  21. formula southenabled = ax != axMAX;
  22. formula westenabled = ay != ayMIN;
  23. formula eastenabled = ay != ayMAX;
  24. observable "cangonorth" = northenabled;
  25. observable "cangosouth" = southenabled;
  26. observable "cangowest" = westenabled;
  27. observable "cangoeast" = eastenabled;
  28. formula done = start & ax = axMAX & ay = ayMAX;
  29. observable "amdone" = done;
  30. formula crash = (ax = ob1x & ay = ob1y);
  31. observable "hascrash" = crash;
  32. formula atStation = (ax = rf1x & ay = rf1y) | (ax = rf2x & ay = rf2y) | (ax = rf3x & ay = rf3y);
  33. formula canRefuel = atStation & fuel < fuelCAP;
  34. observable "refuelAllowed" = canRefuel;
  35. module master
  36. start : bool init false;
  37. [placement] !start -> (start'=true);
  38. [north] start & !done -> true;
  39. [south] start & !done -> true;
  40. [east] start & !done-> true;
  41. [west] start & !done -> true;
  42. endmodule
  43. module tank
  44. fuel : [0..fuelCAP] init fuelCAP;
  45. [refuel] canRefuel -> 1:(fuel'=fuelCAP);
  46. [north] fuel > 0 & !canRefuel -> 1:(fuel'=fuel-1);
  47. [south] fuel > 0 & !canRefuel -> 1:(fuel'=fuel-1);
  48. [east] fuel > 0 & !canRefuel -> 1:(fuel'=fuel-1);
  49. [west] fuel > 0 & !canRefuel -> 1:(fuel'=fuel-1);
  50. [empty] fuel = 0 & !canRefuel -> 1:(fuel'=0);
  51. endmodule
  52. module alice
  53. ax : [axMIN..axMAX] init 0;
  54. ay : [ayMIN..ayMAX] init 0;
  55. [placement] true -> 1: (ax'=0) & (ay'=0); //+ 1/4: (ax'=1) & (ay'=1) + 1/4: (ax'=2) & (ay'=1) + 1/4: (ax'=1) & (ay'=3);
  56. [west] northenabled -> (1-slippery): (ax'=max(ax-1,axMIN)) + slippery: (ax'=max(ax-2,axMIN));
  57. [east] southenabled -> (1-slippery): (ax'=min(ax+1,axMAX)) + slippery: (ax'=min(ax+2,axMAX));
  58. [south] eastenabled -> (1-slippery): (ay'=min(ay+1,ayMAX)) + slippery: (ay'=min(ay+2,ayMAX));
  59. [north] westenabled -> (1-slippery): (ay'=max(ay-1,ayMIN)) + slippery: (ay'=max(ay-2,ayMIN));
  60. endmodule
  61. rewards "steps"
  62. [north] true : 1;
  63. [south] true : 1;
  64. [west] true : 1;
  65. [east] true : 1;
  66. endrewards
  67. rewards "refuels"
  68. [refuel] true : 1;
  69. endrewards
  70. rewards "costs"
  71. [north] true : 1;
  72. [south] true : 1;
  73. [west] true : 1;
  74. [east] true : 1;
  75. [refuel] true : 3;
  76. endrewards
  77. label "goal" = done;
  78. label "traps" = crash;
  79. label "stationvisit" = atStation;
  80. label "notbad" = !crash & (fuel > 0 | canRefuel);