A programmable robotic mouse is placed at an intersection on a square grid, the borders of which are extendable as needed.
From its initial location the mouse moves one cell forward.
It turns right with its next move incrementing by 1.
This incremental process continues up to a certain constraint whereby the mouse resumes the process with a move of one space until that constraint is met again; continue this process until you either return to your starting position or you evidently will never return.
What generalisations can be made about how variations of the value of the constraint affect the path forced upon the mouse? |
|
Note:It will be necessary to test a range of constraining values.
(In reply to
re(4): No Subject - Constraint by nikki)
The program:
CLS
x = 20: y = 36
dirx = 0: diry = 1
amt = 1
lim = 1
s$ = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
mNo = 1
DO
moveNo = moveNo + 1
LOCATE y - 16, x + 25: PRINT MID$(s$, mNo, 1);
DO: a$ = INKEY$: LOOP UNTIL a$ > "": IF a$ = CHR$(27) THEN EXIT DO
x = x + dirx * amt: y = y + diry * amt
IF x = 20 AND y = 36 THEN
ct = ct + 1: LOCATE 47, ct * 6: PRINT moveNo;
END IF
amt = amt + 1: IF amt > lim THEN amt = 1: lim = lim + 1
diryNew = dirx: dirxNew = -diry
diry = diryNew: dirx = dirxNew
mNo = mNo + 1
IF mNo > LEN(s$) THEN mNo = 1
LOOP
acts like nikki's first program, just different names and where the values get incremented, and corresponding change of initialization to 1 rather than 0. The grid spots visited are shown below, again using the sequence 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ repeatedly. Since it repeats you can't tell exactly when a given grid point was achieved:
1 2
1 2
r X Y
X Y
n T U
T U
P j Q
P S R
3 4 L f M
1 LW V
Z 0 l H H mI
X O0 NH Z I
V F W hG D D iE
S4 RD 3 E
R BS C d z eA
Wm VP Vz A
N O x y j 9k v aw
0q ZL M Zv w
rK Vu rg 5 6s
4u2t K3 u3
M Ln w vR i hn Go
8y 7 x O N y x
Q Pj zN Ck
cC d b SB CR B
U E Tf DJ yg p
gG f F G F
Y Xb uc
kK j j KJ J
2 17 q8 L
oO n n N
65 P
s r r
a 9 T
w v
e d
A z
i h
E D
m l
I H
q p
The mouse landed exactly on the starting point on steps,
28 120 276
before the mouse exceeded the bounds of the 80x50 screen by attempting to exit the top at move number 316.
|
Posted by Charlie
on 2008-01-23 10:52:46 |