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.

178 lines
3.2 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 x14 := 0;
  16. int x15 := 0;
  17. int x16 := 0;
  18. int x17 := 0;
  19. int oldx1 := 0;
  20. int oldx2 := 0;
  21. int oldx3 := 0;
  22. int oldx4 := 0;
  23. int oldx5 := 0;
  24. int oldx6 := 0;
  25. int oldx7 := 0;
  26. int oldx8 := 0;
  27. int oldx9 := 0;
  28. int oldx10 := 0;
  29. int oldx11 := 0;
  30. int oldx12 := 0;
  31. int oldx13 := 0;
  32. int oldx14 := 0;
  33. int oldx15 := 0;
  34. int oldx16 := 0;
  35. int oldx17 := 0;
  36. // determine starting token setup on the ring.
  37. {x1 := 0;} [] {x1 := 1;}
  38. {x2 := 0;} [] {x2 := 1;}
  39. {x3 := 0;} [] {x3 := 1;}
  40. {x4 := 0;} [] {x4 := 1;}
  41. {x5 := 0;} [] {x5 := 1;}
  42. {x6 := 0;} [] {x6 := 1;}
  43. {x7 := 0;} [] {x7 := 1;}
  44. {x8 := 0;} [] {x8 := 1;}
  45. {x9 := 0;} [] {x9 := 1;}
  46. {x10 := 0;} [] {x10 := 1;}
  47. {x11 := 0;} [] {x11 := 1;}
  48. {x12 := 0;} [] {x12 := 1;}
  49. {x13 := 0;} [] {x13 := 1;}
  50. {x14 := 0;} [] {x14 := 1;}
  51. {x15 := 0;} [] {x15 := 1;}
  52. {x16 := 0;} [] {x16 := 1;}
  53. {x17 := 0;} [] {x17 := 1;}
  54. // finds a ring configuration with exactly one token in the ring.
  55. while((x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17) != 1) {
  56. oldx1 := x1;
  57. oldx2 := x2;
  58. oldx3 := x3;
  59. oldx4 := x4;
  60. oldx5 := x5;
  61. oldx6 := x6;
  62. oldx7 := x7;
  63. oldx8 := x8;
  64. oldx9 := x9;
  65. oldx10 := x10;
  66. oldx11 := x11;
  67. oldx12 := x12;
  68. oldx13 := x13;
  69. oldx14 := x14;
  70. oldx15 := x15;
  71. oldx16 := x16;
  72. oldx17 := x17;
  73. if(x1 = oldx17) {
  74. {x1 := 0;} [0.5] {x1 := 1;}
  75. } else {
  76. x1 := oldx17;
  77. }
  78. oldx17 := 0;
  79. if(x2 = oldx1) {
  80. {x2 := 0;} [0.5] {x2 := 1;}
  81. } else {
  82. x2 := oldx1;
  83. }
  84. oldx1 := 0;
  85. if(x3 = oldx2) {
  86. {x3 := 0;} [0.5] {x3 := 1;}
  87. } else {
  88. x3 := oldx2;
  89. }
  90. oldx2 := 0;
  91. if(x4 = oldx3) {
  92. {x4 := 0;} [0.5] {x4 := 1;}
  93. } else {
  94. x4 := oldx3;
  95. }
  96. oldx3 := 0;
  97. if(x5 = oldx4) {
  98. {x5 := 0;} [0.5] {x5 := 1;}
  99. } else {
  100. x5 := oldx4;
  101. }
  102. oldx4 := 0;
  103. if(x6 = oldx5) {
  104. {x6 := 0;} [0.5] {x6 := 1;}
  105. } else {
  106. x6 := oldx5;
  107. }
  108. oldx5 := 0;
  109. if(x7 = oldx6) {
  110. {x7 := 0;} [0.5] {x7 := 1;}
  111. } else {
  112. x7 := oldx6;
  113. }
  114. oldx6 := 0;
  115. if(x8 = oldx7) {
  116. {x7 := 0;} [0.5] {x7 := 1;}
  117. } else {
  118. x8 := oldx7;
  119. }
  120. oldx7 := 0;
  121. if(x9 = oldx8) {
  122. {x9 := 0;} [0.5] {x9 := 1;}
  123. } else {
  124. x9 := oldx8;
  125. }
  126. oldx8 := 0;
  127. if(x10 = oldx9) {
  128. {x10 := 0;} [0.5] {x10 := 1;}
  129. } else {
  130. x10 := oldx9;
  131. }
  132. oldx9 := 0;
  133. if(x11 = oldx10) {
  134. {x11 := 0;} [0.5] {x11 := 1;}
  135. } else {
  136. x11 := oldx10;
  137. }
  138. oldx10 := 0;
  139. if(x12 = oldx11) {
  140. {x12 := 0;} [0.5] {x12 := 1;}
  141. } else {
  142. x12 := oldx11;
  143. }
  144. oldx11 := 0;
  145. if(x13 = oldx12) {
  146. {x13 := 0;} [0.5] {x13 := 1;}
  147. } else {
  148. x13 := oldx12;
  149. }
  150. oldx12 := 0;
  151. if(x14 = oldx13) {
  152. {x14 := 0;} [0.5] {x14 := 1;}
  153. } else {
  154. x14 := oldx13;
  155. }
  156. oldx13 := 0;
  157. if(x15 = oldx14) {
  158. {x15 := 0;} [0.5] {x15 := 1;}
  159. } else {
  160. x15 := oldx14;
  161. }
  162. oldx14 := 0;
  163. if(x16 = oldx15) {
  164. {x16 := 0;} [0.5] {x16 := 1;}
  165. } else {
  166. x16 := oldx15;
  167. }
  168. oldx15 := 0;
  169. if(x17 = oldx16) {
  170. {x17 := 0;} [0.5] {x17 := 1;}
  171. } else {
  172. x17 := oldx16;
  173. }
  174. oldx16 := 0;
  175. }
  176. }