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.

71 lines
3.6 KiB

  1. mdp
  2. const int initY = 40;
  3. const int initX = 80;
  4. const int maxY = 240;
  5. const int minX = 12;
  6. const int maxX = 147;
  7. formula HitTree = (122<x & x<139) & (220<y & y=232);
  8. formula HitGate = ((x=51 | x=79) & y=164);
  9. formula PassedGates = (158<y & y<165 & 51<x & x<79);
  10. global move : [0..3] init 0;
  11. module skier
  12. ski_position : [1..14] init 8;
  13. done : bool init false;
  14. [left] !done & move=0 & ski_position>1 -> (ski_position'=ski_position-1) & (move'=1) & (done'=(PassedGates|HitTree|HitGate));
  15. [right] !done & move=0 & ski_position<14 -> (ski_position'=ski_position+1) & (move'=1) & (done'=(PassedGates|HitTree|HitGate));
  16. [noop] !done & move=0 -> (move'=1) & (done'=(PassedGates|HitTree|HitGate));
  17. [left] done & move=0 & ski_position>1 -> (ski_position'=ski_position-1) & (move'=1);
  18. [right] done & move=0 & ski_position<14 -> (ski_position'=ski_position+1) & (move'=1);
  19. [noop] done & move=0 -> (move'=1);
  20. endmodule
  21. module updateY
  22. y : [initY..maxY] init initY;
  23. standstill : [0..8] init 0;
  24. [update_y] move=1 & (ski_position=1 | ski_position = 14) & standstill>=5 -> (y'=y) & (standstill'=min(8,standstill+1)) & (move'=2);
  25. [update_y] move=1 & (ski_position=1 | ski_position = 14) & standstill<5 -> (y'=min(maxY,y+4)) & (standstill'=min(8,standstill+1)) & (move'=2);
  26. [update_y] move=1 & (ski_position=2 | ski_position = 3 | ski_position = 12 | ski_position = 13) -> (y'=min(maxY,y+8)) & (standstill'=0) & (move'=2);
  27. [update_y] move=1 & (ski_position=4 | ski_position = 5 | ski_position = 10 | ski_position = 11) -> (y'=min(maxY,y+12)) & (standstill'=0) & (move'=2);
  28. [update_y] move=1 & (ski_position=6 | ski_position = 7 | ski_position = 8 | ski_position = 9) -> (y'=min(maxY,y+16)) & (standstill'=0) & (move'=2);
  29. endmodule
  30. module updateX
  31. x : [minX..maxX] init initX;
  32. [update_x] move=2 & standstill>=8 -> (move'=0);
  33. [update_x] move=2 & standstill<8 & (ski_position=7 | ski_position=8) -> (move'=0);
  34. [update_x] move=2 & standstill<8 & ski_position=6 -> 0.1: (x'=max(minX,x-3)) + 0.7: (x'=max(minX,x-4)) + 0.2: (x'=max(minX,x-5)) & (move'=0);
  35. [update_x] move=2 & standstill<8 & ski_position=9 -> 0.1: (x'=min(maxX,x+3)) + 0.7: (x'=min(maxX,x+4)) + 0.2: (x'=min(maxX,x+5)) & (move'=0);
  36. [update_x] move=2 & standstill<8 & (ski_position=4 | ski_position=5) -> 0.1: (x'=max(minX,x-5)) + 0.7: (x'=max(minX,x-6)) + 0.2: (x'=max(minX,x-7)) & (move'=0);
  37. [update_x] move=2 & standstill<8 & (ski_position=10 | ski_position=11) -> 0.1: (x'=min(maxX,x+5)) + 0.7: (x'=min(maxX,x+6)) + 0.2: (x'=min(maxX,x+7)) & (move'=0);
  38. [update_x] move=2 & standstill<8 & (ski_position=2 | ski_position=3) -> 0.1: (x'=max(minX,x-5)) + 0.7: (x'=max(minX,x-6)) + 0.2: (x'=max(minX,x-7)) & (move'=0);
  39. [update_x] move=2 & standstill<8 & (ski_position=12 | ski_position=13) -> 0.1: (x'=min(maxX,x+5)) + 0.7: (x'=min(maxX,x+6)) + 0.2: (x'=min(maxX,x+7)) & (move'=0);
  40. [update_x] move=2 & standstill<8 & (ski_position=1) -> 0.1: (x'=max(minX,x-0)) + 0.7: (x'=max(minX,x-2)) + 0.2: (x'=max(minX,x-3)) & (move'=0);
  41. [update_x] move=2 & standstill<8 & (ski_position=14) -> 0.1: (x'=min(maxX,x+0)) + 0.7: (x'=min(maxX,x+2)) + 0.2: (x'=min(maxX,x+3)) & (move'=0);
  42. endmodule
  43. rewards
  44. [left] !done & PassedGates : 100;
  45. [right] !done & PassedGates : 100;
  46. [noop] !done & PassedGates : 100;
  47. [left] !done & (HitTree) : -200;
  48. [right] !done & (HitTree) : -200;
  49. [noop] !done & (HitTree) : -200;
  50. [left] !done & (HitGate) : -150;
  51. [right] !done & (HitGate) : -150;
  52. [noop] !done & (HitGate) : -150;
  53. endrewards