So I've been thinking about writing a Board Game Construction Set. It's a pretty insane idea, essentially I want to write a framework for playing board games. The graphical portion is trivial: display the tableaux and pieces, etc. Even defining where the movement squares are and where the decks and discard piles are is simple: about as complex as building an HTML image map. The insane part is coming up with a "rules language" by which a game designer can describe how a game is to be played.

I make no distinction between "card" games and "board" games; card games are simply board games where the board layout is so simple you can visualize it on a tabletop. With a properly constructed BGCS, it should be possible to create games like Monopoly, Poker, Risk, or Chess. It should even be possible to create a game like Magic: The Gathering (MTG).

My suspicion is that custom components of each game can be written in a scripting language such as Ruby, and then the rules can be written out in a general format. If a game has a custom rule, code can be written to enable that rule, then the rule language can manipulate that rule. For example, consider the notion of "tapped" cards in MTG. The MTG cards could simply have a boolean state added to them called "tapped", and the card draw code could rotate the card in position on the table whenever it is tapped. The custom code could then define a "tap" command which can be enabled by the card if it has a tap rule.

Board games have a lot of common components: pieces, cards, tokens, dice, money. Dice are pretty straightforward. Cards are pretty complicated but in the end have some common actions and collections. Cards can be played, drawn, discarded, and in some games removed from play, but in the end you really just have decks and tableaus: draw piles, discard piles, "graveyards" and "removed from play" are just decks. Hands are decks that can be viewed and sorted by a player, while other players can see only how many cards are in that hand. Tableaus are areas on the table where cards can be placed, face up or face down, and either the custom code or the rules determine how they affect play.

Board games have a lot of common rules: how many can play, how to set up, how to determine play order and who goes first, steps that must be performed during your turn, and the conditions that end the game and determine the winner.

The rules language must either be aware of the objects in the game or be able to declare them outright. For example, a checkers game the language would probably just be aware that there are black and red pieces and black and red kings, while the rules language for Monopoly might start out aware of the concept of a "player token", but extend it to create the Shoe, the Terrier, the Plane, the Car, etc.

MTG would need both. Special rules for the core game would add properties like Banding and Flying, and actions like Tap/Untap, Attack, and Interrupt. Special rules for expansions would add new abilities like Rage and Shadow. But the rules language itself would also be taxed to the limit, defining the abilities and rules associated with each card in the deck.

The problem, then, is how to specify the rules language. Ideally I'd like something that looks close enough to English to be written by non-programmers. The idea being that once rules were written for MTG, a card designer should be able to create new cards by adding the card stats (color, type, power, life, casting cost, image file, flavor text) and then adding the rules for that card. In a VERY ideal situation, the rules language for the card would actually be readable by the game players.

In my head I keep envisioning simple rules like "Tap: Do 1 damage to target creature" where the engine has been customized to understand "Tap:" enables the tap command, "target creature" starts the "select_target_creature" code, and "Do ([\d]+) damage" invokes the damage code for that creature, allows players to Interrupt the action or play an Instant, then checks the target creature for the death condition.

knows that "Tap:" means "Add the command 'Tap' to the card UI" but the sentence "Do 1 damage to target creature" ALSO gets parsed out so that "target creature" invokes the UI code to select a creature in play, and "Do 1 damage" gets parsed out by the damage code (defender allowed to play an interrupt, card must be evaluated for death condition). Or more internal rules like "Creature: on death: place card in graveyard" or "White deck: draw: place top card in hand".

The more I think about this the more I think that making a generic rule language is NP-holycrap. Perhaps I should just be content to write a framework in the code, and then code rules for that game in the code?

Zillions even has an AI that can adapt to whatever ruleset a game has. The AI is really geared towards pure strategy games, though, and kinda bites at anything involving chance. It's an impressive feat nonetheless.

Zillions Of Games is designed to play perfect information games exclusively. This renders it of little or no use in fairly playing imperfect or hidden information games, such as card games. Instead, the program will automatically use all information available to itself, including the cards in the deck and the cards in the hands of all other players.

The Wikipedia article didn't mention this, but it is trivially easy for human players to get the above information as well.

There are many solitaire games that allow the user to create new games as well as edit the ones already set up.

Games with lots of rules and modifiers can be a quite a pain. The biggest thing I've ever done was a character generator for a Marvel Superheroes RPG in TI Extended BASIC, sometime in the early 1990's. It wasn't especially hard, just very tedious. But it sure saved time generating characters! It could spit out the stats to screen as fast as the Enter key could be hit. (Of course printing took longer...)

"I am a machine. I am a weapon of war. I am a destroyer of life in the service of life, the sword and shield of my human creators." Bolo Invincibilus, Mark XXIII, Model B (Experimental) 0075-NKE "Nike".

I spent dozens of hours just playing with "beat frequencies" with the 4-voice FM chip. I'd play one tone at 100Hz and another at 101Hz and listen to it go waaaAAAaaaAAAaaaAAAaaah....

If you played 100, 101, and -1, it sounded like spaceship engines. (Frequencies -1 through -4 were "white noise" sounds.)

* dodders off, happily lost in thought...

I did something similar on my old C64. Then I discovered a synthesiser listing in an old magazine and messed with that. It allowed you to specify attack, decay, sustain and release for the waveform so you could get all sorts of different "instruments".

Fun stuff, that.

anthonyr wrote:

At some point they added support for multiple voices, not sure if the kernel mixes the streams or if it's done in hardware... but I don't really care.

Since you don't care, I'll answer you. AFAICT, ALSA has always supported multiple streams when the hardware did. Recently, though, it also supports driver-level mixing by default. I know this because I was finally able to bury esound at a crossroads with a stake through its heart.

I spent dozens of hours just playing with "beat Since you don't care, I'll answer you. AFAICT, ALSA has always supported multiple streams when the hardware did. Recently, though, it also supports driver-level mixing by default. I know this because I was finally able to bury esound at a crossroads with a stake through its heart.

Well, whatever it is it started working without me doing anything in particular. I discovered it completely by accident. AC97 doesn't support multiple voices?

Not really surprising, that...

Last edited by anthonyr on Fri Oct 21, 2005 12:20 pm, edited 1 time in total.

Well, whatever it is it started working without me doing anything in particular. I discovered it completely by accident. AC97 doesn't support multiple voices?

Not really surprising, that...

Apparently so. I recall a box with a proper sound card (SB PCI128) working fine but AC97 threw a "can't open audio device" error. Perhaps the problem's in the AC97 drivers? IIRC they're reverse-engineered due to lack of specs, as with so much hardware these days.

Apparently so. I recall a box with a proper sound card (SB PCI128) working fine but AC97 threw a "can't open audio device" error. Perhaps the problem's in the AC97 drivers? IIRC they're reverse-engineered due to lack of specs, as with so much hardware these days.

Isn't AC97 a standard that many vendors implement?

Well, however they did it I only care that it works. I guess driver-level mixing will take a bit more CPU, but artsd takes CPU as well and has a lot more overhead. And it's an Athlon64, they don't make Athlon64s slow enough for it to matter...