A downloadable game for Windows

Overview

I wrote Robot Wars as a capstone lab for Applied Computer Programming, a new C-based second-year university course I created and taught. I developed it with LEGO Mindstorms robots being used for lab work as I believed that would be more engaging than having students code yet another Fibonacci sequence. It also had the benefit of giving them exposure to the nuances of interacting with physical hardware.

The robots had their OS replaced with BrickOS so they could execute custom programs written in C. Lab work had interesting challenges, such as reading in a giant (8') bar code, but my students really wanted some kind of arena competition as the final lab. I tried something with the physical robots the first year, but found the hardware wasn't up to the task, so I copied BrickOS's API and made a virtual arena.

The virtual arena supports customizable robots with user-provided names, images, and configurable sensors (both range and robot-detecting ). Each robot has a generator, and the program needs to decide where energy will be spent: charging lasers, running sensors, regenerating shields - or even firing off a turbo boost to ram opponents.

The work was done in 2006 so my options for graphic libraries were somewhat limited - I went with Allegro and it served the project very well. Unfortunately, the passage of time has rotted out the underpinnings of that library version and I'm unable to get the project compiling again (within a reasonable time frame).

So, what's included in this download is:

  1. An executable running two student bots from the 2007 competition. It executes on Windows 10 (though it's not very happy about it!)
  2. All of the source code, which could be used to create and compete your own robots, if you can figure out how to get a newer version of Allegro up and running.

Retrospective

Looking at the code, it kind of blows me away that I put this together. I built Robot Wars entirely on my own time and crunched like mad to have it ready for the competition - making the deadline by just a few days.

I modeled the BrickOS API closely - robots move by setting power to each tread. I did the math on robot sizes and tread movement to get them to mimic the real robots we had used in the labs. Sensors are limited by the number of available ports (despite returning fantastical data).

And for graphics - while Allegro gave me many tools, it was much closer to the hardware than modern engines. I had to be careful to create framerate-independent code. There was a lot of blitting between images to build the scene correctly with transparencies. I crafted sensor arcs by drawing a circle, drawing an arc of the correct number of radians into it, then filling in the rest of the circle with the transparent color. I made my own particle engine using linked lists! It was pretty wild.

Legacy

Robot Wars continues in use today at the Royal Military College of Canada - nearly 15 years later! The department still gathers for the end-course competition, throwing the action onto a projector for all to see and cheer on their favorite bot. That's really cool!

One former student who took the course and is now back as a professor is updating the code to use a new graphics library. He hopes to have it up on GitHub and open-sourced for anyone who wants it. When that happens, I'll link it here!

Download

Download
Robot Wars Example Executable and Source 1 MB

Leave a comment

Log in with itch.io to leave a comment.