Free Republic
Browse · Search
News/Activism
Topics · Post Article

Skip to comments.

*NERD THREAD WARNING*: Robot Wars - Java Style (Awesome new Java based game type)
Earthweb ^ | December 17, 2001 | Mat Nelson

Posted on 12/20/2001 5:14:19 AM PST by Dominic Harr

Robot Wars - Java Style

By Mat Nelson

Robocode is a new twist on programming games such as CoreWars, RobotWars, and Robot Battle. It's like Logo, but with tanks, guns, and explosions instead of penup and pendown... and it's all in Java(tm).

The framework is simple: Robocode exposes a set of APIs you can call to interact with the game. In short, you write a Java class extending robocode.Robot... then by calling methods in the superclass, your actions take effect in the onscreen battlefield.

Here's a complete, super-simple robot:


import robocode.*;

/**
 * Devastator:  A not-all-that-devastating robot
 */
public class Devastator extends AdvancedRobot {
    /**
      * run - called by the game
      */
    public void run() {
         while (true) {
              turnGunRight(360);
               ahead(200);
               turnGunLeft(360);
               back(200);
          }
     }
     /**
      * onScannedRobot - What to do when you see an enemy...
      */
     public void onScannedRobot(ScannedRobotEvent e) {
         fire(3);
    }
}

Easy to learn but difficult to master, Robocode gives you complete freedom to code as you wish. Whether that be an EnemyAnalyzer running in its own thread to track enemy positions, a neural network, a predictive firing algorithm, a reusable wall-avoidance object, an abstracted set of classes to deal with the physics of the game -- whatever it is, the choice is yours.

The only thing Robocode requires is that you tell it what you want to do. Deciding what to do, and how you come to that decision, is completely up to you.

There are already hundreds of robots to test your skills against at websites linked from http://robocode.alphaworks.ibm.com/links/Links.html -- and you can safely run them in Robocode with its built in SecurityManager.

Upcoming Robocode features include: Team support with messaging, walls and objects in the battlefield, terrain, tutorials and objectives to complete... plus whatever else you help us dream up.

Robocode is available at: http://robocode.alphaworks.ibm.com/

The current API you can use to interact with the game can be seen at: http://robocode.alphaworks.ibm.com/docs/robocode/index.html



Click here for larger image


TOPICS: Miscellaneous
KEYWORDS: techindex
Navigation: use the links below to view more comments.
first previous 1-2021-27 last
To: Leroy S. Mort
Actually, I have to start work when my customers do, and they don't cut me much slack when it comes to getting things right, regardless of the hour. ;-)

I'm in the corporate womb. No one here even is comprehensible before about 10 am.

Half of us *never* are, actually.

(Which half am I in?)

21 posted on 12/20/2001 6:02:21 AM PST by Dominic Harr
[ Post Reply | Private Reply | To 20 | View Replies]

To: zandtar
Ooops, Try this Shockwave.com
22 posted on 12/20/2001 6:06:28 AM PST by SolitaryMan
[ Post Reply | Private Reply | To 8 | View Replies]

To: SolitaryMan
If you really want to play some great games online, go to http://www.shockwave.com

I like playing Tank Wars. Cool game.

23 posted on 12/20/2001 6:07:19 AM PST by backslacker
[ Post Reply | Private Reply | To 6 | View Replies]

To: SolitaryMan
Definitely much different games at this site now. 8)
24 posted on 12/20/2001 6:26:35 AM PST by zandtar
[ Post Reply | Private Reply | To 22 | View Replies]

To: Dominic Harr
There's a game very similar to this that's been around a long time -- RoboWar on the mac.

Some of the strategies seen there:

gun turret
wall-hugger
corner-hugger
wall-hopper (like wall-hugger, but will move to other walls if in danger/getting pounded)
corner-hopper
hesitator ( the idea being to use depletion of energy to halt one's movement, thus throwing off opponents' shots)
machine gunner ( overwhelming rate of fire. Overwhelms opponents that are "too smart" defensively.)
dasher ( rush opponent, deliver kill shot at close range )
a number of strategies depending on weapon type

Some of these strategies might not be applicable, depending on the game physics.

It has also been observed that many robots that rule in single combat often die quick, horrible deaths in a melee. Changing strategy for the number of opponents and/or the presence of teammates is a must.

25 posted on 12/20/2001 7:04:56 AM PST by Tauzero
[ Post Reply | Private Reply | To 1 | View Replies]

To: Dominic Harr
Bump! for later grabbing of URL.
26 posted on 12/20/2001 11:49:54 AM PST by Xenon481
[ Post Reply | Private Reply | To 1 | View Replies]

To: Tauzero
Cool info, thanks so much.

Now how can explain to my wife why I 'need' to waste a few hours?

27 posted on 12/20/2001 1:07:47 PM PST by Dominic Harr
[ Post Reply | Private Reply | To 25 | View Replies]


Navigation: use the links below to view more comments.
first previous 1-2021-27 last

Disclaimer: Opinions posted on Free Republic are those of the individual posters and do not necessarily represent the opinion of Free Republic or its management. All materials posted herein are protected by copyright law and the exemption for fair use of copyrighted works.

Free Republic
Browse · Search
News/Activism
Topics · Post Article

FreeRepublic, LLC, PO BOX 9771, FRESNO, CA 93794
FreeRepublic.com is powered by software copyright 2000-2008 John Robinson