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.

137 lines
6.6 KiB

6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
  1. mdp
  2. const int initY = 40;
  3. const int initX = 80;
  4. const int maxY = 580;
  5. //const int maxY = 360;
  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. formula Safe = ( (Safe_1 | Safe_2) | (Safe_3 | Safe_4) ) | ( (Safe_5 | Safe_6) | (Safe_7 | Safe_8) );
  37. formula Unsafe = ( (Unsafe_1 | Unsafe_2) | (Unsafe_3 | Unsafe_4) ) | ( (Unsafe_5 | Unsafe_6) | (Unsafe_7 | Unsafe_8) );
  38. label "Hit_Tree" = Hit_Tree;
  39. label "Hit_Gate" = Hit_Gate;
  40. label "S_Hit_Tree" = S_Hit_Tree;
  41. label "S_Hit_Gate" = S_Hit_Gate;
  42. global move : [0..3];
  43. module skier
  44. ski_position : [1..8] init 4;
  45. reward_given: bool init false;
  46. //done: bool init false;
  47. [left] !reward_given & !Safe & !Unsafe & !Hit_Gate & !Hit_Tree & move=0 & ski_position>1 -> (ski_position'=ski_position-1) & (move'=1);
  48. [right] !reward_given & !Safe & !Unsafe & !Hit_Gate & !Hit_Tree & move=0 & ski_position<8 -> (ski_position'=ski_position+1) & (move'=1);
  49. [noop] !reward_given & !Safe & !Unsafe & !Hit_Gate & !Hit_Tree & move=0 -> (move'=1);
  50. [done] !reward_given & (Hit_Tree | Hit_Gate | Safe | Unsafe) & move=0 -> (reward_given'=true);
  51. //[done] !reward_given & Unsafe_1 & move=0 -> (reward_given'=true);
  52. //[done] !reward_given & Unsafe_2 & move=0 -> (reward_given'=true);
  53. //[done] !reward_given & Unsafe_3 & move=0 -> (reward_given'=true);
  54. //[done] !reward_given & Unsafe_4 & move=0 -> (reward_given'=true);
  55. //[done] !reward_given & Unsafe_5 & move=0 -> (reward_given'=true);
  56. //[done] !reward_given & Unsafe_6 & move=0 -> (reward_given'=true);
  57. //[done] !reward_given & Unsafe_7 & move=0 -> (reward_given'=true);
  58. //[done] !reward_given & Unsafe_8 & move=0 -> (reward_given'=true);
  59. //[done] !reward_given & Safe_1 & move=0 -> (reward_given'=true);
  60. //[done] !reward_given & Safe_2 & move=0 -> (reward_given'=true);
  61. //[done] !reward_given & Safe_3 & move=0 -> (reward_given'=true);
  62. //[done] !reward_given & Safe_4 & move=0 -> (reward_given'=true);
  63. //[done] !reward_given & Safe_5 & move=0 -> (reward_given'=true);
  64. //[done] !reward_given & Safe_6 & move=0 -> (reward_given'=true);
  65. //[done] !reward_given & Safe_7 & move=0 -> (reward_given'=true);
  66. //[done] !reward_given & Safe_8 & move=0 -> (reward_given'=true);
  67. endmodule
  68. module updateY
  69. y : [initY..maxY] ;
  70. velocity: [0..16];
  71. standstill : [0..8] ;
  72. [update_y] move=1 & standstill>=5 -> (y'=y) & (move'=2);
  73. [update_y] move=1 & standstill<5 -> (y'=min(maxY,y+velocity)) & (move'=2);
  74. [update_y] move=2 & (ski_position=1 | ski_position = 8) & standstill>=5 -> (standstill'=min(8,standstill+1)) & (move'=3);
  75. [update_y] move=2 & (ski_position=1 | ski_position = 8) & standstill<5 -> (velocity'=max(0,velocity-4)) &(move'=3);
  76. [update_y] move=2 & (ski_position=2 | ski_position = 7) -> (velocity'=max(0 ,velocity-2)) & (standstill'=0) & (move'=3);
  77. [update_y] move=2 & (ski_position=3 | ski_position = 6) -> (velocity'=min(maxVel,velocity+2)) & (standstill'=0) & (move'=3);
  78. [update_y] move=2 & (ski_position=4 | ski_position = 5) -> (velocity'=min(maxVel,velocity+4)) & (standstill'=0) & (move'=3);
  79. endmodule
  80. module updateX
  81. x : [minX..maxX] init initX;
  82. [update_x] move=3 & standstill>=8 -> (move'=0);
  83. [update_x] move=3 & standstill<8 & (ski_position=4 | ski_position=5) -> (move'=0);
  84. [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);
  85. [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);
  86. [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);
  87. [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);
  88. [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);
  89. [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);
  90. endmodule
  91. //rewards
  92. // [left] !done & !reward_given & Hit_Tree : -100;
  93. // [left] !done & !reward_given & Hit_Gate : -100;
  94. // [left] !done & !reward_given & (Unsafe_1 | Unsafe_2 | Unsafe_3 | Unsafe_4 | Unsafe_5 | Unsafe_6 | Unsafe_7 | Unsafe_8) : -100;
  95. // [right] !done & !reward_given & Hit_Tree : -100;
  96. // [right] !done & !reward_given & Hit_Gate : -100;
  97. // [right] !done & !reward_given & (Unsafe_1 | Unsafe_2 | Unsafe_3 | Unsafe_4 | Unsafe_5 | Unsafe_6 | Unsafe_7 | Unsafe_8) : -100;
  98. // [noop] !done & !reward_given & Hit_Tree : -100;
  99. // [noop] !done & !reward_given & Hit_Gate : -100;
  100. // [noop] !done & !reward_given & (Unsafe_1 | Unsafe_2 | Unsafe_3 | Unsafe_4 | Unsafe_5 | Unsafe_6 | Unsafe_7 | Unsafe_8) : -100;
  101. //endrewards
  102. rewards
  103. [done] !reward_given & (Hit_Gate | Hit_Tree | Unsafe_1 | Unsafe_2 | Unsafe_3 | Unsafe_4 | Unsafe_5 | Unsafe_6 | Unsafe_7 | Unsafe_8) : -100;
  104. endrewards