will someone give me a very simple example of simulating movement in a maze? i want to try this from the console first (worry about the logic right now), then move it to an applet. or, can doing such a thing only be done within a C++ console? i think a multi-dimensional array is used, with a marker.
if you don't know, then ask. if you do know, then share. love is knowledge.
Well if you have a "maze" class you could have methods like: MoveRight(), MoveLeft(), MoveUp(), MoveDown(). The class would also have a print() method so that you could display the maze and your location in it. A two dimentional array would be the first thing that came to mind to represent the maze.
Please ignore post, I have no idea what I am talking about.
Joined: Aug 26, 2001
that's about as far as I had gotten with it, before I decided to post in the forum about this. my main question is this: can this be done from the console? or, must it be done within an applet?
Of course. Anthing that can be done from an Applet can be done from an application. Just add a main method that creates an object of the class, add a constructor that creates a Frame and adds the applet to the Frame and executes the init() and start() methods - that should get you started. To be REALLY cool you would want to replace the browsers functionality in calling stop() and start() by adding listeners to see if the Frame has gotting minimized or covered up etc. My suggestion: go to javaboutique.com and find an applet or application that has a maze or something close and check out their code.
"JavaRanch, where the deer and the Certified play" - David O'Meara
You will also want to use a Stack data structure so that if you hit a dead end you can go back spaces.
Best Regards, -Jason
Jason R. Kretzer<br />Software Engineer<br />System Administrator<br /><a href="http://alia.iwarp.com" target="_blank" rel="nofollow">http://alia.iwarp.com</a>
Joined: Aug 26, 2001
after reading the responses to my question, it appears that I don't have a clue what I am doing. I can mentally see what is happening, I just don't know how to translate this to code.
Joined: May 31, 2001
This is a very common program for Java students to help them learn recursion. You should try looking in a text book. Go to a local college library or bookstore and look for the programming texts. Look up recursion in the index and they almost always use a maze example. Alternately, you could just go here. http://math.hws.edu/xJava/other/maze.html I found this doing a google search for maze source code java. Hope this helps.
------------------ Jason R. Kretzer Software Engineer [This message has been edited by Jason Kretzer (edited December 10, 2001).]