Difference between revisions of "Robocode 2"
From CompSciWiki
(Add headings) |
(Added starting robot code) |
||
Line 9: | Line 9: | ||
== Installation == | == Installation == | ||
− | == | + | == Building starting robot == |
+ | {{CodeBlock | ||
+ | |Code= | ||
+ | package robocode2; | ||
+ | import robocode.*; | ||
+ | |||
+ | public class Robocode2 extends Robot | ||
+ | { | ||
+ | public void run() { | ||
+ | // Robot main loop | ||
+ | while(true) { | ||
+ | turnGunRight(360); | ||
+ | } | ||
+ | } | ||
+ | //onScannedRobot: What to do when you see another robot | ||
+ | public void onScannedRobot(ScannedRobotEvent e) { | ||
+ | fire(1); | ||
+ | } | ||
+ | } | ||
+ | }} | ||
+ | |||
== Move after being hit by a bullet == | == Move after being hit by a bullet == |
Revision as of 12:36, 3 April 2012
COMP 1010 Home > Back to Extra Labs
IntroductionRobocode 2
|
---|
Installation
Building starting robot
package robocode2; import robocode.*; public class Robocode2 extends Robot { public void run() { // Robot main loop while(true) { turnGunRight(360); } } //onScannedRobot: What to do when you see another robot public void onScannedRobot(ScannedRobotEvent e) { fire(1); } }