The source code and dockerfile for the GSW2024 AI Lab.
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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

71 lines
3.0 KiB

2 months ago
  1. mdp
  2. const int WIDTH = 5;
  3. const int HEIGHT = 5;
  4. const int XINIT = 3;
  5. const int YINIT = 1;
  6. const double pAttack = 1/10;
  7. formula left_of_gold = x=2 & y=5;
  8. formula right_of_gold = x=4 & y=5;
  9. formula below_of_gold = (x=3 & y=4);
  10. formula above_of_gold = false;
  11. formula left_of_gem = (x=4 & y=4);
  12. formula right_of_gem = false;
  13. formula below_of_gem = (x=5 & y=3);
  14. formula above_of_gem = (x=5 & y=5);
  15. formula left_of_home = x=2 & y=1;
  16. formula right_of_home = x=4 & y=1;
  17. formula above_of_home = x=3 & y=2;
  18. formula below_of_home = false;
  19. formula left_of_enemy = (x=3 & y=5) | (x=2 & y=4);
  20. formula right_of_enemy = (x=5 & y=5) | (x=4 & y=4);
  21. formula above_of_enemy = x=3 & y=5;
  22. formula below_of_enemy = (x=3 & y=3) | (x=4 & y=4);
  23. module robot
  24. gold : bool init false;
  25. gem : bool init false;
  26. attacked : bool init false;
  27. x : [1..WIDTH] init XINIT;
  28. y : [1..HEIGHT] init YINIT;
  29. [right] !left_of_enemy & x<WIDTH -> (attacked'=false) & (x'=x+1) & (gold' = (gold & !left_of_home) | left_of_gold) & (gem' = (gem & !left_of_home) | left_of_gem);
  30. [left] !right_of_enemy & x>1 -> (attacked'=false) & (x'=x-1) & (gold' = (gold & !right_of_home) | right_of_gold) & (gem' = (gem & !right_of_home) | right_of_gem);
  31. [top] !below_of_enemy & y<HEIGHT -> (attacked'=false) & (y'=y+1) & (gold' = (gold & !below_of_home) | below_of_gold) & (gem' = (gem & !below_of_home) | below_of_gem);
  32. [down] !above_of_enemy & y>1 -> (attacked'=false) & (y'=y-1) & (gold' = (gold & !above_of_home) | above_of_gold) & (gem' = (gem & !above_of_home) | above_of_gem);
  33. [right] left_of_enemy & x<WIDTH -> pAttack : (attacked'=true) & (x'=XINIT) & (y'=YINIT) & (gold'=false) & (gem'=false) + (1-pAttack) : (attacked'=false) & (x'=x+1) & (gold' = (gold & !left_of_home) | left_of_gold) & (gem' = (gem & !left_of_home) | left_of_gem);
  34. [left] right_of_enemy & x>1 -> pAttack : (attacked'=true) & (x'=XINIT) & (y'=YINIT) & (gold'=false) & (gem'=false) + (1-pAttack) : (attacked'=false) & (x'=x-1) & (gold' = (gold & !right_of_home) | right_of_gold) & (gem' = (gem & !right_of_home) | right_of_gem);
  35. [top] below_of_enemy & y<HEIGHT -> pAttack : (attacked'=true) & (x'=XINIT) & (y'=YINIT) & (gold'=false) & (gem'=false) + (1-pAttack) : (attacked'=false) & (y'=y+1) & (gold' = (gold & !below_of_home) | below_of_gold) & (gem' = (gem & !below_of_home) | below_of_gem);
  36. [down] above_of_enemy & y>1 -> pAttack : (attacked'=true) & (x'=XINIT) & (y'=YINIT) & (gold'=false) & (gem'=false) + (1-pAttack) : (attacked'=false) & (y'=y-1) & (gold' = (gold & !above_of_home) | above_of_gold) & (gem' = (gem & !above_of_home) | above_of_gem);
  37. endmodule
  38. rewards "attacks"
  39. attacked : 1;
  40. endrewards
  41. rewards "steps"
  42. [left] true : 1;
  43. [right] true : 1;
  44. [top] true : 1;
  45. [down] true : 1;
  46. endrewards
  47. rewards "gold"
  48. [right] left_of_home & gold : 1;
  49. [left] right_of_home & gold : 1;
  50. [top] below_of_home & gold : 1;
  51. [down] above_of_home & gold : 1;
  52. endrewards
  53. rewards "gem"
  54. [right] left_of_home & gem : 1;
  55. [left] right_of_home & gem : 1;
  56. [top] below_of_home & gem : 1;
  57. [down] above_of_home & gem: 1;
  58. endrewards