Presentation is loading. Please wait.

Presentation is loading. Please wait.

Robocode A robot is made up of 3 things:

Similar presentations


Presentation on theme: "Robocode A robot is made up of 3 things:"— Presentation transcript:

1 Robocode A robot is made up of 3 things:
The vehicle The gun, which sits on the body The radar, which sits on the gun These 3 parts can move independent of each other. Let’s go over the basics of how to create a robot…

2 Commands for moving the robot, gun, and radar
These methods are part of the robocode.Robot class… turnRight(double degree) & turnLeft(double degree) Ahead(double distance) & back(double distance) These methods stop if you hit a wall or another robot turnGunRight(double degree) & turnGunLeft The gun can turn independent of the vehicle turnRadarRight(double degree) & turnRadarLeft Again, the radar can turn independent of vehicle, gun

3 When the vehicle turns, the gun & radar also turn by default, unless you call one of these methods:
setAdjustGunForRobotTurn(boolean flag) If flag==true, gun will NOT change direction even if vehicle does setAdjustRadarForRobotTurn(boolean flag) Same idea as above setAdjustRadarForGunTurn(boolean flag)

4 Obtaining Info about the robot
getX() and getY() Get the coordinates of the robot getHeading() Gets current heading of vehicle, in degrees getGunHeading() getRadarHeading() getBearing() Finds another robot in location to you (see board) getBattleFieldWidth() & getBattleFieldHeight()

5 Firing Bullets Each robot starts with a default energy level
Ways to lose energy: Get hit by a bullet Hit a wall or another robot Fire a bullet The more power put into a bullet, the more energy used, but the more damage inflicted Method: fire(double power) You gain energy when your bullet hits another robot

6 Event handling When certain events occur, your Robot will follow default behavior – unless you handle any of these events: ScannedRobotEvent When your radar detects another robot HitByBulletEvent HitRobotEvent HitWallEvent There are many other methods that you should research

7 Basic structure of a Robot:
Package mq; // my initials import robocode.*; public class QuinnRobot extends Robot { // set instance variables here public void run() { // code here will execute only once…used // to set up the robot while(true) { // code for repetitive action goes here } // helper methods & event handlers go here

8 Assignment Go to robowiki.net. Read the “My First Robot Tutorial.”
Create your first robot, using the basic skills taught in the tutorial. Begin reading other robowiki tutorials/articles. 4. Study the code of already existing robots in the RobotsSample folder Continue working on your robot. The melee will most likely be held this Friday. After that, at some point, there will be an NCAA-style one-on-one tournament.


Download ppt "Robocode A robot is made up of 3 things:"

Similar presentations


Ads by Google