Procedural Card Generator
The procedural card generator in Chaos Cards is implemented in GIGL. The probabilistic grammar to generate content is called an item grammar in GIGL, which requires expansion rules to be named. Each generated item by the system are represented with an instance from the possible hierarchical structures encoded by the grammar, which is called an item tree in GIGL. This page only shows fraction of the grammar, for documentation of the full grammar, please refer to the other page and its subpages.
The left part of the figure above shows the probabilistic grammar (item grammar) for the card generator. The ``..." are omitted parts and constraints are also not shown. he grammar contains rules specifying how a nonterminal node can be further expanded to nonterminal or terminal nodes (including empty). The rules are grouped by which nonterminal type it expands from. The card generation process starts from a starting node (of CardRoot type) and stochastically and recursively select from applicable rules to expand nonterminals until all branches researches terminals. For example, a CardRoot node can be expanded by stochastically choosing one of the three rules, leaderCard, minionCard, or spellCard. If selecting minionCard, then three integer terminals needs to be determined for cost, attack, health respectively, and four other nonterminals of type AtkTimes, MinionType, Abilities, Effects needs to be further expanded (the attack times are represented by a nonterminal instead of an integer terminal only because it is one good way to control majority to be single attack, which is the case for most card game design). The giveEffectsEff rule is one example that brings recursive possibility to the system, as it requires going back to a nonterminal type the expansion already passed through. GIGL's constraint systems are used to limit the recursive depth (nesting depth) of such effect to prevent over-complicated cards. Constraints are also applied to other situations, e.g. only minions can select a deathrattleEff rule, and only spells can select a untargetedBattlecryEff rule.
The right part of the figure above shows the hierarchical structure (item tree) of an example card. The blue rectangles are nonterminal nodes along with the rule selected. The trapezoid are subtrees with internal structures not shown. The small red squares are pointers to nonterminal nodes, the small green square(s) are terminal nodes (empty terminals omitted). It essentially encoded the choices made in stochastic steps in the process of generating this card, e.g. the spellCard rule is selected at the first step when expanding the starting CardRoot node. This illustration shows the modular and structured design of the system, which implies significant varieties encoded by the system. The item trees (i.e. the internal structures) are maintained even after the card generation for a seamless and modular integration with the actual game functionality (the game simulator).
The item tree shown on the right figure above omitted details on some subtrees, which actually contains some structure suggesting combinatorial possibilities. For reference we put them below. Note that many nontermial and rule names are not present in the grammar in the left figure above, which is only because the grammar there also omitted many parts. They can be find at the full grammar page.
Here is the subtree for "no ability":
Here is the subtree for "enemy minion having at most 0 mana cost":
Here is the subtree for "character having at most 5 attack":