An Homage to Crobots

Back in December of 1985, Tom Poindexter released a game called Crobots.[41] This game combined a custom C compiler and a stack-based virtual machine that compiled robot files written in a C-like subset and evaluated combat between multiple robots. This program compiled multiple robots, and then it could either display live results or just give you a summary of the match when it was over. Crobots was ahead of its time and, despite the relative lack of raw computing power of the era, it was, for all intents and purposes, real-time (limited by hardware clock speeds and a couple of other factors).

It wasn’t just a game, however. Crobots’ simplified C syntax and narrowly focused goal (kill your opponents without dying) made it an amazing tool to introduce programming languages and computer science concepts to eager learners. When I was 11 years old, I asked my grandfather if he could teach me C, as I’d just finished learning BASIC. He handed me the Crobots floppy disk and a printed copy of the documentation (complete with dot matrix feeder holes!) and left me to my own devices.

I taught myself C and a number of vital programming concepts by learning to build robots to compete against others. I was instantly entranced by the concepts of virtual worlds, computer programming, and game design theory. The rest, as they say, is history. I quite literally owe much of what I’ve been able to accomplish in my career to my childhood exposure to Tom Poindexter’s creation, and of course, to my grandfather for giving it to me.

The Rules of Crobots

The documentation for the original Crobots game is now available online.[42] You don’t need to read the original in order to implement the WebAssembly game, but I thoroughly enjoyed reading it for the pure nostalgia value.

Each robot in the game is essentially a tank. It can move in any direction by engaging its drive motor pointing in a direction indicated by a heading angle between 0 and 360 degrees. It also has an independently mounted cannon that can fire in any direction indicated by the same type of heading. Each robot’s compass is calibrated with East pointing to the right, as shown in the figure.

images/waros/compass.png

All of the robots occupy a 1,000m by 1,000m battlefield. The perimeter wall is dangerous and inflicts damage to robots upon collision. Robots colliding with each other also take damage. If you want your robot to survive and kill all of your opponents, your robot is going to need input.

The most important input is the scanner. All robot scanners have a range of 700m and can scan within an arc your robot specifies, with a maximum spread of 10 degrees. Damage in the game is doled out according to the following table:

DamageDescription
2%Robot vs. robot or robot vs. wall collision. Also stops the drive motor, setting the speed to 0.
3%Missile explodes within a 40m radius of robot
5%Missile explodes within a 20m radius
10%Missile explodes within a 10m radius

Other inputs include status information, such as the robot’s current location. There are some subtleties missing from the robot API, and so you’ll need to keep track of some information yourself like your current destination, your last heading, and so on. One final rule is that while every robot has an unlimited supply of missiles, only two missiles can ever be in the air at a given time.

Now that we’ve got the basic rules defined, let’s try and build an API that gives robots the tools they need for real-time combat.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.172.61