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.
 
 
 
 

108 lines
1.9 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 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;
// determine starting token setup on the ring.
{x1 := 0;} [0.5] {x1 := 1;}
{x2 := 0;} [0.5] {x2 := 1;}
{x3 := 0;} [0.5] {x3 := 1;}
{x4 := 0;} [0.5] {x4 := 1;}
{x5 := 0;} [0.5] {x5 := 1;}
{x6 := 0;} [0.5] {x6 := 1;}
{x7 := 0;} [0.5] {x7 := 1;}
{x8 := 0;} [0.5] {x8 := 1;}
{x9 := 0;} [0.5] {x9 := 1;}
{x10 := 0;} [0.5] {x10 := 1;}
// finds a ring configuration with exactly one token in the ring.
while((x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10) != 1) {
oldx1 := x1;
oldx2 := x2;
oldx3 := x3;
oldx4 := x4;
oldx5 := x5;
oldx6 := x6;
oldx7 := x7;
oldx8 := x8;
oldx9 := x9;
oldx10 := x10;
if(x1 = oldx10) {
{x1 := 0;} [0.5] {x1 := 1;}
} else {
x1 := oldx10;
}
oldx10 := 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;
}
}