Everything Robocode



An Advanced Robot allows you to access extra functions that are not available to the Basic Robot. It allows you to do multiple things at once (eg. move and turn gun at the same time) by using a non blocking call. So instead of using ahead(int d); you use setAhead(int d).
The setAhead() function will return immediately while the ahead will only return when the move has been completed(this is an example of a blocking call) - it blocks all further movements). This is a feature that is very useful and simple to implement and is used in almost all robots.
Some functions using set:
setAhead(int distance);*
setBack(ind distance);*
setTurnGunRight(int degrees);
setTurnGunLeft(int degrees);
setTurnRight(int degrees);
setTurnLeft(int degrees);

Extending AdvancedRobot class

1. Create a new robot
2. Make sure you have the import "robocode.*" at the top
3. You should see near the top of code, after the imports, "public class 'yourname' extends Robot" - where 'yourname' is what you named the robot
4. Replace Robot with AdvancedRobot
5. There - now you can use set functions!

*all distances are measured in pixels


You are viewing the text version of this site.

To view the full version please install the Adobe Flash Player and ensure your web browser has JavaScript enabled.

Need help? check the requirements page.

Get Flash Player