You can get the latest source to Grobots by anonymous CVS from grobots.cvs.sourceforge.net. (Use CVSROOT=:pserver:firstname.lastname@example.org:/cvsroot/grobots.) Or view the CVS tree with your browser. You can also download the source in a zipfile. The latest version that we've gotten around to uploading is that of 26 August 2012 . Grobots is free software, distributed under the GNU General Public License .
Grobots is built in four layers. The lowest, Support, provides some useful portable library. The second (in three parts: Sides, Simulation, and Brains) implements the game engine. The third, Views, provides most of the user interface portably. The top layer, UI, embeds the views and engine in a cross-platform application. Lower layers do not depend on higher ones. Most of the names below correspond to a .cpp file and a header file.
When viewing the source code with a browser click on the revision number to view the file, not the filename as one might expect (which shows CVS history).
Here are the most important source code files for use when tracking down something for the documentation:
- Hardware cost and mass:
- Hardware functionality: usually
GBRobot.cpp, or elsewhere
- Overall side file format:
ui/GBApplication.cppand the code for the windows in the
Most of the rules are in these files and in methods called from these files.
General-purpose, lower-level code used by the rest of the system.
File for platform conditionalization.
Fixed-point number class, used throughout the simulation and brains.
2-vector of GBNumbers, used for positions and velocities.
A more convenient representation of colors.
Most of the exception classes live here. (Maybe they shouldn't.)
Header file defining a bunch of widely used types and synonyms.
Extra-precision GBNumber, used for keeping scores.
Some simple asynchronous sound functions.
Mixins for classes whose instances tell their dependents when they're deleted, to get around the lack of garbage collection.
Mixin to keep a version number on an object, so views can tell when it's changed.
A random-number generator.
Various string utilities.
Three classes for portable graphics.
Portable timer function. (GBMilliseconds.h is the smallest file in Grobots.)
This part describes sides. Some state is also here, but ought to be split out. Everything here should be portable.
Side spec class, equivalent to a side file.
Type spec class.
Loads side files.
A huge file describing the nature of hardware.
Several classes for scores and statistics.
Everything here should be portable. GBObject and GBWorld are the heart of the engine.
Abstract class for simulation objects (sprites).
Class that holds GBObjects and supports some operations on them.
Subclass of GBObjectWorld, with more features and a roster. This is an important class.
Files containing subclasses of GBObject:Edit
Purely decorative sprites that have no game effect, like smoke and sparks.
Classes for food.
All shots, including syphons, force fields, and explosions.
Sensors are implemented using a sensor shot, which sees things by colliding with them.
Most of the actual work is in GBHardwareState.
Other files supporting GBRobot:Edit
Unwieldy file describing most of the behavior of hardware.
Most of the message-passing communications system.
All brain-related stuff (both spec and state) is here. Only one kind of brain is currently used, but there used to be others (for hardcoded sides), and there could be more in the future (to support other languages, for example).
Spec for the usual kind of brain. Represents compiled code, mostly. Also contains part of the compiler.
GBStackBrain (including GBStackBrainPrimitives.cpp)Edit
Brain class: a simple stack-based virtual machine.
Names of stack brain primitives.
Each window displays a GBView.
Abstract view class, and a few useful subclasses.
Parent class for RosterView, ScoresView, and any other views that are lists of something.
The main view.
Top-level cross-platform user interface code. Nothing outside this part depends on anything in it.
GB-specific application-scope stuff.
Non-Grobots-specific cross-platform application framework.
Cross-platform wrapper class for a window containing a view.
This is a boring file, containing main() and nothing else.
Mac-specific resource file, containing menus and dialogs.
Resource file with sounds.
Resource file with one resource needed for the Carbon build.
Project for building with XCode.
Property list for OS X build.
Prefix header for XCode. (It's useless. How do I turn it off?)
Windows-specific resource files.
WinGrobots.sln, WinGrobots.vcxproj, WinGrobotsHeadless.vcxprojEdit
Build files for Microsoft Visual C++.
Grobots.dsw, GrobotsWin.dsp, GrobotsHeadless.dspEdit
Build files for old versions of Microsoft Visual C++.
- Hardware has big files and poor modularity.
- spec/state aren't distinguished for sides and types.
- GBStackBrain has poor modularity. Adding an operator requires changes to three files.
Places we could use the standard libraryEdit
- Collections in various places (roster, types)
- Standard exception classes
To begin with, port headless mode, which should be entirely portable. The main problem will be compatibility with your compiler. Grobots uses some C++ features which are not universally supported, such as long long, dynamic_cast, and std::string. You may also need to define some missing parts in Support. Simulation, Sides, and Brains shouldn't require any changes.
Add an #if defined to identify your compiler and platform, if it's not there already.
Milliseconds() should return the current time (since startup or whenever) in milliseconds. It doesn't need to be very precise. Once you have headless mode working, start on the GUI.
Porting the GUIEdit
Make these three graphics classes work on your platform. Some parts exist only for portability, so it's OK if they don't do anything on your platform. You can live without GBBitmap but you'll lose double buffering, trails, and the portal background.
There are two error-reporting functions in GBErrors.cpp that need porting. These should be easy.
This is stubbed out by default, so don't worry about it.
A way to make windows containing a GBView.
GBViewsApplication, and GBApplicationEdit
Make this framework work on your platform. This is the hard part, because GUI frameworks vary so much. Fortunately it's mostly independent from the rest of Grobots. Don't worry too much about sharing with the existing code; we can factor out the common stuff later. The Mac and Win folders should be replaced by an appropriately named one for your platform, containing makefiles and any other platform-specific files. Note that the interface may want to be structured differently on some platforms, e.g. panes instead of separate windows.
If you've ported part of Grobots, fixed a bug, or added a feature, we want your changes. Send patches to Devon or to the mailing list. Patches should include enough context that they can be applied even if other changes have been made. diff -u is good. Or give the old and new versions of each function modified. Or just send us the changed files.
See the Wishlist. These lists are mostly for the benefit of the maintainers, but if you feel like implementing some of these, go ahead. They're in very rough order of priority - items at the tops of the lists are more pressing; ones at the bottom are unlikely to ever happen.
There are automatically generated statistics at ohloh . (5 April 2003) I counted lines in the source, and was surprised to find it's over 16000 lines and a hundred files. I didn't count the makefile, which is mostly machine-generated, or the two resource files, which don't have lines.
The largest (and smallest) files are: