Karel Assignment 1 Problem 4-1

Take Home Exercise #4 INFO16029 – Problem Solving/ Programming Logic Instructor: Sukhbir Singh Tatla Note: 1.Assignment must be completed as an individual effort. 2.Due date for submission is specified in SLATE. 3.All online submissions will be done via SLATE (Email submissions will NOT be accepted). 4.Late assignments will be penalized 10% each day for up to 3 days. After that, it is worth zero. 5.Please refer to the Academic Dishonesty Policy. Question: In this assignment, you will be practicing using inheritance and arrays.You will create a new city and environment in your program. Your main task will be to do the following: 1.Create five Things using an array of 5 elements called things and use a for-loop to create the five things. 2.Write the for-loop to pick up all the things using array. 3.Set the labels according to their index i.e. things [0] will have label T0. 4.Have Robot “karel” put down all Things in the same positions but in reverseorder.

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.

Categories: 1

0 Replies to “Karel Assignment 1 Problem 4-1”

Leave a comment

L'indirizzo email non verrà pubblicato. I campi obbligatori sono contrassegnati *