0% found this document useful (0 votes)
63 views

Kevin Smith: @yorkcodedojo

Robocode is a programming game where players code battle tanks (robots) in Java or other languages to compete against other robots. To play, users need Java, the Robocode game files, an IDE, and can code robots that move, turn, fire bullets, and scan for other robots. The goal is to survive battles in the arena against other players' robots and earn points from damaging or destroying opponents.

Uploaded by

Ruben Hernandez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views

Kevin Smith: @yorkcodedojo

Robocode is a programming game where players code battle tanks (robots) in Java or other languages to compete against other robots. To play, users need Java, the Robocode game files, an IDE, and can code robots that move, turn, fire bullets, and scan for other robots. The goal is to survive battles in the arena against other players' robots and earn points from damaging or destroying opponents.

Uploaded by

Ruben Hernandez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Kevin Smith

@kev_bite / kevsoft.net
@YorkCodeDojo
What’s Robocode?

Robocode is a programming game where the goal is to code a robot


battle tank to compete against other robots in a battle arena.

Runs on the Java Runtime but bots can be developed in Java or any
language that is compiled down to IL (C#, F#, VB.NET)

@kev_bite / @YorkCodeDojo
What do I need?

• Java Standard Edition - https://java.com/en/download/


• Robocode - https://sourceforge.net/projects/robocode/files/robocode/1.9.2.6/
• robocode-1.9.2.6-setup.jar
• robocode.dotnet-1.9.2.6-setup.jar

• An IDE – Eclipse, NetBeans, Visual Studio etc…


• or notepad & javac/csc
• or use my VM

@kev_bite / @YorkCodeDojo
No JavaScript?!

• RoboJS – Robocode in JavaScript


• Port of Robocode
• Only runs JavaScript
• Requires hacking HTML
• Can’t play in battle at end

• http://gumuz.nl/projects/robojs/

@kev_bite / @YorkCodeDojo
The Arena

@kev_bite / @YorkCodeDojo
Robot Anatomy
• Body - Carries the gun with the radar on top. The body is used for
moving the robot ahead and back, as well as turning left or right.
• Gun - Mounted on the body and is used for firing energy bullets.
The gun can turn left or right.
• Radar - Mounted on the gun and is used to scan for other robots
when moved. The radar can turn left or right. The radar generates
onScannedRobot events when robots are detected.

@kev_bite / @YorkCodeDojo
Movements

Turn
Backward
Turn
Forward
Right
Left

@kev_bite / @YorkCodeDojo
Attacking

Turn
Turn
TurnRadar
Radar
Gun Right
Left
GunRight
Fire Left
Scanning
@kev_bite / @YorkCodeDojo
Battles

@kev_bite / @YorkCodeDojo
Scoring

• Total Score
• Survival Score
• Last Survivor Bonus
• Bullet Damage
• Bullet Damage Bonus
• Ram Damage
• Ram Damage Bonus
• 1sts, 2nds, 3rds

@kev_bite / @YorkCodeDojo
Show me some code
• Inherit/Extend `Robot` class
• Override `void Run()`
• Override `void OnScannedRobot(ScannedRobotEvent e)`
• Override `void OnHitByBullet(HitByBulletEvent e)`
• Override `void OnHitRobot(HitRobotEvent e)`

• C# -
https://github.com/robo-code/robocode/blob/master/plugins/dotnet/robocode.dotnet.samp
les/src/SampleCs/MyFirstRobot.cs
• Java -
https://github.com/robo-code/robocode/blob/master/robocode.samples/src/main/java/sam
ple/MyFirstRobot.java

@kev_bite / @YorkCodeDojo
More code…
• Ahead(double distance) / Back(double distance)
• TurnGunLeft(double degrees) / TurnGunRight(double degrees)
• TurnLeft(double degrees) / TurnRight(double degrees)
• TurnRadarLeft(double degrees) / TurnRadarRight(double degrees)
• DoNothing()
• Fire(double power)
• Stop()
• Resume()
• Scan()

@kev_bite / @YorkCodeDojo
Let me code (Java)

package {team-name};

import robocode.HitByBulletEvent;
import robocode.HitRobotEvent;
import robocode.Robot;

public class {bot-name} extends Robot { }

@kev_bite / @YorkCodeDojo
Let me code (C#)

using Robocode;
using Robocode.Util;

namespace {team-name}
{
public class {bot-name}: Robot { }
}

@kev_bite / @YorkCodeDojo
Example Robot
public class Fire extends Robot {

public void run() {


// Spin the gun around slowly... forever
while (true) {
turnGunRight(5);
fire(1);
}
}

public void onHitRobot(HitRobotEvent e) {


double turnGunAmt =
normalRelativeAngleDegrees(e.getBearing() + getHeading() - getGunHeading());

turnGunRight(turnGunAmt);
fire(3);
}
}
@kev_bite / @YorkCodeDojo
Resources

• Wiki - http://robowiki.net/
• Java Examples -
https://github.com/robo-code/robocode/blob/master/robocode.sa
mples/src/main/java/sample/
• C# Examples -
https://github.com/robo-code/robocode/blob/master/plugins/dotn
et/robocode.dotnet.samples/src/SampleCs

@kev_bite / @YorkCodeDojo
Bot Ideas

• Running and Firing


• Scan, Fire then Ram
• Spin and Fire
• Artificial Intelligence
• Machine Learning

@kev_bite / @YorkCodeDojo
Packing Robot

• Java - http://robowiki.net/wiki/Robocode/Package_Robot
• .NET – Send Dlls

@kev_bite / @YorkCodeDojo
Exercises

• Pair Up

• Make an Awesome Bot

• Explain Ideas & Battle

@kev_bite / @YorkCodeDojo

You might also like