• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Help with Assignment for Stanford's CS106A Course

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,

I've done quite a bit of searching to find a forum that might actually help me out and have thus come here.

Some explanations first, this is not homework, well not in the traditional sense. This is a free online course, I have no way to submit my work, get feedback, or ask questions (if I could I probably wouldn't be here). From what I understand I actually missed the proper free online course and am just following the course material but as it is I don't think the people following it properly were able to submit there work or ask questions etc.

Anyway to the problem at hand, I will post some links they are not entirely necessary just there if you want to read them and make sure I know what I'm talking about. I've had a lot of problems posting links and then people not helping because they aren't willing to read that much so...

http://see.stanford.edu/materials/icspmcs106a/07-assignment-1-karel.pdf This links you to the assignment document, page 5 is the problem I'm on that I'm having problems with.

The problem given is you need to find the midpoint of a world. So after thinking over it for ages and not knowing how to do it, the idea of a diagonal was constantly stuck in my head, then it came to me. I could make a huge X, but then I realised what if the world is rectangle (this I realised at midnight). So the next day I read over the assignment again to discover one of the conditions says the shape may not always be square, but I read on to find another condition which was the world will always be as tall as it is wide thus a square. So I coded the X. This was all good and well as I continued to code to find the midpoint which was problematic enough as it is. Now though I've discovered wait this doesn't work for 6x6 or 8x8 worlds as there isn't a centre column.

So here we are I'm trying to code a way to find the centre in an even number world. Now before you start suggesting easier ways to start again I'm going to post a link to all the command I know as this is the Karel programming language which is technically Java but dumbed down basically. http://www.stanford.edu/class/cs106a/book/karel-the-robot-learns-java.pdf The last page has what code I know and am allowed to use.

Now my code:

That's the problem code, if you want to read all of my code here is a pastebin link to it: http://pastebin.com/GbQdj2qC.

Basically my idea to solve my problem was whenever it detects a second beeper in a column it would turn left if facing north or turn right if facing south and move forward one and then check if there is a beeper there. If there wasn't it would turnaround move back into position and continue on checking. If there was a beeper that was then the centre in a even world as there would be a group of four beeper at the centre. Instead though it goes to the second beeper in the second column checks and straight thinks there is a second beeper there when there isn't...I have no idea why or what is going wrong and would really appreciate any help I can get.

I've asked for help at Java Forums, OCAU, AtomicMPC, StackOverflow, Binary Revolution and have gotten a couple nice replies but not really any actual help, besides 1 guy from Atomic who I haven't heard from since.

So any help is REALLY appreciated.

Thanks Jack.
 
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is an awful long post, with an awful lot of code. I started to read it (the text, not the code), and just got lost. I'm not sure what you really need help with here.

Can you post a succinct description of your problem, as well as a short, self-contained (compileable) example of what your problem is? Or if you need help with the algorithm, state what he actual problem is you are trying to solve.

You do state that you are trying to find "the mid-point of a world", but I have no idea what you mean by "a world", and I doubt others would, too.

Your job, when you post here, is to make it as easy as possible for someone to help you. There is probably a lot here that will help you get the most out of this site.
 
Jack Wool
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's half the problem. The code depends on the Stanford libraries which is packaged with there version of Eclipse. Explaining all of this and providing links just makes my post longer and thus I've found more people ignore it =/.

It is all very dependent on the files given by Stanford which is hindering any chances of help.

A similar world can be seen here on page 5: http://see.stanford.edu/materials/icspmcs106a/07-assignment-1-karel.pdf. The assignment I am doing can also be read there.

This is more or less the problem currently, the code I posted is also the problem code. So the problem is:

Basically my idea to solve my problem was whenever it detects a second beeper in a column it would turn left if facing north or turn right if facing south and move forward one and then check if there is a beeper there. If there wasn't it would turn around move back into position and continue on checking. If there was a beeper that was then the centre in a even world as there would be a group of four beeper at the centre. Instead though it goes to the second beeper in the second column checks and straight away thinks there is a second beeper there when there isn't...I have no idea why or what is going wrong and would really appreciate any help I can get. idea why or what is going wrong and would really appreciate any help I can get.


 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jack Wool wrote:I have no idea why or what is going wrong


Just my 2 cents worth but you should consider stepping through the code in the debugger, and finding out exactly where it's failing. Then report back with a line number and values that you found wrong.

Otherwise, yeh, it's still very vague just what is going wrong. The debugger will show you var values at each step along the way. At some step you will notice it doing something you didn't expect or don't like. That's what you need to focus on. Then you'll be able to describe the problem in a way that will help focus on the right area.

Hey, that debugger is a wonderful tool. Don't ignore it. It's there to slow the world down and show you what the flow of control is and what values exist and go out of existence and when/where. Take advantage.
 
Jack Wool
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's a problem in itself which I'm trying to solve in the Eclipse forums(getting the debugger to work). You can read about the problem here: http://www.eclipse.org/forums/index.php/t/440280/. Basically I've got a plug-in that is messing up the debugger or so it seems. I'm not even sure how to install or uninstall a plug-in or where it would be located in the folders. So any help there is appreciated.

Sorry about it being vague, I'm not sure how else to explain it. It is very subject or dependant upon the PDFs and lectures given by Stanford and the software they use. Thus finding help has been rather difficult.

So once I can get the debugger running I will give you the line number and values you need to be able to help me.

Thanks.
 
Marshal
Posts: 80772
489
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I shall try duplicating this thread in the IDEs forum; maybe somebody reading there will know about the Eclipse problem. Thank you for informing us you are asking in several places; please tell the people on the Eclipse forum you are posting here.
 
Jack Wool
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I shall inform them as soon as I can.

One problem with Eclipse has been solved. Now though the debugger still seems to be doing nothing. Pressing F5, F6, F7, F8 does nothing or so it seems to me.

Although I'm not sure what the debugger is meant to be doing and producing. The guide the Eclipse forum linked me to didn't help much...
 
Saloon Keeper
Posts: 28718
211
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Jack Wool" from Australia? Hmmm. Good thing you're not from New Zealand or we'd think you were pulling our chains.

With all due respect to IDEs, what you're attempting to do is track a "turtle" (robot) and ensure that it takes a meaningful course, making the proper decisions and ending up in the appropriate destination.

I'd just slap a "System.out.println" in the move() method to print a log of its movements, compare the output to expected actions, and THEN use the debugger (if you need to) to see where/how it's going wrong.

I realize that the problem definition requires a simplified language that may not include printing a trace, but as long as the diagnostic method isn't presented as part of the problem solution (in other words, delete the trace logic when you're done), I can't see anything wrong with that tactic.
 
Paul Witten
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:I'd just slap a "System.out.println" in the move() method to print a log of its movements, compare the output to expected actions, and THEN use the debugger (if you need to) to see where/how it's going wrong.


Debugger probably not even necessary if he follows your sound advice. In fact, once you get used to using println() you begin to sniff where the problems are with your intuition better. If the output is wrong but the cause is still not obvious then the debugger may be necessary, but right now he could advance his cause considerably with println().

Also, I seem to remember a debugger problem that prevented the F-Keys from driving it on certain (Windows probably) versions of a certain platform, or on a certain brand of box, etc. The fix was easy - use the mouse instead of the F-Keys.
 
Jack Wool
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:"Jack Wool" from Australia? Hmmm. Good thing you're not from New Zealand or we'd think you were pulling our chains.

With all due respect to IDEs, what you're attempting to do is track a "turtle" (robot) and ensure that it takes a meaningful course, making the proper decisions and ending up in the appropriate destination.

I'd just slap a "System.out.println" in the move() method to print a log of its movements, compare the output to expected actions, and THEN use the debugger (if you need to) to see where/how it's going wrong.

I realize that the problem definition requires a simplified language that may not include printing a trace, but as long as the diagnostic method isn't presented as part of the problem solution (in other words, delete the trace logic when you're done), I can't see anything wrong with that tactic.



Could you give me an example as to where I would place System.out.println as it doesn't seem to be doing anything if I place it after move () at the end of the code I put in code tags in my opening post. And it doesn't work if I place it inside the brackets like this move (System.out.println()).

Hey I have no way to submit this anyway so it doesn't matter I'm using unorthodox ways to diagnose the problem.
 
Tim Holloway
Saloon Keeper
Posts: 28718
211
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Fortunately you're dealing with an Object-Oriented system here, since I just realized that you don't have the source code to move().

Something like this should help:


I'm assuming that you have ways of determining the current robot position, but I don't know what they are, so I made up "getX, getY" for illustrative purposes. Adjust as needed.
 
Jack Wool
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm now I've read this it may note work. See Karel runs as a graphical display of a robot in a world represented by streets and avenues each position is marked by a dot.

So I can see Karel the robot moving when I compile and run my code, thus I can see what goes wrong I just don't know what is wrong with my code to get this unwanted result. This is why my opening post included a few pdfs that further show examples nd a list of commands I can use and the assignment problem.

It's a very 'involved' problem =\.

So yes I will test that code but I have a feeling it won't work exactly. I'm at the point where I think I should just move on and have somewhat while I look for help.

I'm also thinking of opening a thread here about questioning whether the Stanford course is right for me as I've encountered a problem with another assignment. I'm also concerned I'm not competent with the maths needed for programming and am also trying to work at that with Khan Academy. So...
 
Tim Holloway
Saloon Keeper
Posts: 28718
211
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe the math/compsci discipline that applies to this particular kind of problem is known as Combinatorial Computing (Combinatorics), and if I'm not too far off the beam, includes problems such as Tetris and Rubic's Cube. So if you're not amused by such exercises, then your aptitudes probably lie in other directions. You probably shouldn't apply for a position at iRobot, however, since their Roomba and military robotic products take Karel's exercises into the realm of the real, practical world.

While I consider the fatuous decree that "you can't do Visual Basic unless you know Calculus frontwards and backwards" as, well, fatuous, Computer Science and Math do have a close relationship. What specific mathematical disciplines are necessary vary with what kinds of problems you are interested in solving. I do recommend that for just about anything you be proficient in algebra and symbolic logic. Differential Calculus has been useful to me, as much because it relates to functions and lambda expressions as because of the actual differentations. Oddly, integral calculus is something foreign to my daily work, as evidenced by the horrible showing I did when I finally got around to taking it in college. I'd forgotten most of what I'd once known, including the very existence of trigonometric identities despite spending a term on them in high school.
 
Jack Wool
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well it turns out I am interested in robotics. Particularly A.I. as I hope to help achieve or just achieve the technological singularity.

I'm basically re-teaching myself maths from the beginning as my school life has been interrupted far too many times and is still going through an interruption now (bipolar depression).

So any ideas on learning to program without really needing much math would be greatly appreciated. A book, free online course, etc. would be great.
 
Jack Wool
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is still an open question:

So any ideas on learning to program without really needing much math would be greatly appreciated. A book, free online course, etc. would be great?

Although maybe I didn't make it obvious that it was a question as I didn't leave a question mark at the end...

Anyway bump for the reason above.
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you haven't checked out www.udacity.com already you should take a look. They have a nice little intro to programming course in python.
 
fred rosenberger
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This site has a "Cattle Drive". The assignments are posted for anyone to see/look at/try. If you want a personal reviewer/nit-picker, there is a fee, but you are welcome to take a look here.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic