Sample Code: Making Robots in Java (JRobot)
By Angsuman Chakraborty, Gaea News NetworkThursday, April 20, 2006
I talked about JRobots, an extremely addictive Java game where you develop robots in java to fight against other JRobots in a monthly battle royale. Today I will present you with a simple sample JRobot to encourage you to participate in this contest. It kicks the butt of all sample JRobots provided in the download bundle and even some veterans.
JRobots developers are hesitant to provide actual code because of two reasons;
1. It will lead to proliferation of copy-cat JRobots with a different name which are just a waste of time for all.
2. Nobody likes to reveal their secrets
I have considered them over the years. I have come to the conclusion that the benefits of providing simple code for developers to begin with far outweighs other concerns. So here is a simple JRobot which despite its simplicity can really kick butt of many JRobots. It was initially released as CounterStrike. However now the CounterStrike code is slightly more sophisticated. So I am releasing this JRobot named Simple.
public class __Simple_ extends JJRobot {
void main() {
int distance, angle = 0;
while (true) {
while((distance = scan(angle, 1)) == 0) angle++;
cannon(angle, distance);
drive(angle, 100);
}
}
}
Download the source here.
You can see how easy it is to start coding JRobots. What are you waiting for?
See you in the arena. My JRobots are Bizarro, Janeway, Shrike and CounterStrike.
![]() Nitin |
August 10, 2009: 12:57 pm
hi, |
![]() sandesh nawadkar |
si Paijah