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

function herman() {
int x1 := 0;
int x2 := 0;
int x3 := 0;
int x4 := 0;
int x5 := 0;
int x6 := 0;
int x7 := 0;
int x8 := 0;
int x9 := 0;
int x10 := 0;
int x11 := 0;
int x12 := 0;
int x13 := 0;
int oldx1 := 0;
int oldx2 := 0;
int oldx3 := 0;
int oldx4 := 0;
int oldx5 := 0;
int oldx6 := 0;
int oldx7 := 0;
int oldx8 := 0;
int oldx9 := 0;
int oldx10 := 0;
int oldx11 := 0;
int oldx12 := 0;
int oldx13 := 0;
// determine starting token setup on the ring.
{x1 := 0;} [] {x1 := 1;}
{x2 := 0;} [] {x2 := 1;}
{x3 := 0;} [] {x3 := 1;}
{x4 := 0;} [] {x4 := 1;}
{x5 := 0;} [] {x5 := 1;}
{x6 := 0;} [] {x6 := 1;}
{x7 := 0;} [] {x7 := 1;}
{x8 := 0;} [] {x8 := 1;}
{x9 := 0;} [] {x9 := 1;}
{x10 := 0;} [] {x10 := 1;}
{x11 := 0;} [] {x11 := 1;}
{x12 := 0;} [] {x12 := 1;}
{x13 := 0;} [] {x13 := 1;}
// finds a ring configuration with exactly one token in the ring.
while((x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13) != 1) {
oldx1 := x1;
oldx2 := x2;
oldx3 := x3;
oldx4 := x4;
oldx5 := x5;
oldx6 := x6;
oldx7 := x7;
oldx8 := x8;
oldx9 := x9;
oldx10 := x10;
oldx11 := x11;
oldx12 := x12;
oldx13 := x13;
if(x1 = oldx13) {
{x1 := 0;} [0.5] {x1 := 1;}
} else {
x1 := oldx13;
}
oldx13 := 0;
if(x2 = oldx1) {
{x2 := 0;} [0.5] {x2 := 1;}
} else {
x2 := oldx1;
}
oldx1 := 0;
if(x3 = oldx2) {
{x3 := 0;} [0.5] {x3 := 1;}
} else {
x3 := oldx2;
}
oldx2 := 0;
if(x4 = oldx3) {
{x4 := 0;} [0.5] {x4 := 1;}
} else {
x4 := oldx3;
}
oldx3 := 0;
if(x5 = oldx4) {
{x5 := 0;} [0.5] {x5 := 1;}
} else {
x5 := oldx4;
}
oldx4 := 0;
if(x6 = oldx5) {
{x6 := 0;} [0.5] {x6 := 1;}
} else {
x6 := oldx5;
}
oldx5 := 0;
if(x7 = oldx6) {
{x7 := 0;} [0.5] {x7 := 1;}
} else {
x7 := oldx6;
}
oldx6 := 0;
if(x8 = oldx7) {
{x7 := 0;} [0.5] {x7 := 1;}
} else {
x8 := oldx7;
}
oldx7 := 0;
if(x9 = oldx8) {
{x9 := 0;} [0.5] {x9 := 1;}
} else {
x9 := oldx8;
}
oldx8 := 0;
if(x10 = oldx9) {
{x10 := 0;} [0.5] {x10 := 1;}
} else {
x10 := oldx9;
}
oldx9 := 0;
if(x11 = oldx10) {
{x11 := 0;} [0.5] {x11 := 1;}
} else {
x11 := oldx10;
}
oldx10 := 0;
if(x12 = oldx11) {
{x12 := 0;} [0.5] {x12 := 1;}
} else {
x12 := oldx11;
}
oldx11 := 0;
if(x13 = oldx12) {
{x13 := 0;} [0.5] {x13 := 1;}
} else {
x13 := oldx12;
}
oldx12 := 0;
}
}