Robot Battle Wiki
Advertisement

Before you can switch blocking off you must understand what command blocking is. To understand command blocking you must first understand Turn Loss

About Turn Loss

Although Robot Battle appears to run in real-time, it is in fact a turn based game. You can perform an almost unlimited amount of calculation in a turn, but in the following circumstances you will lose a turn:

  • Running more than 100,000 lines of code. (This will also cause an error.)
  • If a routine gets called for the second time in a row. (i.e. If your core completes and all triggered events have already completed.)
  • You use any of the following commands: endturn, stall, suicide or waitfor
  • Calling a movement command when command blocking is on

So basically, command blocking refers to whether the robot lose turns after movement commands (such as ahead, bodyleft, radarright etc.). So what does this mean practically?

Blocking Example

Here is simple example of the differences between blocking off and on:

Init{
  blocking(_on)
  ahead(50)
  fire(1)
}

This robot will drive forward 50 units, then fire its gun.

Init{
  blocking(_off)
  ahead(50)
  fire(1)
}

This robot will fire before it even starts moving. After firing it will then continue moving forward until it has moved a total of 50 units. You can see the robot has not waited for the ahead command to complete before executing the fire command.

Why switch blocking off?

There are some very good reasons to switch blocking off. This section is designed to inform you of some standard uses.

Curved Movement

You can switch blocking off in order for your robot to perform more than one movement command at once. This can produce curved movement.

Init{
  blocking(_off)
  ahead(100)
  bodyright(90)
}

This robot will move in an arc across the arena. When movement is complete, the robot would have turned 90° to the right and would have moved 100 units. With blocking off, your robot will continue to execute the commands without waiting for the curved movement to complete. In order to get your robot to wait until movement is complete you can use the waitfor command and the _rotating and _moving command. For example:

Init{
  blocking(_off)
  ahead(100)
  bodyright(90)
  waitfor((_rotating == _false) && (_moving == _false))
  print("Done Moving and Rotating!")
}

This robot will wait for the robots motion and rotation to stop before moving on the the print command.

Sliding

Sliding allows a robot to move and rotate at the same time without producing curved movement. In other words, the robot moves straight ahead as if it wasn't rotating, but the robot's heading is changed. The best way to understand sliding is to see it in action. Try this robot:

Init{
  blocking(_off)
  sliding(_on)
  ahead(100)
  bodyright(90)
  waitfor((_rotating == _false) && (_moving == _false))
  print("Done Moving and Rotating!")
}

As you can see, other than switching sliding on, this example is the same as the Curved Movement example above. With sliding on the movement is quite different. You might find this kind of movement useful for wall bots, or any other robot that moves in straight lines.

Note: Sliding was originally a bug, but made it in to Robot Battle 1.4 by popular demand. It can be disabled in match setup. You can check the _allowsliding variable to see if sliding is enabled.

More Control

Some people like to switch blocking off simply to have more control over the robot. For example, autoscan procedures (using regascan) are not required when blocking is switched off. Instead you can simply ensure that the scan command is called once per turn when the robot is moving.

Advertisement