Author |
Topic: 2 Robots (Read 3527 times) |
|
mad
Junior Member
![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif)
![](http://www.ocf.berkeley.edu/~wwu/YaBBImages/avatars/blank.gif)
Posts: 118
|
Two robots are standing on an infinitely long line at infinte unknown positions. We need to make them meet. To do so, we need to write same program for both of them using statements MOVL (move 1 step left) MOVR (move 1 step right) MOV2L (move 2 steps left) MOVR (move 2 steps right) MARK (make a mark at current position) if( Mark ) //True if mark is already there.
|
|
IP Logged |
|
|
|
Icarus
wu::riddles Moderator Uberpuzzler
![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/starmod.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/starmod.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/starmod.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/starmod.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/starmod.gif)
![](http://www.ocf.berkeley.edu/~wwu/YaBBImages/avatars/sylvester.gif) Boldly going where even angels fear to tread.
Gender: ![male](http://www.ocf.berkeley.edu/~wwu/YaBBImages/male.gif)
Posts: 4863
|
![](http://www.ocf.berkeley.edu/~wwu/YaBBImages/xx.gif) |
Re: 2 Robots
« Reply #1 on: Mar 8th, 2008, 7:26am » |
Quote Modify
|
No negation or Else operators? No branching instructions? That will require infinitely long programs.
|
|
IP Logged |
"Pi goes on and on and on ... And e is just as cursed. I wonder: Which is larger When their digits are reversed? " - Anonymous
|
|
|
Hippo
Uberpuzzler
![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif)
![](http://www.ocf.berkeley.edu/~wwu/YaBBImages/avatars/blank.gif)
Gender: ![male](http://www.ocf.berkeley.edu/~wwu/YaBBImages/male.gif)
Posts: 919
|
![](http://www.ocf.berkeley.edu/~wwu/YaBBImages/xx.gif) |
Re: 2 Robots
« Reply #2 on: Mar 8th, 2008, 7:54am » |
Quote Modify
|
It is very simillar to hole in the wall ... one of the robots will stand still mimicking the hole... Yes, some variables will be helpful ... what about unmarking, conditioanl loops, branching ...
|
« Last Edit: Mar 8th, 2008, 7:55am by Hippo » |
IP Logged |
|
|
|
rmsgrey
Uberpuzzler
![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif)
![](http://www.ocf.berkeley.edu/~wwu/YaBBImages/avatars/blank.gif)
![rmsgrey](http://www.ocf.berkeley.edu/~wwu/YaBBImages/aim.gif)
Gender: ![male](http://www.ocf.berkeley.edu/~wwu/YaBBImages/male.gif)
Posts: 2874
|
![](http://www.ocf.berkeley.edu/~wwu/YaBBImages/xx.gif) |
Re: 2 Robots
« Reply #3 on: Mar 8th, 2008, 8:00am » |
Quote Modify
|
on Mar 8th, 2008, 7:54am, Hippo wrote:It is very simillar to hole in the wall ... one of the robots will stand still mimicking the hole... Yes, some variables will be helpful ... what about unmarking, conditioanl loops, branching ... |
| You can't have just one robot stand still throughout - each robot has the same program... I'd go for: MOVL if ( Mark ) MOV2L MARK repeated infinitely many times...
|
|
IP Logged |
|
|
|
Hippo
Uberpuzzler
![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif)
![](http://www.ocf.berkeley.edu/~wwu/YaBBImages/avatars/blank.gif)
Gender: ![male](http://www.ocf.berkeley.edu/~wwu/YaBBImages/male.gif)
Posts: 919
|
![](http://www.ocf.berkeley.edu/~wwu/YaBBImages/xx.gif) |
Re: 2 Robots
« Reply #4 on: Mar 8th, 2008, 10:37am » |
Quote Modify
|
Oops: one letter difference sAme not sOme And yes, your solution works well if the conditions are interpreted the way you use. (Suppose originaly there is sufficient number of places with no marks )
|
« Last Edit: Mar 8th, 2008, 10:41am by Hippo » |
IP Logged |
|
|
|
Grimbal
wu::riddles Moderator Uberpuzzler
![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/starmod.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/starmod.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/starmod.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/starmod.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/starmod.gif)
![](http://florian.net/pic/65x65/grimbal.php?.gif)
Gender: ![male](http://www.ocf.berkeley.edu/~wwu/YaBBImages/male.gif)
Posts: 7527
|
![](http://www.ocf.berkeley.edu/~wwu/YaBBImages/xx.gif) |
Re: 2 Robots
« Reply #5 on: Mar 9th, 2008, 6:16am » |
Quote Modify
|
What is missing in the question is: how are the robots synchronized. Do they repeat the whole program with each time tick? Do they repeat one instruction per time tick? If yes, is if ( ... ) ... executed in one or two ticks when the condition is true?
|
|
IP Logged |
|
|
|
temporary
Full Member
![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif)
![](http://www.ocf.berkeley.edu/~wwu/YaBBImages/avatars/run_in_box.gif)
Posts: 255
|
![](http://www.ocf.berkeley.edu/~wwu/YaBBImages/xx.gif) |
Re: 2 Robots
« Reply #6 on: Mar 23rd, 2008, 1:24pm » |
Quote Modify
|
Write this program for only one(or possibly both) robot(s): MOVL MOV2R MOV3L MOV4R MOV5L MOV6R...
|
|
IP Logged |
My goal is to find what my goal is, once I find what my goal is, my goal will be complete.
|
|
|
rmsgrey
Uberpuzzler
![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif)
![](http://www.ocf.berkeley.edu/~wwu/YaBBImages/avatars/blank.gif)
![rmsgrey](http://www.ocf.berkeley.edu/~wwu/YaBBImages/aim.gif)
Gender: ![male](http://www.ocf.berkeley.edu/~wwu/YaBBImages/male.gif)
Posts: 2874
|
![](http://www.ocf.berkeley.edu/~wwu/YaBBImages/xx.gif) |
Re: 2 Robots
« Reply #7 on: Mar 24th, 2008, 2:19pm » |
Quote Modify
|
on Mar 23rd, 2008, 1:24pm, temporary wrote:Write this program for only one(or possibly both) robot(s): MOVL MOV2R MOV3L MOV4R MOV5L MOV6R... |
| There are two problems with that program. Firstly, it uses instructions that aren't included in the initial set, which only allows for moves of up to 2 steps. Secondly, if both robots execute it at the same speed, there will always be a constant distance between them.
|
|
IP Logged |
|
|
|
temporary
Full Member
![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif)
![](http://www.ocf.berkeley.edu/~wwu/YaBBImages/avatars/run_in_box.gif)
Posts: 255
|
![](http://www.ocf.berkeley.edu/~wwu/YaBBImages/xx.gif) |
Re: 2 Robots
« Reply #8 on: Mar 25th, 2008, 6:09pm » |
Quote Modify
|
Then I suppose programming both of them wouldn't work, but programming only one of them still works. And I can still use that answer by simply rewriting it with only two steps at a time. MOVL MOV2R MOV2L MOVL MOV2R MOV2R MOV2L MOV2L MOVL MOV2R MOV2R MOV2R MOV2L...
|
|
IP Logged |
My goal is to find what my goal is, once I find what my goal is, my goal will be complete.
|
|
|
rmsgrey
Uberpuzzler
![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif)
![](http://www.ocf.berkeley.edu/~wwu/YaBBImages/avatars/blank.gif)
![rmsgrey](http://www.ocf.berkeley.edu/~wwu/YaBBImages/aim.gif)
Gender: ![male](http://www.ocf.berkeley.edu/~wwu/YaBBImages/male.gif)
Posts: 2874
|
![](http://www.ocf.berkeley.edu/~wwu/YaBBImages/xx.gif) |
Re: 2 Robots
« Reply #9 on: Mar 26th, 2008, 12:45pm » |
Quote Modify
|
on Mar 25th, 2008, 6:09pm, temporary wrote:Then I suppose programming both of them wouldn't work, but programming only one of them still works. And I can still use that answer by simply rewriting it with only two steps at a time. MOVL MOV2R MOV2L MOVL MOV2R MOV2R MOV2L MOV2L MOVL MOV2R MOV2R MOV2R MOV2L... |
| It's possible for the two robots to be guaranteed to meet, despite both running the same program. The key is the if command that lets the robots behave differently depending on whether they are at marked positions or not.
|
|
IP Logged |
|
|
|
Hippo
Uberpuzzler
![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif) ![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif)
![](http://www.ocf.berkeley.edu/~wwu/YaBBImages/avatars/blank.gif)
Gender: ![male](http://www.ocf.berkeley.edu/~wwu/YaBBImages/male.gif)
Posts: 919
|
![](http://www.ocf.berkeley.edu/~wwu/YaBBImages/xx.gif) |
Re: 2 Robots
« Reply #10 on: Mar 26th, 2008, 3:11pm » |
Quote Modify
|
rmsgrey: Nice to see someone who is able to comment the posts in such a polite way. I myself should ignore them not having enough mental powers to be able to ...
|
|
IP Logged |
|
|
|
marsh8472
Newbie
![*](http://www.ocf.berkeley.edu/~wwu/YaBBImages/star.gif)
![](http://www.ocf.berkeley.edu/~wwu/YaBBImages/avatars/blank.gif)
Posts: 27
|
![](http://www.ocf.berkeley.edu/~wwu/YaBBImages/xx.gif) |
Re: 2 Robots
« Reply #11 on: Sep 14th, 2012, 1:39am » |
Quote Modify
|
on Mar 7th, 2008, 8:11pm, mad wrote:Two robots are standing on an infinitely long line at infinte unknown positions. We need to make them meet. To do so, we need to write same program for both of them using statements MOVL (move 1 step left) MOVR (move 1 step right) MOV2L (move 2 steps left) MOVR (move 2 steps right) MARK (make a mark at current position) if( Mark ) //True if mark is already there. |
| do until MARK MOVL LOOP do until MARK == false MOV2L loop They both move left until they pick up the other's trail then once the rightmost bot picks up the leftmost bot's trail, the rightmost bot moves twice the speed until it catches up with the leftmost bot.
|
|
IP Logged |
|
|
|
|