You can get the latest source to Grobots by anonymous CVS from grobots.cvs.sourceforge.net. (Use CVSROOT=:pserver:anonymous@grobots.cvs.sourceforge.net:/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 20 August 2008 (260KB).
Grobots is free software, distributed under the GNU General Public License.
Organization of the Code
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.
Support
General-purpose, lower-level code used by the rest of the system.
- GBPlatform.h
- File for platform conditionalization.
- GBNumber
- Fixed-point number class, used throughout the simulation and brains.
- GBFinePoint
- 2-vector of GBNumbers, used for positions and velocities.
- GBColor
- A more convenient representation of colors.
- GBErrors
- Most of the exception classes live here. (Maybe they shouldn't.)
- GBTypes.h
- Header file defining a bunch of widely used types and synonyms.
- GBLongNumber
- Extra-precision GBNumber, used for keeping scores.
- GBSound
- Some simple asynchronous sound functions.
- GBDeletionReporter
- Mixins for classes whose instances tell their dependents when they're deleted, to get around the lack of garbage collection.
- GBModel
- Mixin to keep a
version number
on an object, so views can tell when it's changed.
- GBRandomState
- A random-number generator.
- GBstringUtilities
- Various string utilities.
- GBGraphics
- Three classes for portable graphics.
- GBMilliseconds
- Portable timer function. (GBMilliseconds.h is the smallest file in Grobots.)
Sides
This part describes sides. Some state is also here, but ought to be split out. Everything here should be portable.
- GBSide
- Side spec class.
- GBRobotType
- Type spec class.
- GBSideReader
- Loads side files.
- GBHardwareSpec
- A huge file describing the nature of hardware.
- GBScores
- Several classes for scores and statistics.
Simulation
Everything here should be portable.
GBObject and GBWorld are the heart of the engine.
- GBObject
- Abstract class for simulation objects (sprites).
- GBObjectWorld
- Class that holds GBObjects and supports some operations on them.
- GBWorld
- Subclass of GBObjectWorld, with more features and a roster. This is an important class.
Lots of files containing subclasses of GBObject:
- GBDecorations
- Purely decorative sprites that have no game effect, like smoke and sparks.
- GBFood
- Classes for food.
- GBShot
- All shots, including syphons, force fields, and explosions.
- GBSensorShot
- Sensors are implemented using a
sensor shot
, which sees things by colliding with them.
- GBRobot
- Most of the actual work is in GBHardwareState.
Other files supporting GBRobot:
- GBHardwareState
- Unwieldy file describing most of the behavior of hardware.
- GBMessages
- Most of the message-passing communications system.
Brains
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).
- GBBrainSpec
- Abstract class.
- GBBrain
- Abstract class.
- GBStackBrainSpec
- Spec for the usual kind of brain. Represents compiled code, mostly. Also contains part of the compiler.
- GBStackBrain (including GBStackBrainPrimitives.cpp)
- Brain class: a simple stack-based virtual machine.
- GBStackBrainOpcodes
- Names of stack brain primitives.
Views
This is a portable view system.
- GBView
- Abstract view class, and a few useful subclasses.
- GBListView
- Parent class for RosterView, ScoresView, and any other views that are lists of something.
- GBPortal
- The main view.
- GBRosterView
- GBMiniMap
- GBScoresView
- GBRobotTypeView
- GBTournamentView
- GBDebugger
- GBAboutBox
UI
Top-level cross-platform user interface code. Nothing outside this part depends on anything in it.
- GBApplication
- GB-specific application-scope stuff.
- GBViewsApplication
- Non-Grobots-specific cross-platform application framework.
- GBWindow
- Cross-platform wrapper class for a window containing a view.
- GBMain.cpp
- This is a boring file, containing
main() and nothing else.
Mac
- Mac Interface.rsrc
- Mac-specific resource file, containing menus and dialogs.
- Grobots*.make
- MPW makefiles.
- Sounds.rsrc
- Resource file with sounds.
- Carbon.rsrc
- Resource file with one resource needed for the Carbon build.
- Grobots.xcodeproj
- Project for building with XCode.
- info.plist
- Property list for OS X build.
- Grobots_Prefix.pch
- Prefix header for XCode. (It's useless. How do I turn it off?)
Win
- Menus.rc, grobots.ico
- Windows-specific resource files.
- Grobots.dsw, GrobotsWin.dsp, GrobotsHeadless.dsp
- Build files for Microsoft Visual C++.
Problems
- 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 library
- Collections in various places (roster, types)
- Standard exception classes
Porting
Headless
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.
- GBPlatform.h
- Add an
#if defined to identify your compiler and platform, if it's not there already.
- GBMilliseconds
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 GUI
- GBGraphics
- 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.
- GBErrors
- There are two error-reporting functions in GBErrors.cpp that need porting. These should be easy.
- GBSound
- This is stubbed out by default, so don't worry about it.
- GBWindow
- A way to make windows containing a GBView.
- GBViewsApplication, and GBApplication
- 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.
Sending Patches
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.
To-do list
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 top of the lists are more pressing; ones at the bottom are unlikely to ever happen.
Most urgent todos
If you're looking for something to do, try:
- Make a good icon for the OSX build.
- [Windows] Fill in missing parts of the GUI: keyboard shortcuts, Rules dialog,
Views and UI
- [Mac OS X] Why is blitting to the screen so slow?
- Bug: framerate is irregular on Slowest.
- Bug: Doubletime sometimes shows garbage, and is missing on the cumulative side.
- [Windows] Replace confusing Abort/Retry/Ignore dialog for NonfatalError with Quit/Abort/Continue.
- [Windows] Add keyboard shortcuts in menus.
- [Windows] Allow opening sides from command line.
- [Windows] Make Rules dialog work.
- Support graphing of more statistics.
- [OS X] Put Quit in the application menu, not the File menu.
- Save window positions and states.
- Make blasters prettier: directional line, varying thickness, more color variation.
- Add more hardware variables to the debugger, and color-code them.
- Show last non-gensym label in debugger, to help navigation.
- Debugger should show multiple words on one line.
- Show overall hardware statistics in Types view when no type is selected.
- Make more information visible (sensor results, sensor foci, engine use).
- [Windows] Make confirmation dialog work.
- [Windows] Make tournament length dialog work.
- Bug: profile times are sometimes nonsense.
- Use GBView::lastDrawn for GBRosterView's framerate? (But it's private.)
- Move click-counting to GBView?
- Allow scrolling with arrow keys.
- [Mac] Open all sides in a dropped folder.
- Confirm (once) before using destructive tools during tournaments.
- Bug: following jumps far ahead of syphons and forcefields.
- [Windows] Bug: Closing a child window sometimes buries the main window.
- Alternate portal background? (What's the point?)
Engine
- Keep more statistics in history.
- Add a better language for brains. (Lisp? Lua?)
- Replace GBNumber methods like
Sqrt with overloaded functions, to make switching number types easy. Once that's done, we can try using floats instead of fixed-point numbers without breaking anything.
- Report starting line numbers of unclosed compile-time words.
- Make forcefields and syphons move instead of dying and being recreated, so they can be usefully followed. (Either shot or robot might get deleted, so whoever keeps the reference will have to listen for this.)
- Profile and optimize. (Why is Act taking so long?)
- Don't make decorations when no one's going to see them.
- Track more total hardware (combat fraction?).
- More statistics (who killed who?)
- More flexibility in sensors: filters, sorting, tracking?
- Add world-in-use layer between
GBWorld and GBPortal. (viewpoint, tournament parameters, selection)
- Add fake
time-limit.
Rules changes
We are reluctant to make these changes because they would alter the rules in ways that change the performance of existing sides.
- Bug: shields reduce syphon effectiveness twice.
- More robust seed placement (avoid placing seeds close together).
- Find a better way to discourage large cells in combat than the current extra damage.
- Remove or fix shields. (absorb damage? what's the goal?)
- Fix forcefield balance, possibly by reducing stacking.
- Friendly syphons shouldn't show up on shot sensors.
- Experiment with stunners.
- Make shots last at least one frame. This might mean fiddling with phase order again.
- Physics experiments: dot-product engines? gradual weapon reloading?
Other
- More documentation, including user interface, and the rest of the overview.
- Write tests for lower two layers.
- Provide more help for would-be porters.
- Port UI to Linux.
- Merge GBTournamentView, HTML output, and headless output?
- Use STL (especially containers) more.
- Replace pointers with references where appropriate.
- [Mac] Convert FSSpecs to pathnames and use
ifstream to load sides.
Statistics
(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.
| Part | Files | Lines | Median | Mean
|
|---|
| Support | 26 | 2477 | 64 | 95
|
| Sides | 12 | 3177 | 205 | 265
|
| Brains | 11 | 2144 | 143 | 195
|
| Simulation | 21 | 3991 | 95 | 190
|
| Views | 24 | 2821 | 172 | 118
|
| UI | 7 | 1439 | 80 | 206
|
| Total: | 101 | 16049 | 92 | 159
|
|---|
The largest (and smallest) files are:
| File | Part | Lines
|
|---|
| GBHardwareState.cpp | Simulation | 819
|
| GBStackBrainSpec.cpp | Brains | 714
|
| GBApplication.cpp | UI | 667
|
| GBHardwareSpec.cpp | Sides | 648
|
| GBScores.cpp | Sides | 572
|
| GBSideReader.cpp | Sides | 569
|
| GBStackBrainPrimitives.cpp | Brains | 475
|
| GBObjectWorld.cpp | Simulation | 420
|
| GBWorld.cpp | Simulation | 418
|
| GBPortal.cpp | Views | 405
|
| GBMilliseconds.h | Support | 12
|
Grobots by Devon Schudy
and Warren Schudy