RubyKara
World editor
Program editor
RubyKaraProgramm
Info

Within your RubyKara program, you have access to three different objects. Do not change these three objects! The three objects you can access are:

How does RubyKara work? When executing your own program, a new Thread is started. Important: Since your program runs within its own thread, RubyKara cannot control it, for instance, pause or stop your program`s execution.

This is why a small trick is applied: Each time you make use of any of Kara's commands – kara.move() or kara.turnRight() etc – the method tools.checkState() is called first. This method checks whether the program should pause or even stop; otherwise the thread goes to sleep for an amount of time corresponding to the adjustment of the execution speed controller. You should make sure that your program calls either any of the Kara methods or the tools.checkState()-method! Otherwise you might happen to program an infinite loop, for instance, that cannot be stopped anymore without terminating RubyKara.

kara  
   void move() A step forward
   void turnLeft() 90° left turn
   void turnRight() 90° right turn
   void putLeaf() Lay cloverleaf down
   void removeLeaf() Pick cloverleaf up
   boolean treeFront() Kara in front of a tree?
   boolean treeLeft() Is there a tree to Kara`s left?
   boolean treeRight() Is there a tree to Kara's right?
   boolean onLeaf() Is Kara on top of a cloverleaf?
   boolean mushroomFront() Is Kara in front of a mushroom?
   void setPosition (int x, int y) Put Kara at position (x,y)
   java.awt.Point getPosition() Returns the coordinates of Kara's current position

world  
   void clearAll() Remove all elements
   void setLeaf (int x, int y, boolean putLeaf) Lay down a leaf or pick one up
   void setTree (int x, int y, boolean putTree) Plant or remove tree
   void setMushroom (int x, int y, boolean putMushroom) Plant or remove mushroom
   void setSize (int newSizeX, int newSizeY) Change world size
   boolean isEmpty (int x, int y) Field empty?
   boolean isTree (int x, int y) Is there a tree on the field?
   boolean isMushroom (int x, int y) Is there a mushroom on the field?
   boolean isLeaf (int x, int y) Is there a leaf on the field?
   int getSizeX() Horizontal world size
   int getSizeY() Vertical world size

tools  
   void println (String string) Write string to standard output
   void showMessage (String message) Write string to a dialog window
   int random (int bound) Returns random number in the range [0..bound]
   void checkState() Checks the execution controller
   void sleep (int ms) Sleeps ms milliseconds
   String stringInput (String title) Lets the user input a string in a dialog window with a title. Returns null if the dialog is aborted using Cancel.
   int intInput (String title) Lets the user input a integer number in a dialog window with a title. Returns Integer.MIN_VALUE if the dialog is aborted using Cancel.
   double doubleInput (String title) Lets the user input a real number in a dialog window with a title. Returns Double.MIN_VALUE if the dialog is aborted using Cancel.