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.

68 lines
2.1 KiB

  1. smg
  2. player controlledRobot
  3. [e1], [w1], [n1], [s1], [pickUp], [deliver]
  4. endplayer
  5. player adverseryRobot
  6. [e2], [w2], [n2], [s2]
  7. endplayer
  8. // (w+1)x16 - grid
  9. const int w = 2;
  10. const int width = w;
  11. const int height = 15;
  12. const int xmin = 0;
  13. const int xmax = width;
  14. const int ymin = 0;
  15. const int ymax = height;
  16. // probabilty to get stuck
  17. const double stuckProp = 1/5;
  18. const double notstuckProp = 1 - stuckProp;
  19. global move : [0..1] init 0;
  20. formula robot1BetweenShelves = !(y1=0 | y1=height);
  21. formula robot2BetweenShelves = !(y2=0 | y2=height);
  22. formula robot1AboveShelves = mod(x1, 2) = 1;
  23. formula robot1BelowShelves = mod(x1, 2) = 1;
  24. formula robot2AboveShelves = mod(x2, 2) = 1;
  25. formula robot2BelowShelves = mod(x2, 2) = 1;
  26. formula robot1OpenRow = mod(y1, 5) = 0;
  27. formula robot2OpenRow = mod(y2, 5) = 0;
  28. label "crash" = x1=x2 & y1=y2;
  29. module robot1
  30. x1 : [0..width] init width;
  31. y1 : [0..height] init 0;
  32. picked_up : bool init false;
  33. [e1] move=0 & x1<xmax & (!robot1BetweenShelves | robot1OpenRow) -> (x1'=x1+1) & (move'=1);
  34. [w1] move=0 & x1>0 & (!robot1BetweenShelves | robot1OpenRow) -> (x1'=x1-1) & (move'=1);
  35. [n1] move=0 & y1>0 & !robot1BelowShelves -> (y1'=y1-1) & (move'=1);
  36. [s1] move=0 & y1<ymax & !robot1AboveShelves -> (y1'=y1+1) & (move'=1);
  37. [pickUp] move=0 & !picked_up & x1=0 & y1=ymax -> (picked_up'=true) & (move'=1);
  38. [deliver] move=0 & picked_up & x1=width & y1=0 -> (picked_up'=false) & (move'=1);
  39. endmodule
  40. module robot2
  41. x2 : [0..width] init xmax;
  42. y2 : [0..height] init 0;
  43. [e2] move=1 & x2<xmax & (!robot2BetweenShelves | robot2OpenRow) -> notstuckProp : (x2'=x2+1) & (move'=0) + stuckProp : (move'=0);
  44. [w2] move=1 & x2>0 & (!robot2BetweenShelves | robot2OpenRow) -> notstuckProp : (x2'=x2-1) & (move'=0) + stuckProp : (move'=0);
  45. [n2] move=1 & y2>0 & !robot2BelowShelves -> notstuckProp : (y2'=y2-1) & (move'=0) + stuckProp : (move'=0);
  46. [s2] move=1 & y2<ymax & !robot2AboveShelves -> notstuckProp : (y2'=y2+1) & (move'=0) + stuckProp : (move'=0);
  47. endmodule
  48. rewards
  49. true : -1;
  50. x1=x2 & y1=y2 : -25;
  51. [deliver] true : 100;
  52. endrewards