12/30/10

Karel -the Robot learns Java using Eclipse Tutorial

Karel The Robot is a robot simulator that affords a gentle introduction to computer programming. Users write Karel programs and feed them to the simulator to watch them execute.

By solving karel problems you will build your logic and enjoy programming.



<-Karel 




Karel- its a robot.. its has its own world that is known as the grid. The grid has avenues (column) and streets(rows). Karel is placed at the 1st street and 1st avenues ie 1,1 if denotes in Cartesian co-ordinates.  


 This is Karels World.




Karel has only four Main functions :

1. move()- that makes karel move one step ahead.
2. putBeeper()- It puts a beeper.
3.pickBeeper()- it picks a beeper.
4. turnLeft()-makes karel turn left at that place itself.

It is simialr to JAVA so it is helpful for those who are  learning JAVA. It also supports object oriented programming ie u don’t need to define a function every time if u want to use instead in OOP u can write function once inside a class then u can call the function by creating an object of that class and then calling it..

to download karel, click
to install: Download an assignment from clicck(in this assiggnments)
   
Import button
After downloading both the assignment and eclipse IDE, unrar it and open Eclipse.exe, then click on the import button ----------------------------------------------------------------->


Then use the browser to find Assignment-1 folder.When you do so, Eclipse will load the starter project and display its name in the Package Explorer window like this:


Then click on the small triangle and start doing solving the problem.


Now lets do a simple Karel program : 

Q.we will solve a problem from assignment-1 ie CollectNewspaper(the documentation for the problem is available in, handouts-assignment 1)


clip of problem (we have to get the beeper):   
 Code is:
 
import stanford.karel.*;

public class CollectNewspaperKarel extends Karel{

    public void run(){
          move();
          turnRight();
          move();
          turnLeft();
          move();
          pickBeeper();
    }

    public void turnRight(){
          turnLeft();
          turnLeft();
          turnLeft();
    }


Karels running interface is :

To learn Karel download the book : www.stanford.edu/class/cs106a/book/karel-the-robot-learns-java.pdf

SHARE THIS POST:

5 comments:

  1. Anyone can help? Ive tried running Karel prog on both my own copy of Eclipse and Stanfords,both result in a blank page withe the problem as the title i.e 'CollectNewspaper...'and 'File' just underneath that then the box is just white-(no Image at all! Ive tried changing the run config as explained on a few pages and the youtube video http://www.youtube.com/watch?v=jWMW2ZfYPo4 and a small variation on this but always the same outcome-the blank 'titled' box and No errors show in the Problems tab...it has me totally baffled^^,im taking a java course but i like the look and simplistic approach of karel to speed my education,Thank for reading this any help would be massive! O I'm runnin a PC on Xp pro with java7, i was wondering if i may have to downgrade to java6 but i cant see it? Eclipse Indigo and helios both result in the same-as does stanford own copy,. :s

    ReplyDelete
  2. Go here and check Lecture No. 2 It will show you how to open and run it.
    http://see.stanford.edu/see/lecturelist.aspx?coll=824a47e1-135f-4508-a5aa-866adcae1111

    ReplyDelete