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.

189 lines
13 KiB

7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
  1. mdp
  2. const int initY = 40;
  3. const int initX = 80;
  4. //const int maxY = 580;
  5. //const int maxY = 430;
  6. const int maxY = 200;
  7. const int minX = 10;
  8. const int maxX = 152;
  9. const int maxVel = 8;
  10. formula Gate_1 = (((42<x & x<50) | (74<x & x<82)) & 164<y & y<172);
  11. formula Gate_2 = (((72<x & x<80) | (104<x & x<112)) & 256<y & y<264);
  12. formula Gate_3 = (((80<x & x<88) | (112<x & x<120)) & 349<y & y<357);
  13. formula Gate_4 = (((54<x & x<62) | (88<x & x<96)) & 442<y & y<450);
  14. formula Gate_5 = (((80<x & x<88) | (112<x & x<120)) & 530<y & y<538);
  15. formula S_Gate_1 = (((32<x & x<60) | (64<x & x<92)) & 124<y & y<172);
  16. formula S_Gate_2 = (((62<x & x<90) | (94<x & x<132)) & 216<y & y<264);
  17. formula S_Gate_3 = (((70<x & x<98) | (102<x & x<130)) & 309<y & y<357);
  18. formula S_Gate_4 = (((44<x & x<72) | (78<x & x<106)) & 402<y & y<450);
  19. formula S_Gate_5 = (((70<x & x<98) | (102<x & x<130)) & 490<y & y<538);
  20. formula Tree_1 = ((x>=124 & x<=142) & (y>=190 & y<=200));
  21. formula Tree_2 = ((x>=32 & x<=49) & (y>=284 & y<=295));
  22. formula Tree_3 = ((x>=30 & x<=49) & (y>=317 & y<=327));
  23. formula Tree_4 = ((x>=12 & x<=30) & (y>=408 & y<=418));
  24. formula Tree_5 = ((x>=129 & x<=146) & (y>=468 & y<=480));
  25. formula Tree_6 = ((x>=140 & x<=152) & (y>=496 & y<=510));
  26. formula S_Tree_1 = ((x>=114 & x<=152) & (y>=150 & y<=200));
  27. formula S_Tree_2 = ((x>=22 & x<=59) & (y>=244 & y<=295));
  28. formula S_Tree_3 = ((x>=20 & x<=59) & (y>=277 & y<=327));
  29. formula S_Tree_4 = ((x>=2 & x<=40) & (y>=368 & y<=418));
  30. formula S_Tree_5 = ((x>=119 & x<=156) & (y>=438 & y<=480));
  31. formula S_Tree_6 = ((x>=130 & x<=162) & (y>=456 & y<=510));
  32. formula Hit_Tree = Tree_1 | Tree_2 | Tree_3 | Tree_4 | Tree_5 | Tree_6;
  33. formula Hit_Gate = Gate_1 | Gate_2 | Gate_3 | Gate_4 | Gate_5;
  34. formula S_Hit_Tree = S_Tree_1 | S_Tree_2 | S_Tree_3 | S_Tree_4 | S_Tree_5 | S_Tree_6;
  35. formula S_Hit_Gate = S_Gate_1 | S_Gate_2 | S_Gate_3 | S_Gate_4 | S_Gate_5;
  36. label "Hit_Tree" = Hit_Tree;
  37. label "Hit_Gate" = Hit_Gate;
  38. label "S_Hit_Tree" = S_Hit_Tree;
  39. label "S_Hit_Gate" = S_Hit_Gate;
  40. global move : [0..3];
  41. module skier
  42. ski_position : [1..8] init 4;
  43. reward_given: bool init false;
  44. //done: bool init false;
  45. [left] !reward_given & !Safe_1 & !Unsafe_1 & !Hit_Gate & !Hit_Tree & move=0 & ski_position>1 -> (ski_position'=ski_position-1) & (move'=1);
  46. [right] !reward_given & !Safe_1 & !Unsafe_1 & !Hit_Gate & !Hit_Tree & move=0 & ski_position<8 -> (ski_position'=ski_position+1) & (move'=1);
  47. [noop] !reward_given & !Safe_1 & !Unsafe_1 & !Hit_Gate & !Hit_Tree & move=0 -> (move'=1);
  48. //[left] !reward_given & (Safe_1 | Unsafe_1 | Hit_Tree | Hit_Gate) & move=0 & ski_position>1 -> (ski_position'=ski_position-1) & (move'=1) & (reward_given'=true);
  49. //[right] !reward_given & (Safe_1 | Unsafe_1 | Hit_Tree | Hit_Gate) & move=0 & ski_position<8 -> (ski_position'=ski_position+1) & (move'=1) & (reward_given'=true);
  50. //[noop] !reward_given & (Safe_1 | Unsafe_1 | Hit_Tree | Hit_Gate) & move=0 -> (move'=1) & (reward_given'=true);
  51. [left] !reward_given & !Safe_2 & !Unsafe_2 & !Hit_Gate & !Hit_Tree & move=0 & ski_position>1 -> (ski_position'=ski_position-1) & (move'=1);
  52. [right] !reward_given & !Safe_2 & !Unsafe_2 & !Hit_Gate & !Hit_Tree & move=0 & ski_position<8 -> (ski_position'=ski_position+1) & (move'=1);
  53. [noop] !reward_given & !Safe_2 & !Unsafe_2 & !Hit_Gate & !Hit_Tree & move=0 -> (move'=1);
  54. //[left] !reward_given & (Safe_2 | Unsafe_2 | Hit_Tree | Hit_Gate) & move=0 & ski_position>1 -> (ski_position'=ski_position-1) & (move'=1) & (reward_given'=true);
  55. //[right] !reward_given & (Safe_2 | Unsafe_2 | Hit_Tree | Hit_Gate) & move=0 & ski_position<8 -> (ski_position'=ski_position+1) & (move'=1) & (reward_given'=true);
  56. //[noop] !reward_given & (Safe_2 | Unsafe_2 | Hit_Tree | Hit_Gate) & move=0 -> (move'=1) & (reward_given'=true);
  57. [left] !reward_given & !Safe_3 & !Unsafe_3 & !Hit_Gate & !Hit_Tree & move=0 & ski_position>1 -> (ski_position'=ski_position-1) & (move'=1);
  58. [right] !reward_given & !Safe_3 & !Unsafe_3 & !Hit_Gate & !Hit_Tree & move=0 & ski_position<8 -> (ski_position'=ski_position+1) & (move'=1);
  59. [noop] !reward_given & !Safe_3 & !Unsafe_3 & !Hit_Gate & !Hit_Tree & move=0 -> (move'=1);
  60. //[left] !reward_given & (Safe_3 | Unsafe_3 | Hit_Tree | Hit_Gate) & move=0 & ski_position>1 -> (ski_position'=ski_position-1) & (move'=1) & (reward_given'=true);
  61. //[right] !reward_given & (Safe_3 | Unsafe_3 | Hit_Tree | Hit_Gate) & move=0 & ski_position<8 -> (ski_position'=ski_position+1) & (move'=1) & (reward_given'=true);
  62. //[noop] !reward_given & (Safe_3 | Unsafe_3 | Hit_Tree | Hit_Gate) & move=0 -> (move'=1) & (reward_given'=true);
  63. [left] !reward_given & !Safe_4 & !Unsafe_4 & !Hit_Gate & !Hit_Tree & move=0 & ski_position>1 -> (ski_position'=ski_position-1) & (move'=1);
  64. [right] !reward_given & !Safe_4 & !Unsafe_4 & !Hit_Gate & !Hit_Tree & move=0 & ski_position<8 -> (ski_position'=ski_position+1) & (move'=1);
  65. [noop] !reward_given & !Safe_4 & !Unsafe_4 & !Hit_Gate & !Hit_Tree & move=0 -> (move'=1);
  66. //[left] !reward_given & (Safe_4 | Unsafe_4 | Hit_Tree | Hit_Gate) & move=0 & ski_position>1 -> (ski_position'=ski_position-1) & (move'=1) & (reward_given'=true);
  67. //[right] !reward_given & (Safe_4 | Unsafe_4 | Hit_Tree | Hit_Gate) & move=0 & ski_position<8 -> (ski_position'=ski_position+1) & (move'=1) & (reward_given'=true);
  68. //[noop] !reward_given & (Safe_4 | Unsafe_4 | Hit_Tree | Hit_Gate) & move=0 -> (move'=1) & (reward_given'=true);
  69. [left] !reward_given & !Safe_5 & !Unsafe_5 & !Hit_Gate & !Hit_Tree & move=0 & ski_position>1 -> (ski_position'=ski_position-1) & (move'=1);
  70. [right] !reward_given & !Safe_5 & !Unsafe_5 & !Hit_Gate & !Hit_Tree & move=0 & ski_position<8 -> (ski_position'=ski_position+1) & (move'=1);
  71. [noop] !reward_given & !Safe_5 & !Unsafe_5 & !Hit_Gate & !Hit_Tree & move=0 -> (move'=1);
  72. //[left] !reward_given & (Safe_5 | Unsafe_5 | Hit_Tree | Hit_Gate) & move=0 & ski_position>1 -> (ski_position'=ski_position-1) & (move'=1) & (reward_given'=true);
  73. //[right] !reward_given & (Safe_5 | Unsafe_5 | Hit_Tree | Hit_Gate) & move=0 & ski_position<8 -> (ski_position'=ski_position+1) & (move'=1) & (reward_given'=true);
  74. //[noop] !reward_given & (Safe_5 | Unsafe_5 | Hit_Tree | Hit_Gate) & move=0 -> (move'=1) & (reward_given'=true);
  75. [left] !reward_given & !Safe_6 & !Unsafe_6 & !Hit_Gate & !Hit_Tree & move=0 & ski_position>1 -> (ski_position'=ski_position-1) & (move'=1);
  76. [right] !reward_given & !Safe_6 & !Unsafe_6 & !Hit_Gate & !Hit_Tree & move=0 & ski_position<8 -> (ski_position'=ski_position+1) & (move'=1);
  77. [noop] !reward_given & !Safe_6 & !Unsafe_6 & !Hit_Gate & !Hit_Tree & move=0 -> (move'=1);
  78. //[left] !reward_given & (Safe_6 | Unsafe_6 | Hit_Tree | Hit_Gate) & move=0 & ski_position>1 -> (ski_position'=ski_position-1) & (move'=1) & (reward_given'=true);
  79. //[right] !reward_given & (Safe_6 | Unsafe_6 | Hit_Tree | Hit_Gate) & move=0 & ski_position<8 -> (ski_position'=ski_position+1) & (move'=1) & (reward_given'=true);
  80. //[noop] !reward_given & (Safe_6 | Unsafe_6 | Hit_Tree | Hit_Gate) & move=0 -> (move'=1) & (reward_given'=true);
  81. [left] !reward_given & !Safe_7 & !Unsafe_7 & !Hit_Gate & !Hit_Tree & move=0 & ski_position>1 -> (ski_position'=ski_position-1) & (move'=1);
  82. [right] !reward_given & !Safe_7 & !Unsafe_7 & !Hit_Gate & !Hit_Tree & move=0 & ski_position<8 -> (ski_position'=ski_position+1) & (move'=1);
  83. [noop] !reward_given & !Safe_7 & !Unsafe_7 & !Hit_Gate & !Hit_Tree & move=0 -> (move'=1);
  84. //[left] !reward_given & (Safe_7 | Unsafe_7 | Hit_Tree | Hit_Gate) & move=0 & ski_position>1 -> (ski_position'=ski_position-1) & (move'=1) & (reward_given'=true);
  85. //[right] !reward_given & (Safe_7 | Unsafe_7 | Hit_Tree | Hit_Gate) & move=0 & ski_position<8 -> (ski_position'=ski_position+1) & (move'=1) & (reward_given'=true);
  86. //[noop] !reward_given & (Safe_7 | Unsafe_7 | Hit_Tree | Hit_Gate) & move=0 -> (move'=1) & (reward_given'=true);
  87. [left] !reward_given & !Safe_8 & !Unsafe_8 & !Hit_Gate & !Hit_Tree & move=0 & ski_position>1 -> (ski_position'=ski_position-1) & (move'=1);
  88. [right] !reward_given & !Safe_8 & !Unsafe_8 & !Hit_Gate & !Hit_Tree & move=0 & ski_position<8 -> (ski_position'=ski_position+1) & (move'=1);
  89. [noop] !reward_given & !Safe_8 & !Unsafe_8 & !Hit_Gate & !Hit_Tree & move=0 -> (move'=1);
  90. //[left] !reward_given & (Safe_8 | Unsafe_8 | Hit_Tree | Hit_Gate) & move=0 & ski_position>1 -> (ski_position'=ski_position-1) & (move'=1) & (reward_given'=true);
  91. //[right] !reward_given & (Safe_8 | Unsafe_8 | Hit_Tree | Hit_Gate) & move=0 & ski_position<8 -> (ski_position'=ski_position+1) & (move'=1) & (reward_given'=true);
  92. //[noop] !reward_given & (Safe_8 | Unsafe_8 | Hit_Tree | Hit_Gate) & move=0 -> (move'=1) & (reward_given'=true);
  93. //[left] reward_given & move=0 & ski_position>1 -> (ski_position'=ski_position-1) & (move'=1) & (done'=true);
  94. //[right] reward_given & move=0 & ski_position<8 -> (ski_position'=ski_position+1) & (move'=1) & (done'=true);
  95. //[noop] reward_given & move=0 -> (move'=1) & (done'=true);
  96. [done] !reward_given & (Hit_Tree | Hit_Gate) & move=0 -> (reward_given'=true);
  97. [done] !reward_given & Unsafe_1 & move=0 -> (reward_given'=true);
  98. [done] !reward_given & Unsafe_2 & move=0 -> (reward_given'=true);
  99. [done] !reward_given & Unsafe_3 & move=0 -> (reward_given'=true);
  100. [done] !reward_given & Unsafe_4 & move=0 -> (reward_given'=true);
  101. [done] !reward_given & Unsafe_5 & move=0 -> (reward_given'=true);
  102. [done] !reward_given & Unsafe_6 & move=0 -> (reward_given'=true);
  103. [done] !reward_given & Unsafe_7 & move=0 -> (reward_given'=true);
  104. [done] !reward_given & Unsafe_8 & move=0 -> (reward_given'=true);
  105. [done] !reward_given & Safe_1 & move=0 -> (reward_given'=true);
  106. [done] !reward_given & Safe_2 & move=0 -> (reward_given'=true);
  107. [done] !reward_given & Safe_3 & move=0 -> (reward_given'=true);
  108. [done] !reward_given & Safe_4 & move=0 -> (reward_given'=true);
  109. [done] !reward_given & Safe_5 & move=0 -> (reward_given'=true);
  110. [done] !reward_given & Safe_6 & move=0 -> (reward_given'=true);
  111. [done] !reward_given & Safe_7 & move=0 -> (reward_given'=true);
  112. [done] !reward_given & Safe_8 & move=0 -> (reward_given'=true);
  113. endmodule
  114. module updateY
  115. y : [initY..maxY] ;
  116. velocity: [0..16];
  117. standstill : [0..8] ;
  118. [update_y] move=1 & standstill>=5 -> (y'=y) & (move'=2);
  119. [update_y] move=1 & standstill<5 -> (y'=min(maxY,y+velocity)) & (move'=2);
  120. [update_y] move=2 & (ski_position=1 | ski_position = 8) & standstill>=5 -> (standstill'=min(8,standstill+1)) & (move'=3);
  121. [update_y] move=2 & (ski_position=1 | ski_position = 8) & standstill<5 -> (velocity'=max(0,velocity-4)) &(move'=3);
  122. [update_y] move=2 & (ski_position=2 | ski_position = 7) -> (velocity'=max(0 ,velocity-2)) & (standstill'=0) & (move'=3);
  123. [update_y] move=2 & (ski_position=3 | ski_position = 6) -> (velocity'=min(maxVel,velocity+2)) & (standstill'=0) & (move'=3);
  124. [update_y] move=2 & (ski_position=4 | ski_position = 5) -> (velocity'=min(maxVel,velocity+4)) & (standstill'=0) & (move'=3);
  125. endmodule
  126. module updateX
  127. x : [minX..maxX] init initX;
  128. [update_x] move=3 & standstill>=8 -> (move'=0);
  129. [update_x] move=3 & standstill<8 & (ski_position=4 | ski_position=5) -> (move'=0);
  130. [update_x] move=3 & standstill<8 & (ski_position=3) -> 0.4: (x'=max(minX,x-0)) & (move'=0) + 0.6: (x'=max(minX,x-1)) & (move'=0);
  131. [update_x] move=3 & standstill<8 & (ski_position=6) -> 0.4: (x'=min(maxX,x+0)) & (move'=0) + 0.6: (x'=min(maxX,x+1)) & (move'=0);
  132. [update_x] move=3 & standstill<8 & (ski_position=2) -> 0.3: (x'=max(minX,x-1)) & (move'=0) + 0.7: (x'=max(minX,x-2)) & (move'=0);
  133. [update_x] move=3 & standstill<8 & (ski_position=7) -> 0.3: (x'=min(maxX,x+1)) & (move'=0) + 0.7: (x'=min(maxX,x+2)) & (move'=0);
  134. [update_x] move=3 & standstill<8 & (ski_position=1) -> 0.2: (x'=max(minX,x-2)) & (move'=0) + 0.8: (x'=max(minX,x-3)) & (move'=0);
  135. [update_x] move=3 & standstill<8 & (ski_position=8) -> 0.2: (x'=min(maxX,x+2)) & (move'=0) + 0.8: (x'=min(maxX,x+3)) & (move'=0);
  136. endmodule
  137. //rewards
  138. // [left] !done & !reward_given & Hit_Tree : -100;
  139. // [left] !done & !reward_given & Hit_Gate : -100;
  140. // [left] !done & !reward_given & (Unsafe_1 | Unsafe_2 | Unsafe_3 | Unsafe_4 | Unsafe_5 | Unsafe_6 | Unsafe_7 | Unsafe_8) : -100;
  141. // [right] !done & !reward_given & Hit_Tree : -100;
  142. // [right] !done & !reward_given & Hit_Gate : -100;
  143. // [right] !done & !reward_given & (Unsafe_1 | Unsafe_2 | Unsafe_3 | Unsafe_4 | Unsafe_5 | Unsafe_6 | Unsafe_7 | Unsafe_8) : -100;
  144. // [noop] !done & !reward_given & Hit_Tree : -100;
  145. // [noop] !done & !reward_given & Hit_Gate : -100;
  146. // [noop] !done & !reward_given & (Unsafe_1 | Unsafe_2 | Unsafe_3 | Unsafe_4 | Unsafe_5 | Unsafe_6 | Unsafe_7 | Unsafe_8) : -100;
  147. //endrewards
  148. rewards
  149. [done] !reward_given & (Hit_Gate | Hit_Tree | (Unsafe_1 | Unsafe_2 | Unsafe_3 | Unsafe_4 | Unsafe_5 | Unsafe_6 | Unsafe_7 | Unsafe_8)) : -100;
  150. endrewards