RoBOTL

NewRobotType definition


NewRobotType new_type { IsLikeA old_type ; }
NewRobotType new_type { IsLikeA old_type ; enhancements }

To define a new robot, you must use the NewRobotType statement. This defines a new robot type (new_type) to be based on another robot type (old_type). The enhancements, if given, are what differentiate one type from another and can consist of DefineNewInstruction, DefineInitialBeepers, and DefineInteger statements. The IsLikeA must be the first statement in the NewRobotType definition block. One is never used without the other. The definition must come before any executable statements, so it is placed within a define block.
The NewRobotType definition can also be specified using new_robot_type.
Example 1:
define
{
   NewRobotType another_bot
   {
      IsLikeA basic_bot;
   }
}
execute
{
   new basic_bot karel at 1,1;
   tell karel:
   {
      if (FrontIsClear) Move 1; 
      TurnOff;
   }
   new another_bot twin at 3,3;
   tell twin:
   {
      if (FrontIsClear) Move 1;
      TurnOff;
   }
}

Example 2:
define
{
   NewRobotType beeper_bot
   {
      IsLikeA basic_bot;
      DefineInitialBeepers 5;
      DefineNewInstruction turnright as
      {
         iterate 3 times TurnLeft;
      }
   }
}
execute
{
   new beeper_bot kathy at 5,4;
   tell kathy: turnright;
}

Further Details - NewRobotType definition:
You can also go:

Created on 19 June 1995
Last revised 20 August 1996
Copyright ©1995,1996 Walter S. Ching, n1hbr@ma.ultranet.com