Home
Project Folders
Teacher Resources
Student Resources
How Do I?
Literacy
MWForum
Site Map
Search
Our Team

MWForum Message [Date Index] [Threads] [Authors] [Attachments] [Subscribe]

[Thread Prev] [Thread Next]

To: "MicroWorlds Forum" <mwforum@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Subject: Re: robot and maze
From: "Daniel Ajoy" <da.ajoy@xxxxxxxxx>
Date: Thu, 30 Dec 2010 10:32:24 -0500

On Thu, 30 Dec 2010 05:38:38 -0500, Rotem Kimchi <rotemk2@xxxxxxxxxxxxxxxx> wrote:

Hi Daniel,
How are you?
I created a maze and using two sensors (turtles: Black_Shadow and White_Shadow) I got my car (turtle Robo ) out of the maze.
I used the left wall algorithm that can solve every simple OneNote maze.
I can't think of a way to let the robot know he finished the maze without using color or possition coordinates do you have an idea that could blend into the code? I know that in most cases "the first way you think about solveing a problem is the best and simplest way to solve that problem"
but I think there is room for improvements so
I am sending you the code hoping you could take a look and maybe could offer me ways to improve it by:
adding functions or maybe adding recursion function to solve the maze
In order to cheak the code all you need to do is to press only on the foward ("38" ascii) arrow The end goal is to use this code and others in a real robot that will preform every day tasks on command autonomously or by remote control while writing simple logo commands


It happens that I had created something very similar years ago. The main structure of the program is like this:

to main
  create.maze
  startup.position

  while [inside.maze?] [
     orient
     give.step.forward
  ]
end

to turn.left
  turn.right
  turn.right
  turn.right
end

to orient
  turn.right
  while [wall.infront?] [turn.left]
end

;===========
So the procedures that you need to define are:

create.maze
startup.position
give.step.forward
inside.maze?
turn.right
wall.infront?

Here is my definition of wall.infront?


to wall.infront?
  penup forward 10
  make "x 9 = colorunder
  back 10
  output :x
end

Notice that if there is wall in front of the turtle:

show 9 = colorunder
true

but, if there is not a wall in front of the turtle:

show 9 = colorunder
false

Notice that "wall.infront?" can be implemented by a sensor in front of the robot. No other sensors are requiered.

I can't think of a way to let the robot know he finished the maze without using color or possition coordinates do you have an idea that could blend into the code?

My definition of "inside.maze?" uses colorunder

to inside.maze?
  output not colorunder = 15

  ; the area outside the maze is red
  ; while the turtle is not stepping on red, she is inside.
fin


Daniel



  • Previous by thread: Re: Learn to program in Lisp one game at a time
  • Next by thread: Re: robot and maze

  • To save an attachment to your computer, PC users should right-click (Mac users, click and hold the mouse button) on the link and then choose 'save target as' from the pop-up menu. A window will then pop up in which you can choose a location for the file.


    © copyright 2001 - 2008