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
Neat stuff.</geek mode>

Please let's not turn this into a language wars thread. This is about a cool game idea.

1 posted on 12/20/2001 5:14:19 AM PST by Dominic Harr
[ Post Reply | Private Reply | View Replies]

To: Dominic Harr
Bump for a long Christmas break with something to do now!!
2 posted on 12/20/2001 5:15:20 AM PST by billbears
[ Post Reply | Private Reply | To 1 | View Replies]

To: billbears
I am definitely going to check this out tonight. Neat idea.

Man, do we need to get a life, or what?

My wife is going to hate this, I suspect.

3 posted on 12/20/2001 5:19:21 AM PST by Dominic Harr
[ Post Reply | Private Reply | To 2 | View Replies]

To: Dominic Harr
You need to change the html link to your picture. http://www.freerepublic.com/img/articles/2001/12/17/Robots.jpg won't get ya there. Take a little time to learn HTML.


4 posted on 12/20/2001 5:19:46 AM PST by Leroy S. Mort
[ Post Reply | Private Reply | To 1 | View Replies]

To: tech_index, stainlessbanner
Ping.
5 posted on 12/20/2001 5:20:54 AM PST by Dominic Harr
[ Post Reply | Private Reply | To 3 | View Replies]

To: billbears
If you really want to play some great games online, go to http://www.shockwave.com
6 posted on 12/20/2001 5:21:53 AM PST by SolitaryMan
[ Post Reply | Private Reply | To 2 | View Replies]

To: Leroy S. Mort
Take a little time to learn HTML.

Nice, rude comment. Haven't had your second cup of coffee yet?

It's 8 a.m., I'm barely awake. I am not a morning person, can't hardly see before 9. I just copied/pasted the story.

But thanks for your help anyway.

7 posted on 12/20/2001 5:22:54 AM PST by Dominic Harr
[ Post Reply | Private Reply | To 4 | View Replies]

To: SolitaryMan
Next time you might want to check your spelling in the HTML links...
8 posted on 12/20/2001 5:28:04 AM PST by zandtar
[ Post Reply | Private Reply | To 6 | View Replies]

To: Dominic Harr
C'mon Harr, if you don't know HTML, how are you gonna play Robot Wars?

Please go to your room & learn some HTML < /jokin'>

9 posted on 12/20/2001 5:32:52 AM PST by stainlessbanner
[ Post Reply | Private Reply | To 7 | View Replies]

To: Dominic Harr
You're quite welcome. There are any number of good books on HTML for the novice on Amazon. Plus look for the "HTML Bootcamp" threads here.
10 posted on 12/20/2001 5:33:15 AM PST by Leroy S. Mort
[ Post Reply | Private Reply | To 7 | View Replies]

To: Leroy S. Mort
There are any number of good books on HTML for the novice on Amazon.

I've been doing web work for about 8 years. I just didn't check that closely before pasting it.

The actual link used a relative filename -- "a href="/img/articles/2001/12/17/Robots.jpg" target=newFrame". You do know enough about HTML to know what *that* does, don't you?

11 posted on 12/20/2001 5:38:05 AM PST by Dominic Harr
[ Post Reply | Private Reply | To 10 | View Replies]

To: stainlessbanner
Please go to your room & learn some HTML

With 2 kids, I'd *pay* for some time alone in my room to read . . .

12 posted on 12/20/2001 5:39:54 AM PST by Dominic Harr
[ Post Reply | Private Reply | To 9 | View Replies]

To: SolitaryMan
Shockwave's pretty good, but I tend to play offline on MAMEs
13 posted on 12/20/2001 5:40:05 AM PST by billbears
[ Post Reply | Private Reply | To 6 | View Replies]

To: Dominic Harr
I am definitely going to check this out tonight. Neat idea.

Ten - fifteen years ago they had a text based c-robots game. Thousands of hours were spent playing that. One of the guys at IBM (I think) had developed a GUI tcl/tk based game similar to this one.

I remember one of the c based games had objects within the field of play that could be used to hide behind. It was always tricky trying to decide how "smart" to make your robot. Many times while the smart robot was deciding what to do, the dumb robot would blow it away.

Some of the more successful robots, IIRC, were A)corner-sitters - they just head for the nearest corner and blast the field, and B)the sideline robots - they just run back and forth down the side of the field and shoot.

I seem to remember a robot named Rabbit. It didn't shoot anything, just runs around the field so you can test your robots ability to shoot it.

Lots of fun to play with.

14 posted on 12/20/2001 5:41:05 AM PST by thatsnotnice
[ Post Reply | Private Reply | To 3 | View Replies]

To: thatsnotnice
Some of the more successful robots, IIRC, were A)corner-sitters - they just head for the nearest corner and blast the field, and B)the sideline robots - they just run back and forth down the side of the field and shoot.

Fascinating, thank you.

I'm thinking of starting with something that spins and shoots, just to try it out.

15 posted on 12/20/2001 5:43:43 AM PST by Dominic Harr
[ Post Reply | Private Reply | To 14 | View Replies]

To: Dominic Harr
I've been doing web work for about 8 years. I just didn't check that closely before pasting it.

Smiles.....attention to detail is so important, even in simple programming languages, isn't it? For a major graphic in your post, just replace the relative filename with the actual link. Double check in preview mode, and post. Really not that hard.

16 posted on 12/20/2001 5:46:58 AM PST by Leroy S. Mort
[ Post Reply | Private Reply | To 11 | View Replies]

To: Leroy S. Mort
Double check in preview mode, and post. Really not that hard.

Double-checking early in the morning isn't hard for you?

Believe me, being thorough this early is *very* hard for me. I'll make plenty of spelling errors, too.

For one thing, I went to see Lord of the Rings last night -- a 3 hour movie. Didn't get home till past midnight.

Awesome flick tho! I *highly* reccommend it!

17 posted on 12/20/2001 5:51:16 AM PST by Dominic Harr
[ Post Reply | Private Reply | To 16 | View Replies]

To: Dominic Harr
Oh great, just what I need, another time consuming diversion that my wife will no doubt roll her eyes at.

And just because I'm visiting the site and firing up my IDE does not mean that I like the idea. Not one little bit. I'll just code a few of these little time wasters to prove that they're time wasters. Yeah, that's it. And if they are not quite the time wasters I think they'll be, I'll code a few more to see at what point they become time wasters. Just to prove a point, mind you. :)

[/ability to lie off]

18 posted on 12/20/2001 5:54:04 AM PST by Lumberjack
[ Post Reply | Private Reply | To 1 | View Replies]

To: Lumberjack
Just to prove a point, mind you. :)

Of course, we understand.

Boy do I understand!

19 posted on 12/20/2001 5:55:14 AM PST by Dominic Harr
[ Post Reply | Private Reply | To 18 | View Replies]

To: Dominic Harr
Double-checking early in the morning isn't hard for you?

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 plan on seeing LOTR as soon as the geek love-fest thins out a bit and I have three hours to spare.

20 posted on 12/20/2001 5:59:22 AM PST by Leroy S. Mort
[ Post Reply | Private Reply | To 17 | View Replies]

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]

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