A programmable robotic mouse is placed at an intersection on a square grid, the borders of which are extendable as needed.
Note:It will be necessary to test a range of constraining values.
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?
(In reply to Revision
The following tweaking of brianjn's program uses SCREEN 12 instead of SCREEN 9 for a more square view (each increment of x is the same size on the screen as an increment of y), as the 640 x 480 pixels is the 4:3 ratio of a conventional screen. It necessitated replacing the second parameter of the SCREEN command with a PAINT command after the CLS. Also, due to the larger vertical number of pixels, L could be increased to 7 while keeping the multiple-of-4 values still in range.
And of course these won't work under Windows Vista, which has dropped support for full-screen DOS graphics.
BTW, the mouse is turning left, rather than right, in this program.
DECLARE SUB startpos ()
DECLARE SUB plot ()
DECLARE SUB Keyin ()
DECLARE SUB path ()
DECLARE SUB star ()
DIM SHARED move 'counts steps
DIM SHARED a 'For..Next label
DIM SHARED f 'For..Next label
DIM SHARED L 'sides of polygon
'Since Rt angle turns, L=4
DIM SHARED s 'For..Next label
DIM SHARED v 'Maximum steps (move)
DIM SHARED z 'Determines move length
DIM SHARED x 'horizontal coordinate
DIM SHARED y 'vertical coordinate
DIM SHARED gr 'mod value of or$ input
DIM SHARED or$
PAINT (1, 1), 9
PRINT "No. from 1 to 20",
IF or$ <> "*" THEN
Keyin 'holds screen display
LOOP WHILE INKEY$ <> CHR$(13)
FOR a = 1 TO s
SELECT CASE move 'this is C equiv. of switch
CASE 1 'up
LINE (x, y)-(x, y - z), 7
y = y - z
CASE 2 'left
LINE (x, y)-(x - z, y), 7
x = x - z
CASE 3 'down
LINE (x, y)-(x, y + z), 7
y = y + z
LINE (x, y)-(x + z, y), 7
x = x + z
move = 1
FOR f = 1 TO L
FOR s = 1 TO v 'v determines the shape
move = move + 1
IF move = 5 THEN move = 1
LINE (x - 1, y + 1)-(x + 1, y - 1), 14
LINE (x - 1, y - 1)-(x + 1, y + 1), 14
v = VAL(or$)
z = 18 'param for step size
z = INT(6 * z / v) '6 only reduces
'initial z value
x = 320 'centre of screen values
y = 240 'startpos may be offset.
gr = (v / 4 - INT(v / 4)) * 4
'determines the "mod" value
'of the spiral category
L = 7
IF v = 1 THEN gr = 1
IF gr = 0 THEN y = 60: x = 100
IF gr = 1 THEN y = 240: x = 350
IF gr = 2 THEN L = 2
IF gr = 3 THEN x = 300: y = 150
Edited on January 26, 2008, 11:49 am
Posted by Charlie
on 2008-01-26 11:47:26