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.

138 lines
2.4 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 x8 := 0;
  10. int x9 := 0;
  11. int x10 := 0;
  12. int x11 := 0;
  13. int x12 := 0;
  14. int x13 := 0;
  15. int oldx1 := 0;
  16. int oldx2 := 0;
  17. int oldx3 := 0;
  18. int oldx4 := 0;
  19. int oldx5 := 0;
  20. int oldx6 := 0;
  21. int oldx7 := 0;
  22. int oldx8 := 0;
  23. int oldx9 := 0;
  24. int oldx10 := 0;
  25. int oldx11 := 0;
  26. int oldx12 := 0;
  27. int oldx13 := 0;
  28. // determine starting token setup on the ring.
  29. {x1 := 0;} [] {x1 := 1;}
  30. {x2 := 0;} [] {x2 := 1;}
  31. {x3 := 0;} [] {x3 := 1;}
  32. {x4 := 0;} [] {x4 := 1;}
  33. {x5 := 0;} [] {x5 := 1;}
  34. {x6 := 0;} [] {x6 := 1;}
  35. {x7 := 0;} [] {x7 := 1;}
  36. {x8 := 0;} [] {x8 := 1;}
  37. {x9 := 0;} [] {x9 := 1;}
  38. {x10 := 0;} [] {x10 := 1;}
  39. {x11 := 0;} [] {x11 := 1;}
  40. {x12 := 0;} [] {x12 := 1;}
  41. {x13 := 0;} [] {x13 := 1;}
  42. // finds a ring configuration with exactly one token in the ring.
  43. while((x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13) != 1) {
  44. oldx1 := x1;
  45. oldx2 := x2;
  46. oldx3 := x3;
  47. oldx4 := x4;
  48. oldx5 := x5;
  49. oldx6 := x6;
  50. oldx7 := x7;
  51. oldx8 := x8;
  52. oldx9 := x9;
  53. oldx10 := x10;
  54. oldx11 := x11;
  55. oldx12 := x12;
  56. oldx13 := x13;
  57. if(x1 = oldx13) {
  58. {x1 := 0;} [0.5] {x1 := 1;}
  59. } else {
  60. x1 := oldx13;
  61. }
  62. oldx13 := 0;
  63. if(x2 = oldx1) {
  64. {x2 := 0;} [0.5] {x2 := 1;}
  65. } else {
  66. x2 := oldx1;
  67. }
  68. oldx1 := 0;
  69. if(x3 = oldx2) {
  70. {x3 := 0;} [0.5] {x3 := 1;}
  71. } else {
  72. x3 := oldx2;
  73. }
  74. oldx2 := 0;
  75. if(x4 = oldx3) {
  76. {x4 := 0;} [0.5] {x4 := 1;}
  77. } else {
  78. x4 := oldx3;
  79. }
  80. oldx3 := 0;
  81. if(x5 = oldx4) {
  82. {x5 := 0;} [0.5] {x5 := 1;}
  83. } else {
  84. x5 := oldx4;
  85. }
  86. oldx4 := 0;
  87. if(x6 = oldx5) {
  88. {x6 := 0;} [0.5] {x6 := 1;}
  89. } else {
  90. x6 := oldx5;
  91. }
  92. oldx5 := 0;
  93. if(x7 = oldx6) {
  94. {x7 := 0;} [0.5] {x7 := 1;}
  95. } else {
  96. x7 := oldx6;
  97. }
  98. oldx6 := 0;
  99. if(x8 = oldx7) {
  100. {x7 := 0;} [0.5] {x7 := 1;}
  101. } else {
  102. x8 := oldx7;
  103. }
  104. oldx7 := 0;
  105. if(x9 = oldx8) {
  106. {x9 := 0;} [0.5] {x9 := 1;}
  107. } else {
  108. x9 := oldx8;
  109. }
  110. oldx8 := 0;
  111. if(x10 = oldx9) {
  112. {x10 := 0;} [0.5] {x10 := 1;}
  113. } else {
  114. x10 := oldx9;
  115. }
  116. oldx9 := 0;
  117. if(x11 = oldx10) {
  118. {x11 := 0;} [0.5] {x11 := 1;}
  119. } else {
  120. x11 := oldx10;
  121. }
  122. oldx10 := 0;
  123. if(x12 = oldx11) {
  124. {x12 := 0;} [0.5] {x12 := 1;}
  125. } else {
  126. x12 := oldx11;
  127. }
  128. oldx11 := 0;
  129. if(x13 = oldx12) {
  130. {x13 := 0;} [0.5] {x13 := 1;}
  131. } else {
  132. x13 := oldx12;
  133. }
  134. oldx12 := 0;
  135. }
  136. }