Just wondering if entering a maze from the command line is really a viable requirement. I made a test file and just typing that in took a while. I would assume we could enter the file path to a .txt file via the command line.
I think it's supposed to be like the unix command line utilities, where if you don't get a filename on the command line, you just read from standard input.
So if we had a maze file called maze.txt and a maze program called maze, we could do "cat maze.txt | maze". Or if we had a separate maze generating program called mazegen, we could do "mazegen | maze" without actually saving the generated file anywhere or having to give it a filename.
@itvmakesrage Make sure you use the latest version of Silverlight, which may or may not be BETA or RC. Works just fine for me, the performance is great too on my netbook without hardware acceleration - haven't tried with hardware acceleration - not sure whether UNM video service is DXVA compatible.
Not sure if this'll help you guys or not, but you can specify the command line arguments in eclipse by doing: Run->Run Configurations->Arguments-> Program Arguments
So there shouldn't be any reason to type your maze over and over. Not sure if that what was being asked or not...
I also wanted confirmation on the symbols being used for the maze. I have: S ~Start F ~Finish . ~Open/Path # ~Wall
Just wanted to double check since we haven't gotten an input + output file yet.
@Lucas: Yes, the maze symbols will be S, F, ., #. The lines will be separated by a return character, and the file will be terminated with an EOF character at the beginning of a new line.
The input file will consist of n lines of maze, each of the same length m. m and n will be at most 1000 each, and there will be exactly one S and F. There is no guarantee that the F can actually be reached from the S. If not, your program should print "No solution."
It is preferable if your code actually validates the input. Please print "Invalid input." if the input contains anything but a valid input of the type described above. However, we won't deduct more than 5 points out of 100 for failure to correctly validate the input.
Could you please post the lecture slides regarding this assignment, or at least an outline? I've been working off my notes from class, but it would be nice to have an official version that is easier to access than the slides via ITV.
@Lucy: Justin will be posting some detailed instructions tonight about what to turn in, and how. Hopefully that will make our expectations very clear. Also see my comment above.
In my view, the assignment splits very cleanly into 3 parts, and your solutions should also be very clean and modular.
Part 1: Read and parse the input. At the end of this part, you should have a Graph object, as well as 2 special Vertex (or Node) objects, "start" and "finish"
Part 2: Search the graph, to find a path from start to finish. At the end of this part, you should have a list of Vertex objects, leading from start to finish, without repeats.
Part 3: Print the output in the requested form (big string of NEWS chars).
You aren't required to do it *exactly* like this, but you are required to have search code that works on general graphs, not on arrays of .#SF chars.
I finally have my reference code up and running. Here are some example runs, in case people are interested. It is using BFS, so the paths will always be shortest possible, but this wasn't a project requirement. (Will look best if you view in a monospaced font)
Please enter your maze below, row by row. (ctrl-D when done) S#... .#.#. ...#. ####. F.... SSEENNEESSSSWWWW
The example from class:
Please enter your maze below, row by row. (ctrl-D when done) ######################################## #S.................................###F# #.################################.#...# #.#................................#.#.# #.#.################################.### #.#..................................#.# #.####################################.# #....................................#.# ######################################## EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEESSWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWSSEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEENNNEEN
two more:
Please enter your maze below, row by row. (ctrl-D when done) F S N
Please enter your maze below, row by row. (ctrl-D when done) S..#..F ...#... No exit route.
@Hera, if there is no solution, your code should print a message such as "No exit route" like in my example above. No further output is needed.
As I said in class, you should check for properly formatted input, but it won't be worth more than a 5% penalty if you just assume the input is properly formatted. If you are going to validate the input, here is a list of things to check for: Is the input a rectangle? Is there exactly 1 S and exactly 1 F? Are all characters one of .#SF or return? If any of the answers are NO, you should print an error message and exit without solving the maze.
You shouldn't treat System.in any differently than you treat your FileInputStream.
If you think the most logical arrangement is to have those 4 methods in the same class, then go for it. My own solution has 12 files, and is organized so that all the code specific to this particular kind of maze input is in one file, and all the code that applies in more generality is in the other files.
@kstolleis: Sorry about this. Justin was supposed to post some detailed instructions for this on Friday. I think he is still going to do so, so keep an eye on the Assignments section of the main course website.
In brief, you should make a JAR file containing all your .java and .class files as well as a readme file that explains correct usage. Then just email the jar file. We are going to be recompiling, as well as reading and commenting on your source code, so just sending the .class files is not enough.
Justin or I will post an example readme file, which you can use as a model. Look for that in the Assignments section of the course website.
It would have been really nice to have some further instructions and hints during the Friday lab session. Effectively there hasn't been a lab session for at least two weeks now.
I agree. The entire lab part is just a joke. It would be nice to have an email about the lab cancellation. I had to drive all the way to the University just to see the announcement. And it would be nice to have any explanations of grading on the written homework paper, not just a number. Thanks, but it doesn't help at all!!! But I guess, it's too much to ask.
So my program works just fine using the program arguments using Eclipse under run configurations and it works by giving it a file path with the -f flag, like so:
$java MazeSolver -f C:/somefilepath/somefile.txt
Is it necessary to use the Scanner in order to get the arguments after running the file? I don't think it'd take that much work on my part, but I'll need to know this before turning the project in. I don't want points marked off for it not working, when it can solve every JUnit test that I can write for it.
Let me know if this will affect my grade negatively if I turn it in as is.
Not what you are asking but the Scanner is for internal use in loading/parsing the file. You can either construct a Scanner object with the file path argument or you can construct it with System.in and it will handle the command line input. Everything downstream of the scanner will work fine, whichever you use.
I guess I should clarify my post. I'm assuming that when I run my program with no command line arguments that it should say "Please enter your maze below, row by row. (ctrl-D when done)" and then the user can input their maze. Mine does not currently do that, BUT it can run just fine with the command line arguments that are input from Eclipse.
I thought my project was working just fine, but I was testing it from the command line before turning it in, all other testing was done inside Eclipse, which I'm assuming that Justin and Hayes are going to use to test our projects anyway.
I guess I'm looking for a response from Prof. Hayes on whether or not this is acceptable since the project does work just fine, but it has the user input the maze in a different manner.
I'll try to address the recent comments in a couple of separate posts.
First, I think the attachment should be viewable now. If you download the readme, you'll find that it is only a page long, and the information requested is just to help ensure that we are able to run your code properly, since there may be some variation in how people's programs operate. I would encourage people to just take the example readme, modify it appropriately for your code, and turn it in with your jar file.
Do make sure you include your source code in your jar, not just the executable. Also, be sure to CC yourself and me, so you have proof that you submitted it. I will extend the deadline to midnight, to help compensate for the cancelled lab on Friday.
@Lucas, I'm not quite sure what you are saying your code does. It sounds like you are saying that it can read a maze in from a file, but not one typed in by the user "interactively". It should be able to do both. As Karl suggested, if you've got the file input working, getting the user input working should just be a line or two more.
A separate question is the difference between entering "command line" arguments within Eclipse, versus within a shell session. This shouldn't be a big deal. As Tim pointed out, you can and should use the readme file to indicate how you've got it working successfully for you.
Lucas, if you can clarify your question, and possibly send us your code, we can probably give you a better answer.
@ollie, you can do both through Eclipse. Here are the steps I followed.
File > Export Java/JAR file (not Runnable JAR file, which seems to offer fewer options) (Next) check: Export generated class files and resources check: Export Java source files and resources (Next, Next) to make it runnable, Select the class of the application entry point (the class with your "main" method) (Finish)
Check that it worked: > jar tf MyJar.jar (should list all your .java and .class files) > java -jar MyJar.jar (should run your main method)
Nevermind, I forgot that the terminating character for Windows was ctrl-Z not ctrl-D. I updated the prompt to the user to reflect that as well in my code. Gotta love the little mistakes that take up a good chunk of time...
Just wondering if entering a maze from the command line is really a viable requirement. I made a test file and just typing that in took a while. I would assume we could enter the file path to a .txt file via the command line.
ReplyDeleteWhat if you had a maze generator, and wanted to pipe it's output in to the solver? That's about the only thing I can think of.
ReplyDeleteI think it's supposed to be like the unix command line utilities, where if you don't get a filename on the command line, you just read from standard input.
ReplyDeleteSo if we had a maze file called maze.txt and a maze program called maze, we could do "cat maze.txt | maze". Or if we had a separate maze generating program called mazegen, we could do "mazegen | maze" without actually saving the generated file anywhere or having to give it a filename.
Where are the lecture slides? Please tell me they aren't on iTV it always crashes on me when I try to fast forward.
ReplyDeleteAny way to RAW input via CMD?
ReplyDelete@itvmakesrage
Make sure you use the latest version of Silverlight, which may or may not be BETA or RC. Works just fine for me, the performance is great too on my netbook without hardware acceleration - haven't tried with hardware acceleration - not sure whether UNM video service is DXVA compatible.
Can someone post the input as a .txt file? There is no point for everybody to type the same thing.
ReplyDeleteFor the mazes, can we assume this program will be tested with a medium sized mazes (1k nodes +)?
ReplyDeleteNot sure if this'll help you guys or not, but you can specify the command line arguments in eclipse by doing:
ReplyDeleteRun->Run Configurations->Arguments-> Program Arguments
So there shouldn't be any reason to type your maze over and over. Not sure if that what was being asked or not...
I also wanted confirmation on the symbols being used for the maze. I have:
S ~Start
F ~Finish
. ~Open/Path
# ~Wall
Just wanted to double check since we haven't gotten an input + output file yet.
@Lucas: Yes, the maze symbols will be S, F, ., #. The lines will be separated by a return character, and the file will be terminated with an EOF character at the beginning of a new line.
ReplyDeleteThe input file will consist of n lines of maze, each of the same length m. m and n will be at most 1000 each, and there will be exactly one S and F. There is no guarantee that the F can actually be reached from the S. If not, your program should print "No solution."
It is preferable if your code actually validates the input. Please print "Invalid input." if the input contains anything but a valid input of the type described above. However, we won't deduct more than 5 points out of 100 for failure to correctly validate the input.
Could you please post the lecture slides regarding this assignment, or at least an outline? I've been working off my notes from class, but it would be nice to have an official version that is easier to access than the slides via ITV.
ReplyDelete@Lucy: Justin will be posting some detailed instructions tonight about what to turn in, and how. Hopefully that will make our expectations very clear. Also see my comment above.
ReplyDeleteIn my view, the assignment splits very cleanly into 3 parts, and your solutions should also be very clean and modular.
Part 1: Read and parse the input.
At the end of this part, you should have a Graph object, as well as 2 special Vertex (or Node) objects, "start" and "finish"
Part 2: Search the graph, to find a path from start to finish.
At the end of this part, you should have a list of Vertex objects, leading from start to finish, without repeats.
Part 3: Print the output in the requested form (big string of NEWS chars).
You aren't required to do it *exactly* like this, but you are required to have search code that works on general graphs, not on arrays of .#SF chars.
Hi folks,
ReplyDeleteI finally have my reference code up and running. Here are some example runs, in case people are interested. It is using BFS, so the paths will always be shortest possible, but this wasn't a project requirement.
(Will look best if you view in a monospaced font)
Please enter your maze below, row by row. (ctrl-D when done)
S#...
.#.#.
...#.
####.
F....
SSEENNEESSSSWWWW
The example from class:
Please enter your maze below, row by row. (ctrl-D when done)
########################################
#S.................................###F#
#.################################.#...#
#.#................................#.#.#
#.#.################################.###
#.#..................................#.#
#.####################################.#
#....................................#.#
########################################
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEESSWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWSSEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEENNNEEN
two more:
Please enter your maze below, row by row. (ctrl-D when done)
F
S
N
Please enter your maze below, row by row. (ctrl-D when done)
S..#..F
...#...
No exit route.
TIP: I found using Scanner simplifies code a bit.
ReplyDeleteFor System.in:
.S.
###
.F.
there is no S -> F solution - can I check for this condition and just stop right there?
File maze.txt & similar - do we need to check that it is a rectangle?
For System.in, can non-maze characters simply trigger end of input?
I have loadFile, createGraph, doGraphTraversal, and getDirections methods all in MazeSolver.java - is this OK?
@Hera, if there is no solution, your code should print a message such as "No exit route" like in my example above. No further output is needed.
ReplyDeleteAs I said in class, you should check for properly formatted input, but it won't be worth more than a 5% penalty if you just assume the input is properly formatted. If you are going to validate the input, here is a list of things to check for:
Is the input a rectangle?
Is there exactly 1 S and exactly 1 F?
Are all characters one of .#SF or return?
If any of the answers are NO, you should print an error message and exit without solving the maze.
You shouldn't treat System.in any differently than you treat your FileInputStream.
If you think the most logical arrangement is to have those 4 methods in the same class, then go for it. My own solution has 12 files, and is organized so that all the code specific to this particular kind of maze input is in one file, and all the code that applies in more generality is in the other files.
What is the deliverable for this assignment? Do we simply email a runnable jar file or do you want all the code as a jar and you will compile ect?
ReplyDeleteSorry if this has already been answered but I couldnt find it.
@kstolleis: Sorry about this. Justin was supposed to post some detailed instructions for this on Friday. I think he is still going to do so, so keep an eye on the Assignments section of the main course website.
ReplyDeleteIn brief, you should make a JAR file containing all your .java and .class files as well as a readme file that explains correct usage. Then just email the jar file. We are going to be recompiling, as well as reading and commenting on your source code, so just sending the .class files is not enough.
Justin or I will post an example readme file, which you can use as a model. Look for that in the Assignments section of the course website.
The Programming Assignment 1 announcement under assignments says that a README.pdf file is attached but I don't see one. Can anyone see it?
ReplyDeleteYou gotta be kidding me! Is it the due day like tomorrow? By this time you cannot be too picky about the readme we got.
ReplyDeleteNo, I cannot see the posted readme.
ReplyDeleteIt would have been really nice to have some further instructions and hints during the Friday lab session. Effectively there hasn't been a lab session for at least two weeks now.
ReplyDeleteI agree. The entire lab part is just a joke. It would be nice to have an email about the lab cancellation. I had to drive all the way to the University just to see the announcement. And it would be nice to have any explanations of grading on the written homework paper, not just a number. Thanks, but it doesn't help at all!!! But I guess, it's too much to ask.
ReplyDeleteSo my program works just fine using the program arguments using Eclipse under run configurations and it works by giving it a file path with the -f flag, like so:
ReplyDelete$java MazeSolver -f C:/somefilepath/somefile.txt
Is it necessary to use the Scanner in order to get the arguments after running the file? I don't think it'd take that much work on my part, but I'll need to know this before turning the project in. I don't want points marked off for it not working, when it can solve every JUnit test that I can write for it.
Let me know if this will affect my grade negatively if I turn it in as is.
Thanks,
Lucas
Lucas,
ReplyDeleteNot what you are asking but the Scanner is for internal use in loading/parsing the file. You can either construct a Scanner object with the file path argument or you can construct it with System.in and it will handle the command line input. Everything downstream of the scanner will work fine, whichever you use.
I guess I should clarify my post. I'm assuming that when I run my program with no command line arguments that it should say "Please enter your maze below, row by row. (ctrl-D when done)" and then the user can input their maze. Mine does not currently do that, BUT it can run just fine with the command line arguments that are input from Eclipse.
ReplyDeleteI thought my project was working just fine, but I was testing it from the command line before turning it in, all other testing was done inside Eclipse, which I'm assuming that Justin and Hayes are going to use to test our projects anyway.
I guess I'm looking for a response from Prof. Hayes on whether or not this is acceptable since the project does work just fine, but it has the user input the maze in a different manner.
Hi Lucas,
ReplyDeletefrom the Programming assignment 1 link it states that for turn-in, the readme will require:
-how to execute your program
-what is the input rule of your program
-how to terminate your program
So, I think as long as you put in the readme how to run your program, you should be fine...at least that is my interpretation.
of course, I could be very wrong...
-TIM
Hi class,
ReplyDeleteI'll try to address the recent comments in a couple of separate posts.
First, I think the attachment should be viewable now. If you download the readme, you'll find that it is only a page long, and the information requested is just to help ensure that we are able to run your code properly, since there may be some variation in how people's programs operate. I would encourage people to just take the example readme, modify it appropriately for your code, and turn it in with your jar file.
Do make sure you include your source code in your jar, not just the executable. Also, be sure to CC yourself and me, so you have proof that you submitted it. I will extend the deadline to midnight, to help compensate for the cancelled lab on Friday.
@Lucas, I'm not quite sure what you are saying your code does. It sounds like you are saying that it can read a maze in from a file, but not one typed in by the user "interactively". It should be able to do both. As Karl suggested, if you've got the file input working, getting the user input working should just be a line or two more.
ReplyDeleteA separate question is the difference between entering "command line" arguments within Eclipse, versus within a shell session. This shouldn't be a big deal. As Tim pointed out, you can and should use the readme file to indicate how you've got it working successfully for you.
Lucas, if you can clarify your question, and possibly send us your code, we can probably give you a better answer.
How do I create .jar with both .java and .class? Eclipse can only do either one of them but not both.
ReplyDeleteOllie, I did it from the command line
ReplyDeletejar cf my_jar_file folder_with_all_my_work/*
It worked. I checked. :)
@ollie, you can do both through Eclipse. Here are the steps I followed.
ReplyDeleteFile > Export
Java/JAR file (not Runnable JAR file, which seems to offer fewer options)
(Next)
check: Export generated class files and resources
check: Export Java source files and resources
(Next, Next)
to make it runnable, Select the class of the application entry point
(the class with your "main" method)
(Finish)
Check that it worked:
> jar tf MyJar.jar
(should list all your .java and .class files)
> java -jar MyJar.jar
(should run your main method)
Nevermind, I forgot that the terminating character for Windows was ctrl-Z not ctrl-D. I updated the prompt to the user to reflect that as well in my code. Gotta love the little mistakes that take up a good chunk of time...
ReplyDelete