A First Look at C++Robots (Greg Lindahl)

[ This is an article from the Play-By-Electronic-Mail Fanzine, v94n7, which was published on October 31, 1994. ]

Richard Roglie's abstract games server has a new and definately non-abstract game available: C++Robots. Some readers might be familiar with the game C Robots, which dates back quite a few years. I wrote a version of Pascal Robots in 1983 as a term project for a programming class, and it wasn't that novel at the time, so these sorts of programs have a long history.

The basic premise of the game is that there are two robots in a square room. Each robot has a gun, a scanner which can detect the other robot, and some means of moving around the room. The robots are controlled by a computer program written by the players.

[ Regular readers of this fanzine, or _Scientific American_, will note that this game is somewhat similar to `Core Wars', a game of battling computer programs. For more details about that game, see PBEM volume 94 number 2. ]

As the name of the game implies, these programs are written in the C++ programming language. No features of C++ are actually required, so anyone who knows C will also be able to play.

Here's an example program:

#include "robots.h"

main() {

int angle, range;

  while (1) {
    angle = rand(360);
    range = scan(angle,5);
    if( range > 50 && range < 7000 )
      cannon(angle, range);
  }
}
This program simply sits in place, and scans randomly in all directions. If an enemy is detected, and is in range but isn't so close that I'd be caught in the explosion, I fire at it.

As you might imagine, this program doesn't do very well in the arena. A clever robot remembers where it last saw the enemy, and uses this information. I wrote such a robot, and here's some example output from the adjudication program:

   Program Name Age Score  W / L / T  Author
   ============ === ===== =========== =====================================
 1 sidetracker2   3   284  94/  4/  2 hansk@netcom.com (Hans Kellner)
 2 xenophage      3   261  86/ 11/  3 tdavis@garnet.acns.fsu.edu
 3 assassin       3   250  83/ 16/  1 tdavis@garnet.acns.fsu.edu
 4 gargoyle       3   205  65/ 25/ 10 tdavis@garnet.acns.fsu.edu
 5 strafe         3   199  66/ 33/  1 wfp5p@tigger.itc.virginia.edu
 6 slither        1   182  57/ 32/ 11 tdavis@garnet.acns.fsu.edu
 7 strafe2        3   181  60/ 39/  1 wfp5p@tigger.itc.virginia.edu
 8 backscan       3   151  50/ 49/  1 hanwen@stack.urc.tue.nl
 9 predator       3   147  49/ 51/  0 rrognlie (Richard Rognlie)
10 tracker        3   141  47/ 53/  0 rrognlie (Richard Rognlie)
11 stalker        3   141  45/ 49/  6 rrognlie (Richard Rognlie)
12 shadow         3   136  45/ 54/  1 wfp5p@tigger.itc.virginia.edu
13 shadow2        3   115  38/ 61/  1 wfp5p@tigger.itc.virginia.edu
14*new sitter8    0   112  31/ 50/ 19 gl8f@fermi.clas.virginia.edu
15 sitnspray_ba   3    99  29/ 59/ 12 s004tro@alpha.wright.edu
16 old sitter8    3    92  24/ 56/ 20 gl8f@fermi.clas.virginia.edu
17 circle         3    86  20/ 54/ 26 sgoehrin@copper.ucs.indiana.edu
18 laser          3    83  21/ 59/ 20 wsheppar@st6000.sct.edu
19 3laser         3    78  19/ 60/ 21 wsheppar@st6000.sct.edu
20 nisse9         3    76  13/ 50/ 37 Magnus.Lindberg@eua.ericsson.se
My program was "new sitter8". When you submit a program to the adjudication program, you fight 5 battles against every other robot to see who is the "King of the Hill". Your individual results are also shown:

  vs. sitter8      W/L/T
  ================ =====
  new sitter8      4/0/1 
  sidetracker2     1/3/1 
  xenophage        0/5/0 
  assassin         1/4/0 
  gargoyle         0/3/2 
  strafe           2/3/0 
  slither          1/3/1 
  strafe2          1/4/0 
  predator         5/0/0 
  backscan         1/4/0 
  tracker          1/4/0 
  stalker          1/4/0 
  shadow           1/4/0 
  shadow2          2/3/0 
  sitnspray_bad    2/0/3 
  old sitter8      2/2/1 
  circle           1/0/4 
  nisse9           3/0/2 
  3laser           2/1/2 
  laser            0/3/2 
As you can see, my program did very poorly against some programs such as "xenophage", but beat "predator" 5 times out of 5.

At this point, the C++Robots adjudication program is pretty young, and still has an occasional bug. The help files are a bit incomplete, and there is no simulator available to test programs against each other and see what went wrong. I have the source code to "tracker", which beats me 80% of the time, but short of just staring really hard at the source code, I have no idea of figuring out why I lose to it so frequently.

If you're interested in learning more, send email to the address `pbmserv@gamerz.net' with the word HELP in the subject. If you would like to talk to a human about the game, send mail to rrognlie@gamerz.net. Good luck.

(Edited by Greg Lindahl) (lindahl@pbm.com)