Difference between revisions of "Robocode 2"

From CompSciWiki
Jump to: navigation, search
(Add headings)
(Added starting robot code)
Line 9: Line 9:
 
== Installation ==
 
== Installation ==
  
== Download starting robot ==
+
== 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

Introduction

Robocode 2
Robot API
Download and Battle against the Internet

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);
	}	
} 


Move after being hit by a bullet

Move back after hitting a wall

Add your own event based method from the robot API

Battle!