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.

33 lines
667 B

  1. function crowds(double PF, double bad) {
  2. int delivered := 0;
  3. int lastSender := 0;
  4. int remainingRuns := 5;
  5. int observeSender := 0;
  6. int observeOther := 0;
  7. while(remainingRuns > 0) {
  8. while(delivered = 0) {
  9. {
  10. if(lastSender = 0) {
  11. observeSender := observeSender + 1;
  12. } else {
  13. observeOther := observeOther + 1;
  14. }
  15. lastSender := 0;
  16. delivered := 1;
  17. } [bad] {
  18. { lastSender:=0; } [1/3] { lastSender := 1; }
  19. }
  20. [PF]
  21. {
  22. lastSender := 0;
  23. // When not forwarding, the message is delivered here.
  24. delivered := 1;
  25. }
  26. }
  27. }
  28. delivered := 0;
  29. // Set up new run.
  30. remainingRuns := remainingRuns - 1;
  31. }
  32. }