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.

48 lines
1.6 KiB

  1. // Variation to Knuth's model of a fair die using only fair coins
  2. mdp
  3. module die
  4. // local state
  5. s : [0..7] init 0;
  6. // value of the dice
  7. d : [0..6] init 0;
  8. [fair] s=0 -> 0.5 : (s'=1) + 0.5 : (s'=2);
  9. [ufair1] s=0 -> 0.6 : (s'=1) + 0.4 : (s'=2);
  10. [ufair2] s=0 -> 0.7 : (s'=1) + 0.3 : (s'=2);
  11. [fair] s=1 -> 0.5 : (s'=3) + 0.5 : (s'=4);
  12. [ufair1] s=1 -> 0.6 : (s'=3) + 0.4 : (s'=4);
  13. [ufair2] s=1 -> 0.7 : (s'=3) + 0.3 : (s'=4);
  14. [fair] s=2 -> 0.5 : (s'=5) + 0.5 : (s'=6);
  15. [ufair1] s=2 -> 0.6 : (s'=5) + 0.4 : (s'=6);
  16. [ufair2] s=2 -> 0.7 : (s'=5) + 0.3 : (s'=6);
  17. [fair] s=3 -> 0.5 : (s'=1) + 0.5 : (s'=7) & (d'=1);
  18. [ufair1] s=3 -> 0.6 : (s'=1) + 0.4 : (s'=7) & (d'=1);
  19. [ufair2] s=3 -> 0.7 : (s'=1) + 0.3 : (s'=7) & (d'=1);
  20. [fair] s=4 -> 0.5 : (s'=7) & (d'=2) + 0.5 : (s'=7) & (d'=3);
  21. [ufair1] s=4 -> 0.6 : (s'=7) & (d'=2) + 0.4 : (s'=7) & (d'=3);
  22. [ufair2] s=4 -> 0.7 : (s'=7) & (d'=2) + 0.3 : (s'=7) & (d'=3);
  23. [fair] s=5 -> 0.5 : (s'=7) & (d'=4) + 0.5 : (s'=7) & (d'=5);
  24. [ufair1] s=5 -> 0.6 : (s'=7) & (d'=4) + 0.4 : (s'=7) & (d'=5);
  25. [ufair2] s=5 -> 0.7 : (s'=7) & (d'=4) + 0.3 : (s'=7) & (d'=5);
  26. [fair] s=6 -> 0.5 : (s'=2) + 0.5 : (s'=7) & (d'=6);
  27. [ufair1] s=6 -> 0.6 : (s'=2) + 0.4 : (s'=7) & (d'=6);
  28. [ufair2] s=6 -> 0.7 : (s'=2) + 0.3 : (s'=7) & (d'=6);
  29. [] s=7 -> 1: (s'=7);
  30. endmodule
  31. rewards "coin_flips"
  32. [fair] s<7 : 1;
  33. [ufair1] s<7 : 1;
  34. [ufair2] s<7 : 1;
  35. endrewards
  36. label "one" = s=7&d=1;
  37. label "two" = s=7&d=2;
  38. label "three" = s=7&d=3;
  39. label "four" = s=7&d=4;
  40. label "five" = s=7&d=5;
  41. label "six" = s=7&d=6;
  42. label "done" = s=7;