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.

73 lines
2.4 KiB

  1. smg
  2. player controller
  3. cont
  4. endplayer
  5. player shield
  6. [reduceNS_Shield], [reduceEW_Shield], [reduceNS_ShieldDev], [reduceEW_ShieldDev]
  7. endplayer
  8. player environment
  9. env
  10. endplayer
  11. global move : [0..2];
  12. const int lmax = 1;
  13. global N : [0..lmax];
  14. global E : [0..lmax];
  15. global S : [0..lmax];
  16. global W : [0..lmax];
  17. module env
  18. [] move=0 -> 1/8 : (N'=min(lmax,N+1)) & (move'=1) +
  19. 1/8 : (S'=min(lmax,S+1)) & (move'=1) +
  20. 1/8 : (E'=min(lmax,E+1)) & (move'=1) +
  21. 1/8 : (W'=min(lmax,W+1)) & (move'=1) +
  22. 7/120 : (N'=min(lmax,N+1)) & (S'=min(lmax,S+1)) & (move'=1) +
  23. 7/120 : (S'=min(lmax,S+1)) & (W'=min(lmax,W+1)) & (move'=1) +
  24. 7/120 : (E'=min(lmax,E+1)) & (N'=min(lmax,N+1)) & (move'=1) +
  25. 7/120 : (W'=min(lmax,W+1)) & (N'=min(lmax,N+1)) & (move'=1) +
  26. 7/120 : (E'=min(lmax,E+1)) & (S'=min(lmax,S+1)) & (move'=1) +
  27. 7/120 : (W'=min(lmax,W+1)) & (S'=min(lmax,S+1)) & (move'=1) +
  28. 3/120 : (E'=min(lmax,E+1)) & (N'=min(lmax,N+1)) & (W'=min(lmax,W+1)) & (move'=1) +
  29. 3/120 : (W'=min(lmax,W+1)) & (N'=min(lmax,N+1)) & (E'=min(lmax,E+1)) & (move'=1) +
  30. 3/120 : (E'=min(lmax,E+1)) & (S'=min(lmax,S+1)) & (W'=min(lmax,W+1)) & (move'=1) +
  31. 3/120 : (W'=min(lmax,W+1)) & (S'=min(lmax,S+1)) & (N'=min(lmax,N+1)) & (move'=1) +
  32. 6/120 : (W'=min(lmax,W+1)) & (S'=min(lmax,S+1)) & (E'=min(lmax,E+1)) & (N'=min(lmax,N+1)) & (move'=1);
  33. endmodule
  34. module cont
  35. action : [0..1];
  36. [] move=1 -> (action'=0) & (move'=2);
  37. [] move=1 -> (action'=1) & (move'=2);
  38. endmodule
  39. module sh
  40. [reduceNS_Shield] move=2 & action=0 -> (N'=max(0,N-1)) & (S'=max(0,S-1)) & (move'=0);
  41. [reduceEW_Shield] move=2 & action=1 -> (W'=max(0,W-1)) & (E'=max(0,E-1)) & (move'=0);
  42. [reduceNS_ShieldDev] move=2 & action=1 -> (N'=max(0,N-1)) & (S'=max(0,S-1)) & (move'=0);
  43. [reduceEW_ShieldDev] move=2 & action=0 -> (W'=max(0,W-1)) & (E'=max(0,E-1)) & (move'=0);
  44. endmodule
  45. formula diff = pow(pow((N+S)-(E+W),2),0.5);
  46. rewards "difference"
  47. true : diff;
  48. endrewards
  49. const double lambda = 0.8;
  50. const double interference = 2 * lmax;
  51. rewards "differenceWithInterferenceCost"
  52. [reduceNS_Shield] true : lambda * diff;
  53. [reduceEW_Shield] true : lambda * diff;
  54. [reduceNS_ShieldDev] true : lambda * diff + (1 - lambda) * interference;
  55. [reduceEW_ShieldDev] true : lambda * diff + (1 - lambda) * interference;
  56. endrewards