All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Algorithms
Unbounded Maze (Posted on 2008-01-18) Difficulty: 3 of 5
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.

See The Solution Submitted by brianjn    
Rating: 4.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
re(5): No Subject - Constraint | Comment 12 of 19 |
(In reply to re(4): No Subject - Constraint by nikki)

The program:

x = 20: y = 36
dirx = 0: diry = 1
amt = 1
lim = 1

s$ = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
mNo = 1
 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;
 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

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
Please log in:
Remember me:
Sign up! | Forgot password

Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (5)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Copyright © 2002 - 2019 by Animus Pactum Consulting. All rights reserved. Privacy Information