BerryBots is a programming game. You write a Lua program to control a ship that competes in challenges or battles against other ships. The stage is also a Lua program and it controls many aspects of the gameplay.
User programs are coded in Lua, a lightweight and flexible programming language designed for this type of application, where one program is embedded into another. A few resources to get started:
A ship program can...
- ...move a ship by firing its thrusters.
- ...fire a ship's laser gun (primary weapon).
- ...fire a ship's torpedo gun (secondary weapon).
- ...see other ships and certain gameplay events, based on line of sight (i.e., not blocked by walls).
- ...control all ships on a team from a single program, with all ships' combined vision.
- ...draw debugging graphics to the screen.
A stage program can...
- ...configure the stage size, walls, zones, starting points, team size, battle mode, and stage ships.
- ...monitor everything in the game, decide when rounds end, when the game is over, and who wins.
- ...modify almost everything about ships.
- ...send custom events to ships.
- ...draw text on the screen.
- ...draw debugging graphics to the screen.
I'm a huge fan of Robocode. I've probably spent more time writing Robocode bots than anyone ever. Robocode was inspired by Robot Battle, which drew inspiration from earlier tank battle games... So BerryBots was certainly influenced by Robocode and its predecessors. I think BerryBots brings some cool new stuff to the table. I hope you'll agree. (And by all means, check out Robocode and those other games, too!)
First, it's designed from the ground up to run on the Raspberry Pi. You don't need anything besides what comes in Raspbian to get started writing and running your bots with a terminal and a text editor. You should have no problem running matches with a few moderately complex bots at a smooth 60 frames per second.
Perhaps the most unique aspect of BerryBots is the programmable stage. The stage is a user written program loaded at run time, just as ships are. The stage program dictates much of the BerryBots gameplay. You can see a wide range of gameplay styles in the sample stages, and these only scratch the surface of what could be done with the stage API.
You should always be careful running any kind of untrusted code on your system. But yes, I've done my best to create a secure sandbox for running BerryBots ships and stages. Specifically:
- Lua code has no network access.
- Disabled the following Lua/LuaJIT libraries:
io
- general filesystem accessos
- OS operations, like executing commandsdebug
- various ways of poking around the Lua statejit
- alters settings of the JIT compilerpackage.loadlib
- directly loads functions from C libraries
- Modified Lua's
require
,loadfile
, anddofile
functions to only load Lua source files from BerryBots data directories. - Disabled support for loading LuaJIT bytecode.
- Disallow running any packaged ships or stages that contain symbolic links.
I gave serious thought to avoiding the idea of having bots shoot at each other in any way. I decided that the gameplay dynamics of it are just too interesting to avoid it entirely. That said, I have a couple of points to offer:
- I've been careful to keep the violence squarely in the "cartoon violence" realm. The game uses simple 2D vector graphics. There are no detailed explosions or anything photorealistic. Lasers and torpedos are not typical real world weapons. Ships don't "die", they are "destroyed" (and can be revived!).
- By default, ships can only move. A stage has to enable "battle mode" to allow ships to shoot at each other. A lot can be done with battle mode off - many of the sample stages do not use battle mode. If you're averse to spaceships shooting each other, limit yourself (or your students / children) to these types of stages.
BerryBots uses a modified LuaJIT 2.0.x, which itself is a highly optimized version of Lua 5.1 with some features of 5.2. The changes made for BerryBots are centered on security and packaging of ships and stages.