[hotjoe.com] HotJoe Java Help Forums
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Visit java.com
Please send email if you are having login problems - see the posts below for more info.
Hotmail and Yahoo! users - please see the Hotmail post or the Yahoo! post for information on lost emails.
i Need to create a method called insideMaze.  XML
Forum Index » Java Programming
Author Message
joner89

Newbie

Joined: 03/03/2010 01:56:09
Messages: 2
Offline

I need to create a method called insideMaze.

The method will determine if a robot is still inside a maze and return the corresponding bollean indicator. E.g True if the robot is still inside the maze.

The maze is composed of linked walls and defined as follows.

1. It has a square peremiter wall with one gap for exit.
2. From any position in the maze it is possible to reach every other position in the maze.
3. each position in the maze has 1, 2 or 3 walls adjacent to it.
4. each peice of the wall in the maze in connected (possibly via other peices of wall) to the perimeter wall.

The method should finish with the robot pointing in the same direction as at the start of the method.

The robot is passed as a parameter.

Baisically i have a group task 'leave the maze'.

There is a main method as follows.

BEGIN
create a maze
create a robot inside the maze
set balls to 0
set moves to 0
WHILE robot is insideMaze
update balls by ballsPickedUp
robot makes nextMove
increment moves
ENDWHILE
display moves and balls
END

I am not required to programme the main method, but each member of our team(3) needs to design test and implement the three methods.

My method is insideMaze, which i have described in my first post on this thread. Dont worry about the other methods as other group members are doing that e.g makeAMove and ballsPickedUp.

As far as code goes ive come up with some PDL.

SET Robot InsideMaze to TRUE
IF Robot InsideMaze
robot move
END IF
WHILE robot front is not clear
turn left
turn left
turn left
move
END WHILE

This seemed to work in theory but after looking at the maze i realised i could get stuck in a coulde de sac, therefore i need a way for my robot to stop getting stuck and still find its way out

The problem i have is how to get robot InsideMaze to false? I was thinking it could count the walls around it when its front isnt clear, therefore when it reaches the end and counts 0 walls then it will know its out of the maze and end to while loop.

Sorry if its a bit long winded but its the best way i can explain!
stdunbar

Newbie
[Avatar]

Joined: 06/22/2005 14:51:37
Messages: 849
Location: Superior, CO, USA
Offline

Are you having a problem with some specific code? You'll have to have a way to catch if your robot gets stuck but I would start to code up your thoughts to this point and see if you get stuck in the coding aspect.

Thanks for using the forums at hotjoe.com
[WWW] [Yahoo!] [ICQ]
joner89

Newbie

Joined: 03/03/2010 01:56:09
Messages: 2
Offline

Portfolio Part 2 – Leave The Maze.

This is the method ive been asked to create, here is the PDL i have come up with so far. Can someone aswer my questions in the PDL?

This method should determine if the robot is still inside the maze and return the corresponding boolean indicator. For example, it should return true if the robot is still inside the maze.
The method should finish with the robot pointing in the same direction as at the start of the method.
The robot is passed as the parameter.


PDL For inside Maze.
BEGIN
Create robot inside maze
Set Robot Direction//Why do I have to do this?
Set Robot insideMaze to TRUE
WHILE Robot inisdeMaze
IF Robot frontIsClear
Robot Move
END IF
ELSE Robot frontIsNotClear
Robot turn Left
Robot Move// is there a way i can do this so it wont get stuck? E.g Random number of turns?
END ELSE
END WHILE

IF Robot is outside maze// how do i say its outside maze?
Robot insideMaze is FALSE
END IF
END
 
Forum Index » Java Programming
Go to:   
Powered by JForum 2.1.9 © JForum Team
This site run by Scott Dunbar of Xigole Systems. © 2005-2011 - Scott Dunbar
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners
hotjoe.com, xigole.com, and Scott Dunbar have no affiliation with Oracle