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(5): No Subject - Constraint by Charlie)
The following program continues on after the first return to the start:
CLS
c = 0
fprev = 0
fcurr = 1
temp = 0
x = 0: y = 0
dx = 0: dy = 1
PRINT x; y
' x is positive to the right
' y contrary to convention is positive to the bottom
' but this doesn't matter as left turns would work just as good
' as right turns.
DO
s = 0
c = fcurr
DO
moveNo = moveNo + 1
s = s + 1
PRINT TAB(8); s; c, moveNo
px = x: py = y
x = x + dx * s: y = y + dy * s
PRINT x; y
IF x = 0 AND y = 0 OR x = 0 AND dx = 0 AND SGN(y) = -SGN(py) OR y = 0 AND dy = 0 AND SGN(x) = -SGN(px) THEN
DO: LOOP UNTIL INKEY$ > ""
END IF
dyNew = dx: dxNew = -dy
dy = dyNew: dx = dxNew
LOOP UNTIL s = c
temp = fcurr
fcurr = fprev + fcurr
fprev = temp
LOOP UNTIL x = 0 AND y = 0
A subset of its output, showing places where the original location was hit exactly (apparently only once, on step 9) or where that location was crossed over, follows:
x y s c step
0 0
1 1 1
0 1
1 1 2
-1 1
1 2 3
-1 0
2 2 4 first pass over origin
1 0
1 3 5
1 1
2 3 6
-1 1
3 3 7
-1 -2
1 5 8
0 -2
2 5 9
0 0 landing on origin
...
-7 0
18 34 72 second pass over origin
11 0
...
26 0
71 89 214 third
-45 0
...
-117 0
306 610 1292 fourth
189 0
...
492 0
1291 1597 3874 fifth
-799 0
...
-2091 0
5474 10946 23184 sixth
3383 0
...
etc.
|
Posted by Charlie
on 2008-01-23 11:47:41 |