Welcome! By now you should have at least three RoBOTL windows open somewhere on your desktop, Your Browser Window The main RoBOTL Applet window (in which most of the action happens) Tutorial Module 1 (in which this text appears. You might want to position the Tutorial windows so that you can see this and the RoBOTL Applet at the same time. To the right in the RoBOTL Applet window is a text box labelled "Code". Directly below the Code box you should see a set of buttons. Click on the red button, labelled "Run", and see what happens. You should see the following text in the Code box:execute { }
This is the shortest program you can ever write in RoBOTL. It consists only of an empty Execute Block. All RoBOTL programs must have at least this part. You can erase the word execute and hit Run to see what happens! To make a program do something, we add instructions within the curly brackets, { }, after execute. You should have the empty execute block in your Code window before you go on. You can click on the Clear-button on top of the Code box to erase whatever is in the Code box now. Hit run to re-load the sample code, and you should be ready for STEP ONE: STEP 1 - Create a NEW Basic Robot (Eve is born) Place the cursor after the { and press Enter. A new line should appear. Type: New basic_bot Eve; Click Run again, and keep an eye on the colored area labeled World. If a triangle appeared in the lower left corner of the World, you just succeeded in creating a new robot and naming it Eve. Eve is of a robot type called basic_bot, which means she has some basic instructions she understands. Eve was born in the lower left corner of our World, because we didn't specify a specific origin. Eve was born facing East (pointing towards the Code). A program body is made up of the instructions within the curly brackets, in this case "New basic_bot Eve;". Skip to STEP 2 to find out what Eve can do! TROUBLE? If you didn't see a triangle, you may have made a typo or omitted the ";". The box named Messages contains information about what just happened, and will suggest how to correct a possible mistake. Don't worry if the messages sound a bit garbled, you'll soon learn how to read them! Correct your program and hit Run, OK? STEP 2 - Where we TELL Eve to MOVE We'll refer to the triangles as robots from now on. Insert a new line after the "new" statement, and type:Tell Eve:{ Move 10; }
Run your program. To verify who and where the robot is, point at it and look in the box Robot/World info for details. The "Tell:" statement calls upon a specific robot by name, in our case Eve. The { } enclose the instructions we have for the robot, for instance: "Move ;", in our case "Move 10;". Note that a robot is moving only in the direction it is pointing. This is important to keep in mind when we later starts operating multiple, high-speed robots in our World. If your program executed without problem, Eve is now placed at (10,0). You might want to make a note of how the World is divided into cells, counting from and including 0. With Eve in place go to STEP 3! STEP 3 - Where we tell Eve to TURN You learned already that a robot only moves in the direction in which it is facing. In order to wander all over the World, the robots need to be able to change direction. They do that by turning left in 90 degree increments. Place the cursor after the "Move 10;" statement and type: Turnleft;
Run your program and watch Eve's final position. Where is she pointing? Add the following after your "turnleft;" statement (you can copy the code lines and paste them into your Code box if you don't want to type):
Move 9; turnleft; move 8; turnleft; move 7; turnleft; move 20;
Run the program and watch Eve twist and turn! Ouch, did we get a little over-aggressive here? After successfully twisting and turning about, Eve went full speed ahead into the Wall and got terminated. Change the code over so that Eve ends up in the far right end of the World, but alive. Now, if that all works go to STEP 4 and get ready for the EXERCISE STEP 4 - Where we introduce more robots and arrange for a meeting You can create multiple robots and place them in the World, as long as you follow these basic rules: 1) Each robot must have a UNIQUE NAME 2) Only one robot at a time can be in the same square 3) Robots can never venture OUTSIDE their World Create some companion robots for Eve by entering this code:New basic_bot Adam at 4,6; New basic_bot Boa at 13,0;
Run the program with this addition. Note that we not only gave birth to two new robots, Adam and Boa, but also placed them on specific squares in the World. This is done by adding the "at x,y"-clause to the New statement. EXERCISE: Create two robots of type basic_bot, one in the lower left and one in the upper right hand corner (19,19). You want the robots to meet in the middle of the World, without crashing into each other and cause mutual destruction. Run your program, and go to Module 2 whenever you are ready! If you want to see an example of a program that solves the problem, click on the View Code button above the tutorial text. Load Code will load the example code (and ERASE your text) and let you run it. KEYWORDS: Basic_Bot, Execute, Move, New, Tell, Turnleft
Send questions and comments to: Karen Lemone