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.

85 lines
3.5 KiB

  1. mdp
  2. const int initY = 40;
  3. const int initX = 80;
  4. //const int maxY = 580;
  5. const int maxY = 300;
  6. const int minX = 10;
  7. const int maxX = 152;
  8. const int maxVel = 8;
  9. formula Gate_1 = (((42<x & x<50) | (74<x & x<82)) & 164<y & y<172);
  10. formula Gate_2 = (((72<x & x<80) | (104<x & x<112)) & 256<y & y<264);
  11. formula Gate_3 = (((80<x & x<88) | (112<x & x<120)) & 349<y & y<357);
  12. formula Gate_4 = (((54<x & x<62) | (88<x & x<96)) & 442<y & y<450);
  13. formula Gate_5 = (((80<x & x<88) | (112<x & x<120)) & 530<y & y<538);
  14. formula Tree_1 = ((x>=124 & x<=142) & (y>=190 & y<=200));
  15. formula Tree_2 = ((x>=32 & x<=49) & (y>=284 & y<=295));
  16. formula Tree_3 = ((x>=30 & x<=49) & (y>=317 & y<=327));
  17. formula Tree_4 = ((x>=12 & x<=30) & (y>=408 & y<=418));
  18. formula Tree_5 = ((x>=129 & x<=146) & (y>=468 & y<=480));
  19. formula Tree_6 = ((x>=140 & x<=152) & (y>=496 & y<=510));
  20. formula Hit_Tree = Tree_1 | Tree_2 | Tree_3 | Tree_4 | Tree_5 | Tree_6;
  21. formula Hit_Gate = Gate_1 | Gate_2 | Gate_3 | Gate_4 | Gate_5;
  22. label "Hit_Tree" = Hit_Tree;
  23. label "Hit_Gate" = Hit_Gate;
  24. global move : [0..3];
  25. module skier
  26. ski_position : [1..8] init 4;
  27. done : bool init false;
  28. [left] !done & !Safe & !Unsafe & !Hit_Gate & !Hit_Tree & move=0 & ski_position>1 -> (ski_position'=ski_position-1) & (move'=1);
  29. [right] !done & !Safe & !Unsafe & !Hit_Gate & !Hit_Tree & move=0 & ski_position<8 -> (ski_position'=ski_position+1) & (move'=1);
  30. [noop] !done & !Safe & !Unsafe & !Hit_Gate & !Hit_Tree & move=0 -> (move'=1);
  31. [done] move=0 & (Safe | Unsafe | Hit_Tree | Hit_Gate) -> (done'=true);
  32. endmodule
  33. module updateY
  34. y : [initY..maxY] ;
  35. velocity: [0..16];
  36. standstill : [0..8] ;
  37. [update_y] move=1 & standstill>=5 -> (y'=y) & (move'=2);
  38. [update_y] move=1 & standstill<5 -> (y'=min(maxY,y+velocity)) & (move'=2);
  39. [update_y] move=2 & (ski_position=1 | ski_position = 8) & standstill>=5 -> (standstill'=min(8,standstill+1)) & (move'=3);
  40. [update_y] move=2 & (ski_position=1 | ski_position = 8) & standstill<5 -> (velocity'=max(0,velocity-4)) &(move'=3);
  41. [update_y] move=2 & (ski_position=2 | ski_position = 7) -> (velocity'=max(0 ,velocity-2)) & (standstill'=0) & (move'=3);
  42. [update_y] move=2 & (ski_position=3 | ski_position = 6) -> (velocity'=min(maxVel,velocity+2)) & (standstill'=0) & (move'=3);
  43. [update_y] move=2 & (ski_position=4 | ski_position = 5) -> (velocity'=min(maxVel,velocity+4)) & (standstill'=0) & (move'=3);
  44. endmodule
  45. module updateX
  46. x : [minX..maxX] init initX;
  47. [update_x] move=3 & standstill>=8 -> (move'=0);
  48. [update_x] move=3 & standstill<8 & (ski_position=4 | ski_position=5) -> (move'=0);
  49. [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);
  50. [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);
  51. [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);
  52. [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);
  53. [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);
  54. [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);
  55. endmodule
  56. rewards
  57. [done] !done & Hit_Tree : -100;
  58. [done] !done & Hit_Gate : -100;
  59. [done] !done & Unsafe : -100;
  60. endrewards