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?

M

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(4): No Subject - Constraint | Comment 10 of 19 |
(In reply to re(3): No Subject - Constraint and she by brianjn)


I noticed I made an error in my program. The size of the mouse's step size never resets! So the "whole number condition" program should look like (pseudo code was also reorganized to be more intuitive, so the important correction is marked in italics):
 

C=0


Do
   S=0 <Represents the unit length of the step>
   C=C+1    <The constraint will increment by 1 on>
            <each iteration to follow the whole>
            <numbers>

   Do
      S=S+1 <The step size increments by 1>
            <until the constraint is reached>
      Move forward S units
      Turn right
   While S!=C

While (mouse has not returned to start spot)


By the way, the mouse passes over her start spot in the middle of her 5th step, and officially lands on it at the end of it's 28th step.

The pseudocode for the constraint following the Fibonacci Sequence (FS) would be something like:
 

C=0
Fprev=0 <The first number in the FS, which we can't>
            <really incorporate into the program>
Fcurr=1  <The second number in the FS, which will be>
            <the first constraint in the program>
Temp=0  <Placeholder variable>


Do
   S=0 <Represents the unit length of the step>

   C=Fcurr   <The constraint will increase each>
             <iteration to follow the FS>

   Do
      S=S+1 <The step size increments by 1>
             <until the constraint is reached>
      Move forward S units
      Turn right
   While S!=C


   Temp=Fcurr <These lines move us up the FS>
   Fcurr=Fprev+Fcurr
   Fprev=Temp

While (mouse has not returned to start spot)


Here the mouse passes over her start spot in the middle of her 4th step. I haven't been able to determine if she ever lands on it, though. Out of curiosity, is there a difference?

 

Edited on January 23, 2008, 10:18 am
  Posted by nikki on 2008-01-22 17:14:04

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


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

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information