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.

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