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.

77 lines
1.3 KiB

  1. function herman() {
  2. int x1 := 0;
  3. int x2 := 0;
  4. int x3 := 0;
  5. int x4 := 0;
  6. int x5 := 0;
  7. int x6 := 0;
  8. int x7 := 0;
  9. int oldx1 := 0;
  10. int oldx2 := 0;
  11. int oldx3 := 0;
  12. int oldx4 := 0;
  13. int oldx5 := 0;
  14. int oldx6 := 0;
  15. int oldx7 := 0;
  16. {x1 := 0;} [0.5] {x1 := 1;}
  17. {x2 := 0;} [0.5] {x2 := 1;}
  18. {x3 := 0;} [0.5] {x3 := 1;}
  19. {x4 := 0;} [0.5] {x4 := 1;}
  20. {x5 := 0;} [0.5] {x5 := 1;}
  21. {x6 := 0;} [0.5] {x6 := 1;}
  22. {x7 := 0;} [0.5] {x7 := 1;}
  23. // finds a ring configuration with exactly one token in the ring.
  24. while((x1 + x2 + x3 + x4 + x5 + x6 + x7) != 1) {
  25. oldx1 := x1;
  26. oldx2 := x2;
  27. oldx3 := x3;
  28. oldx4 := x4;
  29. oldx5 := x5;
  30. oldx6 := x6;
  31. oldx7 := x7;
  32. if(x1 = oldx7) {
  33. {x1 := 0;} [0.5] {x1 := 1;}
  34. } else {
  35. x1 := oldx7;
  36. }
  37. oldx7 := 0;
  38. if(x2 = oldx1) {
  39. {x2 := 0;} [0.5] {x2 := 1;}
  40. } else {
  41. x2 := oldx1;
  42. }
  43. oldx1 := 0;
  44. if(x3 = oldx2) {
  45. {x3 := 0;} [0.5] {x3 := 1;}
  46. } else {
  47. x3 := oldx2;
  48. }
  49. oldx2 := 0;
  50. if(x4 = oldx3) {
  51. {x4 := 0;} [0.5] {x4 := 1;}
  52. } else {
  53. x4 := oldx3;
  54. }
  55. oldx3 := 0;
  56. if(x5 = oldx4) {
  57. {x5 := 0;} [0.5] {x5 := 1;}
  58. } else {
  59. x5 := oldx4;
  60. }
  61. oldx4 := 0;
  62. if(x6 = oldx5) {
  63. {x6 := 0;} [0.5] {x6 := 1;}
  64. } else {
  65. x6 := oldx5;
  66. }
  67. oldx5 := 0;
  68. if(x7 = oldx6) {
  69. {x7 := 0;} [0.5] {x7 := 1;}
  70. } else {
  71. x7 := oldx6;
  72. }
  73. oldx6 := 0;
  74. }
  75. }