Back to Agent's Blog
Created 13 November 2006 | Last Edited 02 February 2009
PCRobots A programming game | When I was working as a Software Engineer back in the 90's, I remember having a whole lotta fun (during smoko breaks etc) writing PCRobots to compete with those written by my co-workers.
Unfortunately, some of my less scrupulous, "hacker" colleagues soon figured out how to circumvent the official PCRobots API by directly accessing live data structures in memory, which of course gave their bots a very unfair advantage! I did actually toy with the idea of rewriting PCRobots in protected-mode at the time, which would have prevented this kind of insidious cheating, but alas I never got around to it.
Now that I have the time, I'd like to do a remake of PCRobots. Unlike the original, however, it will be cross-platform (Windows, Mac OS X, Linux) and it will be a multiplayer, networked application - i.e. instead of the main PCRobots application loading all the bots into memory as individual tasks (and communicating with them via DOS software interrupts) each bot will run as a completely separate program, communicating with the PCRobots "server" via UDP packets.
The server itself can run either on the same local machine as the bots, or on a remote host.
I intend to code it in C and use Allegro or SDL for graphics/sound, with perhaps Gnet or Enet for networking. Blitz Max is also a possibility; perhaps I'll prototype it in BMax and then port it to C.
At this stage I plan to provide API wrappers that will allow bots to be written in Blitz Basic (via DLL userlib), Blitz Max, PureBasic or C.
Initially, the graphics will be identical to the original DOS version, but once I get the basic engine working, I'll of course soup it up with better sprites and sound effects, etc.
Later, I might try upgrading the graphics to a full 3D version, with the bots perhaps represented as battle tanks. The user will be able to enter the arena and observe the bots doing battle, rather like in Counter Strike after you have been killed. I guess actually using the Source Engine is a possibility too, but that's quite a way down the track at this stage.
The API will, for the most part, be identical to the original PCRobots API. This will enable bots originally written for the DOS version to be easily ported (some of which will be included as examples).
Maybe if there's enough interest, we can hold a PCRobots Tournament as a Wednesday Workshop or something 
31 Dec '06
I think I'll use this blog as my worklog, at least until I have something ready to post in the Showcase section.
I'm coding it in BlitzMax, just to see how that goes. At first, I considered just porting most of Paul Smith's original C++ code, but instead I decided to start from scratch with a new architecture of my own design. The C++ source is mostly DOS-specific, which of course I don't need. Nevertheless, I'm extracting as much of the original code as is necessary to faithfully reproduce the functionality of the original DOS version.
Completed so far:
* All graphics (screen resolution independent)
* Arena class and Map file loader
* Robot class
* Some of the API
Next:
* Cannon class
* Complete API & test all functions
* Produce .ogg files from original DOS sound effects
The plan is to test the API with "internal" robot mini-programs and then, after everything checks out, implement the network feature. I'm looking at using either GNet/Enet (which is directly supported in BlitzMax) or Krylar's K-NetLib.
At this stage, K-NetLlib looks like it might be the better option, because it's directly supported by PureBasic and also Cobra. Because BlitzMax can't be used to build DLL's for Windows, I plan to use PureBasic to implement the client APIs. PureBasic is also cross-platform, so I should be able to use most of the same code for the Mac and Linux plug-ins.
And, courtesy of Filax's K-NetLib module for BlitzMax, I'll be able to use it for the PCRobots Server application as well.
26 Feb '07

Well, everything was going quite well with Blitz Max until I tried to run it under Windows 98 on my old laptop (a 133MHz Pentium). The graphics were all screwed up, and it ran incredibly slow. Why should it be so bloated and slow compared to the original DOS version? My Blitz Max code certainly isn't inefficient - in fact I took great pains to write quite optimal code.
Anyway, the upshot of it is that I've become dissatisfied with the limitations of Blitz Max, so I've decided to recode the whole thing in D - using SDL to handle the graphics, sound and keyboard input, etc. It was always my long term plan to migrate to D as my primary language, and now that a stable Version 1.0 has recently been released by Digital Mars, I may as well take the plunge.
So, apologies for the delay, but it'll take a little while longer for me to learn D and also get familiar with the SDL API.
Stay tuned, I promise PCRobots v2 will happen, eventually... 
24 May '08
Still experimenting with various languages and libraries in order to determine the best solution for cross-platform implementation.
In the meantime, here's some code I've written that might be useful to any Forth programmers out there who are interested in having a play with the DOS version of PCRobots.
The following Forth program is a port of P.D.Smith's "Simple" demonstration Robot (C and Pascal versions were included in the original PCRobots package). It compiles to a .COM executable, 525 bytes in size.
Note - the main PCRobots website seems to have gone offline, but its archive can still be accessed via the Wayback Machine: here
23 Nov '08
Hmm... after taking some time to learn and play around with the D and eC languages a bit, I've decided that I might give Blitz Max another shot.
After all, I never really bothered to investigate just why my original code was so sluggish — it could well be just that my way of using the API was inefficient. On reflection, there's probably no good reason to jettison the code I've already written; especially since any speed bottleneck is likely to be localized and can thus be easily optimized with C or even assembly language, if necessary. So then, back to Blitz Max it is 
3 Feb '09
Arrgh! Still no progress. Will I ever get this project finished?
Now I'm thinking "to hell with Blitz Max". D+SDL is where I really want to be. |
Latest Comments
| Posted : Monday, 13 November 2006, 22:23 |
hyruleknight
 
| cool, i will help if i can. i have a PC that you can use as a linux server
as long as the program for the server does not use any graphics when running it will run fine as a test server with a little RAM upgrade
| | Posted : Monday, 13 November 2006, 22:37 |
Agent

 
| Thanks, hyrule. I'd appreciate any help.
Actually, what I had intended was that the server would be the one with the graphics, so you can see what's happening with all bots, with the bot programs not having any graphics.
But I suppose it can be flexible; the server could just be a CLI app which dumps the results into a text file or something.
And I guess it won't be much fun running your bot remotely and not being able to see what's going on.
But the thing is, the Server knows where all the bots are, whereas individual bots only know their own position, plus the location of any nearby enemy bots that they're able to detect using their scanners.
| | Posted : Monday, 13 November 2006, 23:12 |
hyruleknight
 
| hmm, well since only i would see what the server's output would be you should only focus on the server outputing text for debugging and get the UDP packets flying out of it
also my home is on a highspeed connection with a wireless network.
and planning this would go a lot faster in the gabbly chat
| | Posted : Monday, 13 November 2006, 23:25 |
Agent

 
| Sure thing, but the idea with the server program is that it can also be run on the same machine (with graphics) as your bot.
This is so you can test, tweak and perfect your bot before unleashing it in the official tournament 
| | Posted : Monday, 13 November 2006, 23:34 |
hyruleknight
 
| but then it is not a server mode but a test mode. the actual server will have no interaction with a user besides debugging and there fore would not need graphics
| | Posted : Sunday, 03 December 2006, 10:34 |
slobbit
 
| Agent Smith, good luck with the project and I really hope that you complete it. I too got hooked by the game in the mid 1990s, more than any other computer game that I have played before or since.
Incidentally, I recently got the original DOS PCRobots running on my PC under DosBox and it brought back all the memories!
The biggest site I have found with example robots is the University of Frankfurt:
http://www.informatik.uni-frankfurt.de/~hbecker/pcrob.html
| | Posted : Sunday, 03 December 2006, 13:02 |
Agent

 
| Thanks, slobbit. Great to hear that there are still other PCRobots fans out there 
My PCRobots remake will definitely be completed, but atm it's No. 2 in the queue. I'm just prepping an article for post first, then I'll clear my desk and it'll be full steam ahead.
Yes, I was aware of that site you mentioned (link in my blog) which appears to be the main PCRobots website and repository for PCRobots exe's.
A while ago I also searched for PCRobots tournaments, but wasn't able to find any still being run.
I'd be interested in the source code for any of your own PCRobots, if you still have them and wouldn't mind sharing. But I'll understand if you don't want to reveal your secret algorithms (for potential use in future tournament entries).
I've also got the original PCRobots running on DOSBox under OS X on my Mac 
| | Posted : Monday, 04 December 2006, 14:44 |
slobbit
 
| I am happy to provide source code for one of my robots (not the best, I am keeping that for later!) and a few others, including the strong "Tilly" robot.
I used to compile my own robots with Borland Turbo C++ which is now available free of charge (as is Turbo Pascal) from:
http://bdn.borland.com/museum/
Let me know how to send the files to you.
| | Posted : Monday, 04 December 2006, 15:58 |
Agent

 
| That would be much appreciated if you could email it to me.
Is your Tilly by the same author as Tilly_9 (#8 from the website)?
So far I have the sources for Simple, Demo, Explorer, Gamma, Si2, and Termis - all of which I will port and include as examples with my remake.
I also used to program my bots in Turbo C, but I switched to DeSmet C because it generated smaller .exe's, allowing a larger program
(a "do nothing" null program in DeSmet C is only about 1.5k in size). I also did an API so I could use Janus/Ada 83.
| | Posted : Tuesday, 05 December 2006, 11:25 |
slobbit
 
| I have just sent you source code for the following:
Tilly v1 to v9 (Tilly9 came 8th in the competition)
Slime (40th in the competition)
Control (one of mine)
Snark0 (another of mine)
Apart from my own robots and those you already have, these are all the source codes that I have available.
| | Posted : Tuesday, 05 December 2006, 14:07 |
Agent

 
| (slobbit)
I've sent you an email reply already, but thanks again for providing me with the source code for some particularly strong robots.
(others)
slobbit is actually none other than the author of PCRobots Competition winning entry "Snark1b" 
| | Posted : Saturday, 25 August 2007, 03:43 |
slobbit
 
| Agent Smith, I hope that you are having more luck with the PCRobots rewrite in D.
I fired up DOSBox a couple of times recently and made some improvements to my old Turbo C++ robot. Now I just need an opponent!
I have taken a look at RoboCode, but the game is not as deep. A RoboCode robot dodges bullets by moving from side to side. A PCRobots robot dodges shells, requiring prediction and movement in two dimensions.
When the time comes, if you need a tester then please let me know.
| | Posted : Sunday, 26 August 2007, 15:44 |
Agent

 
| Sorry I haven't been able to get it finished yet, unfortunately the real world keeps monopolizing my limited hobby time. The project is progressing (albeit slowly) so please stay tuned.
I hadn't heard of RoboCode and I'm not a Java programmer, but I'll have a play with it anyway. I know there are a number of similar games out there; maybe they'll give me some ideas for future PCRobots improvements.
Thanks for the offer to test, I'll be sure to send you a Beta version to try out as soon as it's ready.
| | Posted : Sunday, 26 August 2007, 20:43 |
Nolan
 
| I remember RoboCode from way back when I began programming. Good fun!
I'm really looking forward to seeing this project progress, Agent Smith.
|
|