1: http://robocode.alphaWorks.ibm.com/home/home.html, click Click to Continue, if the test passes, you can download Robocode-setup.jar. As long as you have J2SDK, the test generally passes.
2: Double-click the downloaded Robocode-setup.jar, follow the prompt installation, will put a shortcut on the desktop after completion.
3: Double-click the shortcut to enter the Robocode integration environment.
4: Click on the EDITORR under Robot, then click New, enter the "Robot Name" and "Package Name" in turn.
Then there was the following code:
Package myrobot; import robocode. *; // Import java.awt.color;
/ ** * MySecondRobot - a robot by (your name here) * / public class MySecondRobot extends Robot {/ ** * run: MySecondRobot's default behavior * / public void run () {// After trying out your robot, try uncommenting the Import at the top, // and the next line: //setcolors (color.red, maor.blue, lib.green); while (true) {// replace the next 4 Lines with any behavieor you Would Like Ahead (100 ); Turngunright (360); back (100); Turngunright (360);}}
/ ** * ONSCANNEDROBOT: What to do when you see another robot * / public void onscannedrobot (ScannedRobotevent E) {Fire (1);
/ ** * onhitbybullet: what to do when're Hit by a barlet * / public void onhitbybullet (hitbybulletevent e) {turnleft (90 - E.getBearing ());}
You can do anything, after saving, click Compile Compilation under Compiler.
5: Close Editor, click New, press F5 to refresh, then click Add and Your Robot, click Add, add a system to bring a system with the same method, and finally press START BATTLE to start fighting. .
Tip: You can refer to the Robocode API under Help.