I've been thinking a lot about how to program a board game in the most customizable way possible. Something occurred to me...
In Invade Earth and some other experiments, I stored Map data in XML form for simplicity, while rule values and game state data are stored in Java class structures. But it actually would make sense to store everything in an XML document. The whole game state, including map data and global rule values (e.g. amount of $ for passing go, each square and game piece, etc.) could be stored as an XML tree. Moves would be stored as XML as well. This would facilitate transmission over and network and persistence, and most importantly... a user could edit a "game.xml" file in a text editor and customize the game to a great extent.
For example, had I done this in Invade Earth, the user would not be limited to the options in the "customize rules" window. You could open the "invadeEarth.xml" file and rig the decks to have different arrangements of cards, or edit the values on the cards themselves. No more hard-coding of data values in Java. Also, the user could adjust the type of units available for purchase, and so on.
Just some thoughts, for reference. I'll post again if this ever goes anywhere.
I can't remember if I heard about this on SP a while back...?
Anyway, I've been looking into Lua as a scripting language. It's pretty nice, and there is a Java library to interface with Lua. I'm having to recall all the things I learned about dynamic-typed languages in college :)
I'd like to experiment with a small game first, like Stratego, and then maybe try to do a bigger one.
Already there is a Lua/C boardgame package out there, but it is mostly for Linux and mostly for "simple" abstract boardgames like checkers/chess/etc.
Lua would obviously be preferable to the idea above, since it could store not only data and constants, but also rules. Even the data could be stored as a program; e.g. rather than copying a block of XML several times, use for-loop, etc.
That's a good idea... I've heard that Lua is really good for programming game logic (I can't remember which one, but there is some major game out there that uses it for AI).
I don't know much about Lua, but if it is at all like PHP and Python, Lua constructs can probably be stored in a file and restored later without fooling with XML at all. They could even be sent as objects directly over your connection to other players... again, if it is at all like the scripting languages I'm familiar with.
I've been experimenting it...
There's not a library for directly writing objects, but with a few lines of code it's easy to do. Basically you just spit out Lua constructors.
Looks like Lua is good for game logic, as they say. I programmed a Stratego (L'Attaque!) engine without a lot of hassle. (It's completely useable, but lacks an interface.)
Here's the awesome part... MMF2 has a Lua script object! It's not so terribly difficult to use either, actually it's simpler than Java or C, though the documentation isn't great.
I've started working on a battle engine for a Culdcept-type game, and a little bit of an interface on MMF2. I'd like to use Lua for the game logic (which is CRAZY complicated for Culdcept) and MMF2 for all the graphics/sounds/special effects, which is what MMF2 does best :)
http://en.wikipedia.org/wiki/Culdcept
Culdcept is basically Monopoly, but to "buy" a property, you summon a creature on it (a la Magic:TG). If you don't want to pay someone's rent, you can challenge them to a battle and try to steal the property. The complexity is in the variety of abilities that creatures can have and how they interact, as anyone who has seen Magic will understand....
Nice... that sounds interesting. MMF is great for graphics and sound, so why not?
Re: Customizable board game programming
That's a good idea. This leaves room for rule-changing as well... for instance, if a card changes the way the game is played. Of course, the best part of this structure would be that you could make similar board games quickly by using the same code.