Original von Zachanassian
Also mein ahk (s.u.) gibt nach 100,000 versuchen41,59 Züge. Also aufgerundet 42!
anzahl := 0 tries := 100000 loop, %tries% { anzahl := anzahl + walk() } result := anzahl / tries MsgBox, %tries%: %result% walk() { xpos := 13 ypos := 13 zug := 0 loop { zug := zug + 1 Random, rand, 1, 8 if (rand = 1) { xpos := xpos + 2 ypos := ypos + 1 } else if(rand = 2) { xpos := xpos + 2 ypos := ypos - 1 } else if(rand = 3) { xpos := xpos + 1 ypos := ypos + 2 } else if(rand = 4) { xpos := xpos + 1 ypos := ypos - 2 } else if(rand = 5) { xpos := xpos - 1 ypos := ypos + 2 } else if(rand = 6) { xpos := xpos - 1 ypos := ypos - 2 } else if(rand = 7) { xpos := xpos - 2 ypos := ypos + 1 } else if(rand = 8) { xpos := xpos - 2 ypos := ypos - 1 } if (xpos < 1) or (xpos > 25) or (ypos < 1) or (ypos > 25) break } return zug }
bei dir werden manchmal felder übersprungen.
die 8 verschiedenen zugkombinationen lauten:
x = x+1
y = y+1
x = x+0
y = y+1
x = x-1
y = y+1
x = x+1
y = y+0
x = x+1
y = y-1
x = x+0
y = y-1
x = x-1
y = y-1
x = x-1
y = y+0