Karel Assignment 1 Problem 24

posted 5 years ago

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.

This course is the largest of the introductory programming courses and is one of the largest courses at Stanford. Topics focus on the introduction to the engineering of computer applications emphasizing modern software engineering principles: object-oriented design, decomposition, encapsulation, abstraction, and testing.

Programming Methodology teaches the widely-used Java programming language along with good software engineering principles. Emphasis is on good programming style and the built-in facilities of the Java language. The course is explicitly designed to appeal to humanists and social scientists as well as hard-core techies. In fact, most Programming Methodology graduates end up majoring outside of the School of Engineering. 

Prerequisites: The course requires no previous background in programming, but does require considerable dedication and hard work.

This Stanford course was taught on campus three times per week in 50 minute lectures for the Stanford Engineering Everywhere Initiative.

For more online learning opportunities, please visit Stanford Online.

0 thoughts on “Karel Assignment 1 Problem 24

Leave a Reply

Your email address will not be published. Required fields are marked *