getName 返回自己的名字
public String getName()
Returns the robot's name.
返回机器人自己的名字
Returns:
the robot's name.
--------------------------------------------------------------------------------
getX 得到X坐标
public double getX()
Returns the X position of the robot. (0,0) is at the bottom left of the battlefield.
返回值为机器人的X坐标,(0,0)坐标在战场的左下角。(译者注:向右为X正向,向上为Y正向)。
Returns:
the X position of the robot.
See Also:
getY()
--------------------------------------------------------------------------------
getY 得到Y坐标
public double getY()
Returns the Y position of the robot. (0,0) is at the bottom left of the battlefield.
返回值为机器人的Y坐标,(0,0)坐标在战场的左下角。(译者注:向右为X正向,向上为Y正向)。
Returns:
the Y position of the robot.
See Also:
getX()
run
public void run()
The main method in every robot. You must override this to set up your robot's basic behavior.
在每个机器人中的主方法。为了你的机器人有一些基本行为,你必须重写这个方法。
Example:
例如:
// A basic robot that moves around in a square
一个在一个正方形里反复行走的基本的机器人
public void run() {
while (true) {
ahead(100);
turnRight(90);
}
}
Specified by:
run in interface Runnable
可以行走的时候才会行走。
--------------------------------------------------------------------------------
turnLeft
public void turnLeft(double degrees)
Immediately turns the robot's body to the left by degrees.
马上将机器人向左转以 degrees 指写的度数
This call executes immediately, and does not return until it is complete, i.e. when the angle remaining in the robot's turn is 0.
这个指令马上被调用,直到做完才会返回。比如,当角度已经转完时就会返回。
Note that both positive and negative values can be given as input, where negative values means that the robot's body is set to turn right instead of left.
正数和负数都可以作为参数,是负数意味着会向右转,转动角度的大小是一样的。
Example:
// Turn the robot 180 degrees to the left
将机器人向左转180度。
turnLeft(180);
// Afterwards, turn the robot 90 degrees to the right
然后,向右转90度。
turnLeft(-90);
Parameters:
degrees - the amount of degrees to turn the robot's body to the left. If degrees > 0 the robot will turn left. If degrees < 0 the robot will turn right. If
degrees = 0 the robot will not turn, but execute.
degrees- 机器人向左转动的角度的大小。如果 degrees>0,那么机器人会向左转,如果degrees<0,那么机器人会像右转。如果degrees=0,那么机器人不会转动,但指令还是执行了
的。
See Also:
可参考:
turnRight(double), turnGunLeft(double), turnGunRight(double), turnRadarLeft(double), turnRadarRight(double)
--------------------------------------------------------------------------------
turnRight 向右转
public void turnRight(double degrees)
Immediately turns the robot's body to the right by degrees.
马上将机器人向右转以 degrees 指写的度数
This call executes immediately, and does not return until it is complete, i.e. when the angle remaining in the robot's turn is 0.
这个指令马上被调用,直到做完才会返回。比如,当角度已经转完时就会返回。
Note that both positive and negative values can be given as input, where negative values means that the robot's body is set to turn left instead of right.
正数和负数都可以作为参数,是负数意味着会向左转,转动角度的大小是一样的。
Example:
// Turn the robot 180 degrees to the right
将机器人向右转180度。
turnRight(180);
// Afterwards, turn the robot 90 degrees to the left
然后,向左转90度。
turnRight(-90);
Parameters:
degrees - the amount of degrees to turn the robot's body to the right. If degrees > 0 the robot will turn right. If degrees < 0 the robot will turn left. If
degrees = 0 the robot will not turn, but execute.
degrees- 机器人向右转动的角度的大小。如果 degrees>0,那么机器人会向右转,如果degrees<0,那么机器人会像左转。如果degrees=0,那么机器人不会转动,但指令还是执行了
的。
See Also:
turnLeft(double), turnGunLeft(double), turnGunRight(double), turnRadarLeft(double), turnRadarRight(double)
--------------------------------------------------------------------------------
doNothing 什么都不做
public void doNothing()
Do nothing this turn, meaning that the robot will skip it's turn.
在这一轮中什么都不做,其实也就表示机器人将退出这一轮的比赛。
This call executes immediately, and does not return until the turn is over.
这个指令会马上执行,直到这轮比赛结束才返回。