STEP 1 - In which we define a WorldEntity, some Beepers and get Adam busy Load the example "Adam in Adamsville" from the Examples menu. Run the program! What is the obvious new thing here? As the program listing shows, there is a whole new section to our RoBOTL program, the define block. define { WorldEntity Adamsville { Beeper at 0,0; Beeper at 0,19= 3; Beeper at 19,19 = 2; Beeper at 19,0; } } This part of the program defines a transparent overlay for the general World, and names it Adamsville. Adamsville contains some elements, Beepers, that robots can play with. A Beeper is a square marker, and you can identify a beeper as a colored square on the World. Beepers are placed out at specific squares, named by their coordinates: Beeper at; In our case 4 Beepers are defined at different places, and 2 of these are defined as groups of beepers: Beeper at = ; What color are the Beepers in our example? Run the program again, and if you have trouble identifying the beepers, try slowing the execution down, and look in the corners. (Answer to the Q: The colors vary, depending on the active color scheme. The default Beeper color is purple). Defining the WorldEntity is only half the fun. In order to ACTIVATE a WorldEntity it has to be PLACED onto the World. This is done inside the execute block of the program: execute{ place Adamsville; new basic_bot Adam; tell Adam: { iterate 4 times { move 19; turnleft; pickbeeper; } } } Trying to run only this execute block will give you at least a runtime error. Try it as you please! You can find an explanation to the error messages at the end of this module. Now that Adam has a place of his own, and something to play with, we can ask him to pick up or put down beepers. PickBeeper makes Adam suck up a beeper from the World, and place it in his backpack. The backpack is called a BeeperBag (guess you didn't know he even carried one around!). PutBeeper makes a robot grab a Beeper from the BeeperBag, and toss it onto a square. STEP 2 - where we verify that Adam is actually doing his job Before you do the exercise, verify that Adam is really picking up beepers! If you click Step instead of Run to start the program, you'll run the program line by line. Click Step again, until Adam appears in the corner. Now, if you hold down the Shift key and click on Adam, you'll create a leash to your robot, and its movements and whereabouts will be displayed in the box containing World/Robot information. You will see how this comes in handy later, when your programs get bigger and your robots are not responding as expected. Stepping through a program is a way of finding out where problems occur. This process is often referred to as trouble shooting or debuging. Check it out! You can at anytime resume to normal speed by clicking Continue. EXERCISE Create a WorldEntity containing two sets of single beepers and two sets of two beepers placed in the far most corners of the World. Create two robots. One robot should walk about and pick up a beeper from each location. The other robot should pick up the remaining beepers. Do not let the robots crash or self destruct! How did it go? If your program ran without errors and solved the task, you should be ready for Module 4! You can View Code to look at an example that solves the problem as specified. Note that this is one way of doing it, other ways can be as correct or even better! KEYWORDS Beeper, Continue, Define, PickBeeper, Place, PutBeeper, Step, WorldEntity ERROR MESSAGES Error: The WorldEntity "Adamsville" has not been defined. (line 2) Execution was halted due to a runtime error. This is a possible result from NOT defining something before trying to use it. Similar messages will appear whenever we try to use something that is not a predefined part of the RoBOTL language.
Send questions and comments to: Karen Lemone