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.

58 lines
1.8 KiB

  1. smg
  2. player shieldedRobot
  3. [e1], [w1], [n1], [s1]
  4. endplayer
  5. player adverseryRobot
  6. [e2], [w2], [n2], [s2]
  7. endplayer
  8. // (w+1)x16 - grid
  9. //const int w;
  10. const int width = 6;
  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 0;
  31. y1 : [0..height] init ymax;
  32. [e1] move=0 & x1<xmax & (!robot1BetweenShelves | robot1OpenRow) -> (x1'=x1+1) & (move'=1);
  33. [w1] move=0 & x1>0 & (!robot1BetweenShelves | robot1OpenRow) -> (x1'=x1-1) & (move'=1);
  34. [n1] move=0 & y1>0 & !robot1BelowShelves -> (y1'=y1-1) & (move'=1);
  35. [s1] move=0 & y1<ymax & !robot1AboveShelves -> (y1'=y1+1) & (move'=1);
  36. endmodule
  37. module robot2
  38. x2 : [0..width] init xmax;
  39. y2 : [0..height] init 0;
  40. [e2] move=1 & x2<xmax & (!robot2BetweenShelves | robot2OpenRow) -> notstuckProp : (x2'=x2+1) & (move'=0) + stuckProp : (move'=0);
  41. [w2] move=1 & x2>0 & (!robot2BetweenShelves | robot2OpenRow) -> notstuckProp : (x2'=x2-1) & (move'=0) + stuckProp : (move'=0);
  42. [n2] move=1 & y2>0 & !robot2BelowShelves -> notstuckProp : (y2'=y2-1) & (move'=0) + stuckProp : (move'=0);
  43. [s2] move=1 & y2<ymax & !robot2AboveShelves -> notstuckProp : (y2'=y2+1) & (move'=0) + stuckProp : (move'=0);
  44. endmodule