AdvancedRobot SetAhead Method Robocode Robot API for .NET
Sets the robot to move ahead (forward) by distance measured in pixels when the next execution takes place.

This call returns immediately, and will not execute until you call Execute  or take an action that executes.

Note that both positive and negative values can be given as input, where positive values means that the robot is set to move ahead, and negative values means that the robot is set to move back. If 0 is given as input, the robot will stop its movement, but will have to decelerate till it stands still, and will thus not be able to stop its movement immediately, but eventually.

Namespace: Robocode
Assembly: robocode (in robocode.dll) Version: 1.9.3.0
Syntax

public void SetAhead(
	double distance
)

Parameters

distance
Type: OnlineSystem Double
The distance to move measured in pixels. If distance > 0 the robot is set to move ahead. If distance < 0 the robot is set to move back. If distance = 0 the robot is set to stop its movement.
Examples

// Set the robot to move 50 pixels ahead
SetAhead(50);

// Set the robot to move 100 pixels back 
// (overrides the previous order)
SetAhead(-100);

...
// Executes the last SetAhead()
Execute();
See Also