=Paper= {{Paper |id=Vol-3926/paper7 |storemode=property |title=MiniStS: A Testbed for Dynamic Rule Exploration |pdfUrl=https://ceur-ws.org/Vol-3926/paper7.pdf |volume=Vol-3926 |authors=Bahar Bateni,Jim Whitehead |dblpUrl=https://dblp.org/rec/conf/exag/BateniW24 }} ==MiniStS: A Testbed for Dynamic Rule Exploration== https://ceur-ws.org/Vol-3926/paper7.pdf
                         MiniStS: A Testbed for Dynamic Rule Exploration
                         Bahar Bateni1 , Jim Whitehead1
                         1
                             University of California, Santa Cruz (UCSC), Santa Cruz, CA 95064


                                           Abstract
                                           Specialized testbeds are valuable tools in game AI and procedural content generation (PCG) research, providing controlled environments
                                           to test and evaluate new algorithms and explore game mechanics. This paper introduces MiniStS, a research testbed modeled after the
                                           rogue-like card game Slay the Spire (StS), tailored for studying game-playing AI and procedural generation. MiniStS features a dynamic
                                           rule system where in-game cards can modify game rules, providing a rich context for research. We argue that such an environment offers
                                           distinct research opportunities by revealing insights into game design, enabling the exploration of rule combinations and synergies, and
                                           advancing AI capabilities. We define possible applications for MiniStS in terms of generalized game-playing that requires understanding
                                           and adaptability to the dynamic changes to the rules, and card generation with a focus on a deepened exploration of rule synergies.

                                           Keywords
                                           Collectible Card Games, General Game-playing, Automated Game Design, Procedural Content Generation



                         1. Introduction                                                                                                                               Dynamic Ruleset
                                                                                                                                          Designer
                         Game AI and procedural content generation (PCG) research                                                                         Rule       Rule      Rule      Rule       Rule
                         frequently benefits from specialized testbed environments
                         that are tailored to specific research needs. These environ-
                         ments provide controlled settings where new algorithms can
                         be developed and evaluated. Furthermore, they can enable
                         an examination of game mechanics and design principles.                                                          Player                          Playthrough
                            One prominent example of this is Infinite Mario Bros
                                                                                                                                                                            Game State
                         [1], a research testbed designed to emulate the classic plat-
                         former Super Mario Bros. Infinite Mario Bros has enabled re-
                         searchers to explore areas such as level generation [2, 3, 4, 5],                                            Figure 1: The structure of a game with a dynamic rule system.
                         game-playing AI [6, 7], accessibility [8], visualization of                                                  In such a game, the designer defines a set of possible rules or
                         playtesting data [9], and, venturing outside of games, soft-                                                 design elements in the game that can be combined together. The
                         ware repair [10]. GVGAI [11] is another testbed environ-                                                     game then allows the player to manipulate the design of the
                                                                                                                                      game through playing the game and activating certain rules.
                         ment which implements a variety of 2D arcade games, such
                         as Space Invaders, Pong, Solarfox, and more. Other research
                         environments include implementations of Angry Birds [12],
                         Overcooked [13], and Baba is You [14].                                                                       1.1. Dynamic Rule System Definition
                            In this paper, we introduce MiniStS,1 a simplified Python
                                                                                                                                      We define games with dynamic rule systems as games in
                         implementation of the rogue-like card game Slay the Spire
                                                                                                                                      which the rules can be changed by playing the game. One
                         (StS) [15]. MiniStS serves as a dedicated research environ-
                                                                                                                                      of the most interesting examples of this is the game Baba is
                         ment for investigating various aspects of game AI and pro-
                                                                                                                                      you [16]. In this game, the player can move blocks around a
                         cedural generation of cards. Similar to other collectible card
                                                                                                                                      grid-based level in a Sokoban style game. In contrast with
                         games, Slay the Spire includes cards that can affect the de-
                                                                                                                                      Sokoban, here the blocks can also represents game design
                         sign of the game by enabling or modifying certain rules of
                                                                                                                                      concepts and elements in the level. For example, if the player
                         the game. Because of this, it demonstrates characteristics
                                                                                                                                      moves the three blocks representing "Flag", "Is" and "Win"
                         that allow interesting research avenues.
                                                                                                                                      together, it results in activating a rule in the game were the
                            One of these characteristics is that a game-playing agent
                                                                                                                                      player touching the flag will result in winning the level.
                         in this game is required to have reasoning capabilities re-
                                                                                                                                         Baba is You is not the only game that utilizes a dynamic
                         lated to game design, since it needs to manipulate these
                                                                                                                                      rule system. Collectible card games often include cards
                         playable rules to its own advantage. Further, agents should
                                                                                                                                      which have game design implications. These cards can en-
                         be generalized enough to play the game while rules are dy-
                                                                                                                                      able or modify the rules of the game to some extent either
                         namically changing and adapt its strategies accordingly. As
                                                                                                                                      temporarily or for the duration of the battle.2,3 In these
                         for a PCG agent, it is necessary to not fixate on the context
                                                                                                                                      games, the players are invited to think about the conse-
                         of a single ruleset, but to consider all the possibilities arising
                                                                                                                                      quences of activating or modifying different rules in the
                         from combining different rules in different ways. We discuss
                                                                                                                                      game and use these changes strategically to their advan-
                         these properties and more in Section 1.2.
                                                                                                                                      tage.
                                                                                                                                         Another genre of games that have many examples of us-
                          11th Experimental Artificial Intelligence in Games Workshop, November                                       ing a dynamic rule system are roguelikes. The definition
                          19, 2024, Lexington, Kentucky, USA.
                          $ bbateni@ucsc.edu (B. Bateni); ejw@ucsc.edu (J. Whitehead)                                                 2
                                                                                                                                        An example of such a card in Hearthstone is Cold Feet which causes
                          € https://bahar.bateni.org (B. Bateni); https://users.soe.ucsc.edu/~ejw/                                      enemy minions to cost 5 more next turn. This card modifies the initial
                          (J. Whitehead)                                                                                                rule of "Card A costs X" for one turn.
                           0000-0002-0701-0311 (B. Bateni); 0000-0002-6887-7330                                                      3
                                                                                                                                        An example of such a card in Magic: the Gathering is Elder Mastery
                          (J. Whitehead)                                                                                                which enchants a creature so that whenever it deals damage to a player,
                                       © 2024 Copyright for this paper by its authors. Use permitted under Creative Commons License
                                       Attribution 4.0 International (CC BY 4.0).                                                       that player is forced to discard two cards. This cards adds a new rule
                         1
                             The code is available at https://github.com/iambb5445/MiniSTS                                              to the game for a certain creature.


CEUR
                  ceur-ws.org
Workshop      ISSN 1613-0073
Proceedings
of a roguelike game has been a point of debate in the com-
munity.4 However, one of the main goals of this genre is a                          Design                Gameplay
sense of exploration and a gameplay that varies every run.
Toward this goal, there are numerous examples of rogue-
likes that include rule-altering items in the game. The game
uses these alterations to not only provide a strategic aspect                   Rules
to the game, but also enable various possibilities in the way
the game is played. Examples of this type of gameplay can                                                                   Rules
be seen in roguelikes such as the Binding of Isaac [18], Hades
[19], Noita [20], Risk of Rain 2 [21] and more.
                                                                              Figure 2: The design space resulting from a single set of rules
   One important note is that the distinction between games
                                                                              in a dynamic rule system. The designer initially defines a set of
with static rule systems and dynamic rule systems is not                      composable rules in the game during the game design process.
always pronounced. For example, a first person shooter                        The player then dynamically changes the set of active rules during
(FPS) can allow the player to choose between weapons such                     gameplay by making in-game decisions. As a result, the player
as an sniper or an assault riffle, which affects the design                   to some extent collaborates on game design decisions.
of the game and subsequently the way the game is played.
However, the extent of these changes and the variety of the
possible designs that can be created by these choices are
more limited. Dynamic rule systems specially involve rules
that can be combined together and create a wide variety of                                     A
unique selections. Additionally, games with dynamic rule
systems rely on the changes to the rules as one of the main
components of the game.
                                                                               Rules                             Bad Design*        Good Design*
1.2. Dynamic Rule System Research
In the previous section, we describe a dynamic rule sys-
tem and the genres that frequently use such systems. In                                        B
this section, we argue that these games can provide unique
opportunities for research on games.
   First, games with dynamic rule systems can help us to dis-
cover novel viewpoints in understanding game design. For
                                                                                                                 Bad Design*        Good Design*
example, in Baba is Y’all [14], the authors describe how “the
game provides an interesting study for procedural level gen-                  Figure 3: Exploring the effect of adding rule A vs rule B in a
eration where game levels and game rules are intertwined.”                    dynamic design system. The effect of adding each rule should be
Not only does this introduce a new challenge to level design,                 viewed in terms of how it affects the space of valid combinations
where the game design and its possible outcomes should                        in the design space as opposed to in a single fixed ruleset. The
                                                                              good design and bad design visualizations are assumed according
be considered when designing the levels, but it also sug-
                                                                              to system’s design quality metric.
gests the possibility that this connection could have been
explored deeper in other games, even ones with static rule
systems.
   Second, dynamic rule systems can enable the study of rule                  for the agent to be able to understand this space to some
combinations in a way that cannot be explored in a static                     extent in order to steer toward designs that are better suited
rule system. As shown in Figure 2, in a dynamic rule system                   for the agent’s goals. The challenge for game-playing AI is
the set of available rules creates a space of possible designs                to reason about what effects its decisions have on the game
in which every valid point is the result of combining rules by                since these decisions relate to game design.
activating them in some order (in a card game, via playing                       Finally, it’s important to note that research on dynamic
cards). The player choices can then result in moving in this                  rule systems can be beneficial for improving the develop-
space from one point to the other, resulting in a different                   ment of such games. In other words, such research has ben-
experience every time.                                                        eficial impacts not only on game design and game-playing
   When taking the role of the designer and adding a new                      AI, but also on the development of new games with dynamic
rule to the set of available rules, the effect of this new rule               design systems. In roguelikes, random generation and PCG
should be examined on all the possible designs from every                     systems are often used to create a different experience every
possible combination. This effect can move the design points                  playthrough and foster a sense of exploration in the player.
in the space and result in a distribution of design points with               A PCG system designed specifically for dynamic rule sys-
a lower or higher design quality according to the relevant                    tem can enhance this design concept by ensuring that the
research metrics. Figure 3 visualizes this characteristic.                    procedural content aligns more closely with the evolving
   This study of rule combinations and synergies is not lim-                  gameplay, or expand the set of available rules by finding
ited to when an AI assumes the role of the designer. Simi-                    rules that fit its malleable rule system.
larly, when developing a game-playing AI, it is necessary                        In a similar fashion, the interactions between dynamically
                                                                              added rules is important in many games, especially card
4
    One popular interpretation of roguelike is the Berlin Interpretation,     games like MiniStS. When the cards are designed in a way to
    [17] which defines a set of characteristics expected from roguelikes.     enable various synergies and interactions between the cards,
    However, many of these characteristics, such as turn-based, grid-based,
    and ASCII art style, do not apply to a significant number of modern
                                                                              they enable lenticular design [22], a term introduced by
    roguelikes.                                                               Mark Rosewater, the head designer of Magic the Gathering.
Lenticular design is when understanding a card is more             as applying rhythm-based approaches [2], creating level
difficult for an experienced player compared to a beginner.        sections focused on certain mechanics [3], or composing
If the cards include many synergy effects when combined            predefined level sections [4, 5].
in certain ways, an experienced player would likely have              In addition to its applications in level generation, IMB
to consider all of these effects when playing. On the other        has also served as a gameplaying environment acting as
hand, a novice player would not understand these effects           a benchmark for artificial intelligence research [7]. This
and hence would not get lost in the complexity of the game.        resulted in the introduction of the Mario AI Framework
This is a desirable effect for game designers, since it means      [6], which has been utilized in AI competitions to evaluate
that the barrier to entry is low allowing novice players to feel   and compare various AI strategies. Beyond these applica-
comfortable playing the game with minimal instructions,            tions, IMB has also been used in visualizing and analyzing
while experienced players continue to find new layers of           play-testing data [9], exploring accessibility methods [8],
complexity to the game.                                            and contributing to fields outside of game studies, such as
                                                                   runtime software repair [10].
1.3. Slay the Spire                                                   Another research game environment is the physics-based
                                                                   game Angry Birds. Since the game Angry Birds does not
Slay the Spire is a single-player roguelike card game that has     have an open source implementation, Ferreira and Toledo
a strong emphasis on strategic play and card synergies. We         implemented a clone of the game for the purpose of explor-
chose this game to implement as the testbed environment            ing level generation in this game [12]. This environment,
since it has desirable characteristics from both roguelikes        named Science Birds, has been used to explore a variety of
and collectible card games.                                        level generation approaches such as procedurally construct-
   First, as with many roguelike games, StS is a single-player     ing and combining structures [23], utilizing Generative Ad-
game. The game is played against a set of pre-defined en-          versarial Networks (GANs) for level generation [24], and
emies that perform different moves with different proba-           using genetic algorithms [24]. Furthermore, Science Birds
bilities independent of the player actions. Therefore, the         has been selected as the platform for the GPT4PCG [25]
challenges of understanding the opponent skill level in eval-      competition in which the use of Large Language Models
uating game-playing capabilities of an agent can be elim-          in generating levels via effective prompt-engineering is ex-
inated in favor of focusing on an understanding of rules           plored. The AIBirds [26] competition also uses Angry Birds
and their combinations, both during game-play and during           as a testbed for both level generation and game-playing, and
design of these rules. Similarly, the strength of different        uses Science Birds for its level generation track.
cards or decks can be evaluated without considering how               The IMB and Science Birds testbeds are not the only ex-
well they perform against different opposing decks.                amples of re-implementing games for research. Hu et al. list
   Furthermore, the core loop of the game allows for an in-        other examples of environments developed for research pur-
cremental approach to deck-building. At the end of every           poses based on video games [27], some of which have been
battle in StS, the player is asked to choose at most one of        significantly simplified to better fit the intended purpose.
three possible cards to add to their deck. The increasing          These examples include a simplified version of Overcooked
level of difficulty for each battle and the enemies are care-      developed to experiment with cooperative abilities of AI
fully designed in a way that appropriately matches bigger          agents [13], a minimal implementation of Real-Time Strat-
and more powerful decks as the game progresses. Because            egy (RTS) game mechanics used for microRTS game AI
of this, a game-playing agent defined in this environment          competition [28], and an implementation of the Legend of
doesn’t need to necessarily be exposed to the challenges that      Zelda: a Link to the Past developed specifically as a PCG
arise from the vast space of possibilities for possible decks.     research environment [29]. It’s also worth noting that some
Instead, the agent can be tested in terms of combining rules       games such as Starcraft II provide an API for interacting
from a single set of cards in a pre-defined deck, and the          with the game which can be used to develop game-playing
game offers various examples of well-designed levels with          agents that can directly interact with the game via these
different degrees of difficulty suited for this evaluation.        APIs [30].
   Additionally, similar to most collectible card games, Slay         General Video Game AI (GVGAI) [11] is an example of a
the Spire is turn-based. As a result, game-playing in this         general purpose environment that provides a wide variety
environment can be done without any considerations of real-        of 2D arcade games as a testbed for evaluating AI agents
time play and mimicking human players in terms of reaction         in terms of general video game playing capabilities. The
time. The possibility of eliminating these challenges in StS       agents in this environment are expected to not be game-
is desirable since it makes the MiniStS environment better         specific, which requires them to be able to play games that
suited for our goals.                                              they have not been trained on. Similar to this goal, MiniStS
                                                                   also expects the agents to be able to adapt to changes in the
                                                                   rules of the game. However the StS environment requires
2. Related Work                                                    the game-playing AI agent itself to actively make changes
Research in games often utilize game environments that im-         to the rules through playing the game. This is an important
plement existing games to explore various aspects of game          difference that requires the agent to reason about how a
design, level generation, and artificial intelligence. As men-     specific rule would benefit or harm its chance of winning,
tioned earlier, one notable example is Infinite Mario Bros         and how best the rules can be composed to fit the agent’s
(IMB), a public domain clone of the classic Super Mario Bros.      goals. Furthermore, the card game nature of StS allows
IMB incorporates a simple procedural level generation pro-         for the possibility of an agent understanding these rules
cess that combines pre-defined segments to create a level.         via language-based reasoning. Our previous work [31] has
One of the ways that researchers have used IMB is by ex-           shown that such an agent in this environment can show
perimenting with different level generation methods such           long-term reasoning capabilities required in some scenarios.
                                                                      MiniStS is not the only card game environment avail-
able for research purposes. XMage5 and Hearthbreaker6                                         Possible Actions
are community-made clones of Magic: the Gathering and
Hearthstone respectively. Ling et al. use the dataset of cards
from both of these environments to perform research on                                Which      To which        To which
code generation [32]. Metastone7 is a community-made                                  card?       agent?          card?
implementation of Hearthstone which Santos et al. use to
explore use of the MCTS algorithm in playing Hearthstone             Game State                    Agent                    Action
[33]. One important difference between MiniStS and the
community-made environments is our focus on not limiting
MiniStS to the set of existing cards. Since our goal is en-       Figure 4: The API required for defining a rule-playing agent in
abling research that explores dynamic rule systems and an         MiniStS. The agent should be able to respond to three type of
understanding and adaption to the rules during gameplay,          questions given the state of the game and the list of possible
we specifically design MiniStS to facilitate these goals.         responses.
   Chen and Guy introduce Chaos Cards [34] as a card gen-
eration system. They use the Chaos Card environment,
which has similar rules to Hearthstone, to both generate
                                                                     Though these two applications can be explored indepen-
playable cards and playtest them by using a 1-step look-
                                                                  dently, they relate to each other in an interesting way. The
ahead agent. The cards are designed via a specific grammar
                                                                  dynamic rule-playing agent can be used as a means of eval-
that runs through GIGL [35], which was previously made
                                                                  uation to playtest the game when new cards are introduced
by the same authors to enable creating executable artifacts
                                                                  to the game. On the other hand, defining new cards can test
from grammatical descriptions. While this environment is
                                                                  the agents in terms of generalization since the agent can be
well-suited for the purposes of the authors, our focus lies
                                                                  provided with new rules to play with without being trained
on cards that allow changes to the rules and can possibly
                                                                  on those specific set of rules. A virtuous cycle.
have effects beyond the Hearthstone-specific grammar. Ad-
                                                                     Below we describe the required API to tackle each of
ditionally, MiniStS also removes some of the challenges of
                                                                  these challenges, as well as our existing examples of agents
playing against an opponent and deck-building to enable a
                                                                  that respond to each target application.
more direct focus on studying the underlying dynamic rule
system, which we discussed in Section 1.3.
   Finally, while not a card game, Baba is You has similarities   3.1. Dynamic Rule-Playing AI
with MiniStS in terms of qualities of the environment. As         In MiniStS, we define the term game-playing agent (GPA) as
discussed in Section 1, Baba is You is an interesting research    an agent that take the role of the player in the game by mak-
subject since, similar to games with as dynamic rule systems      ing any decision that is expected from the player. Any GPA
such as StS, it provides an environment that the player           in MiniStS is required to implement three functionalities:
interacts with the rules and changes them during gameplay.
Not only does this create interesting challenges in level             1. Choose a card to play: Given the current state, the
design and intertwines level design and game rules, it also              agent should be able to decide which one of the
raises interesting questions in terms of game-playing that               available cards to play, or decide to end its turn.
relates to the AI agent’s understanding of how to best play           2. Choose the target (agent): Some of the cards can
with the rules. Charity et al. use an implementation of the              target one or more agents in the game, for example
game based on the available code for the initial game jam                the player should choose the target for “Strike: Deal
version of the game to research their proposed collaborative             6 damage.” Given the state of the game and a list of
mixed-initiative design system [14].                                     possible options, the GPA should be able to decide
                                                                         which option(s) are the target of the card.
                                                                      3. Choose the target (card): Similarly, some cards can
3. Applications                                                          target other cards, such as “Concentrate: Discard 3
In this section, we highlight two types of application for               cards. Gain 2 energy.” Given the state of the game
which MiniStS can be used. First, we can use MiniStS to ex-              and a list of possible options, the GPA should be able
plore dynamic rule-playing agents, i.e. game-playing agents              to decide which option(s) are the target of the card.
that can act in a dynamic rule system, deciding how to play          The only requirement for playing the game is for a GPA
the game in ways that possibly result in a change of rules.       to be able to respond to these three questions. MiniStS also
The agents should be able to continuously adapt to these          allows the agents to simulate the future steps of the game,
changes. Furthermore, the agents should have an under-            making it possible to define agents that use this prediction
standing of game design and the effect of rules on the game       in their decision making, such as an MCTS agent. Note that
to be able to choose how to manipulate the active rules           this simulation is not completely accurate, since any non-
toward their goal.                                                deterministic actions (e.g. shuffling the deck, random choice,
   Second, we discuss the use of MiniStS as a card generation     etc.) are intentionally forced to use a different seed. This is
environment. Since MiniStS is designed in a way to allow          because none of the agents should have perfect knowledge
the definition of new cards by combining existing actions         about the non-deterministic events of the game.
and effects or defining new ones, this environment can be            In our previous research [31], we developed three differ-
used for designing and playtesting new cards.                     ent agents within MiniStS and compared them in different
                                                                  scenarios. First, we showed that a random agent can be
                                                                  defined by simply choosing one of the options randomly
5
  https://github.com/magefree/mage/                               for each of these questions, as shown in Figure 5. Second,
6
  https://github.com/danielyule/hearthbreaker/
7
  https://github.com/demilich1/metastone
                                                                  we utilized the simulation abilities of MiniStS to showcase
                                                                 over 1,000 simulations). Running these 1,000 simulations on
                                                                 a personal laptop with an RTX 3050 GPU and on 50 threads
                                                                 takes less than 10 milliseconds per simulation on average.

                                                                 3.2. Card Generation
                                                                 The second goal of MiniStS is to enable researchers to define
                                                                 card-generation systems. As we discussed previously, when
Figure 5: Pseudocode showing implementation of an example        the cards can alter the rules of the game, card generation
agent (random agent). The agent implements functions to decide   requires a careful consideration of rule synergies and the
the next action based on the state of the game and to choose a   space of the game design. To achieve this goal, we design the
target between agents/cards when needed. The pseudocode is       system in a way to allow versatile combination of different
slightly simplified from the actual implementation.              actions and effects. These actions and effects can be from
                                                                 the existing actions, but a major part of our focus is in not
                                                                 limiting our system to a pre-defined set of actions. The
a look-ahead agent. The look-ahead agent simulates the           actions can also be combined with an AND module. If the
game up to a pre-defined depth and chooses an action for         action requires a target, MiniStS forces the card definition
the current move that would maximize the estimated score         to include the TO module for defining how this target is
in the future. Finally, we demonstrated how MiniStS can be       selected. We discuss these modules in more detail and with
used with a language-based agent by converting the game          examples in Section 4.
state into a purely text-based format and sending it to a           Additionally, some cards can change the rules to have
large language model (LLM) along with the basic rules of         specific effects when certain events occur. To make this pos-
the game. The text-based description for each card is au-        sible, we define status effects that visualize these changes in
tomatically generated based on its effects but can also be       the rules, similar to how the game visualizes these changes
customized to show a predefined text. All three agents are       for the player. We also use an open-ended event system
generalized, meaning that they are not limited to playing        that allows for defining broadcast events and subscribing to
only a specific set of cards. These three agents are included    them to perform actions that result from the rule change. We
in MiniStS’s source code and can be used to run simulations      explain MiniStS components, such as actions, their targets,
in different settings. Our primary focus in this paper is to     status effects, and event system in more detail in Section 4.
present MiniStS as a testbed, rather than the agents. Our           With this setup, creating a new card in the game can be
previous work [31] provides an example of how MiniStS            done by following these steps:
can be used to simulate and compare different agents in              1. Use the set of existing actions and define any new
a dynamic rule system, and includes more information on                 actions that are required. Each action can access
each of these agents.                                                   the state of the game and manipulate it. However,
   The testbed that MiniStS provides is uniquely useful in              the actions should be defined as atomic operations,
testing rule-playing agents. As discussed in Section 1, one             meaning that they are small enough that cannot be
of our main goals with MiniStS is to define an environment              broken down further into lower level actions.
in which playing the game can change the way the game                2. If there are any new status effect, define these effects
is played. As such, we call the game-playing agents in this             and determine their properties, such as if multiple
environment rule-playing agents, since the agent is playing             instances of the same effect would stack, if the effect
with the rules. In other words, the performance of such an              is for a certain number of turns, and so on.
agent is tied to its understanding of how these rules change         3. If the card requires any new events or callback on
the game, and whether or not it would benefit from these                the existing events, define the new modules.
changes.                                                             4. Combine the actions, and determine any required
   MiniStS also includes an agent evaluation module that                card parameters (such as cost of the card) or action
allows comparing different agents given a scenario. The                 parameters (such as amount of damage for the action
scenario defines which cards the agents have in their deck,             “Deal x damage”).
and what enemies are they encountering. The evaluation
component then simulates multiple instances of the game             Example of card definitions and combining the actions is
in parallel and logs the game events and the response of         available in Section 4.
agents to these events. Finally, these logs are imported by         To show a simple example of card generation, we im-
another module to calculate a set of metrics such as win-rate,   plement a simple grammar-based card generation module.
the distribution of player’s health at the end of the game,      The card generation module randomly chooses actions and
whether a certain card or combinations of cards were used        possibly combines them by using the AND module. The pa-
by the agent, how many turns the agent took to win/lose          rameters for each action are chosen from a set of reasonable
the game, and so on.                                             values that are determined based on examples of existing
   The execution time of the simulation is highly dependent      cards. The card generation process lacks any evaluation of
on the number of turns it takes for the agent to end the         the quality of cards and is also limited to the set of available
game and the agent’s performance. To provide an estimate         actions and their combinations, and does not introduce new
of MiniStS’s performance and factor out the time it takes        rules into the game. We use the available card generation
for the agent to make decisions, we can consider an agent        process not as a strong method for generating cards, but as
that always chooses the first available action. In this case,    both an example of how cards can be generated from these
the first battle of the game, using the starting set of cards,   actions and to enable a simple way of providing new cards
averages around 5 turns and 23 agent actions (calculated         for the purpose of testing rule-playing agents when playing
                                                                 with never-seen-before cards.
                                      Atomic Actions
                              Atomic Actions                                               Card Targets                    Agent  Targets
                                                                                     Card Targets                       Agent Targets
        Decorate Decorate        Deal                             Gain                                     Discard




                                                    Target




                                                                          Target
                          Deal      Gain                                                     Self   Discard Pile               Self




                                    Target




                                                             Target
                                Damage                            Block             Self             Pile               Self
                         Damage     Block                                                                   Draw
                                                                                           Choose Draw                               Enemy
                                                                                                                           Choose Enemy
                        And              Discard                  Draw                                       Pile




                                                    Target
           And            Discard             Draw                                 Choose            Pile            Choose




                                    Target
                                          Card                    Card
                           Card                  Card                                         All           Hand               All              All
                         To                  Apply                                   All             Hand                All              All




                                                    Target
                                                                      …                                 Exhaust
            To            Apply              Status …                                      RandomExhaust Pile              Random



                                    Target
                          Status                                                   Random            Pile            Random
                                                                                     Figure 7: Possible targets for atomic actions. The targets can
Figure 6: Atomic actions. Some actions have a specific type of                       be either a card or an agent (i.e. the player or enemies). Each of
target (agent or card) and can be decorated with TO. Any action                      these targets is defined on a set of possible options, and a way of
or combination of actions can be decorated with AND.                                 choosing the option.



4. System Structure                                                                         • Self: Either the player or the card that includes this
                                                                                              action, based on the type of target (agent or card).
In this section, we describe different components of the Min-
                                                                                            • Choose [from a set of options]: The target is identi-
iStS design with the goal of creating a research environment
                                                                                              fied based on player input.
with a dynamic rule system.
   One of our main goals with MiniStS is to enable and                                      • All [from a set of options]: The action with this
streamline the process of defining a new card. To achieve                                     type of target is applied to all the the possible target
this, we analyze a set of existing cards, both from Slay the                                  options.
Spire and from a set of third party cards designed as mods                                  • Random [from a set of options]: The target is chosen
by the StS community.                                                                         as one or more options from the set of available
                                                                                              options.
4.1. Actions                                                                            For each of these cases, the set of available options can be
                                                                                     defined in a few different ways. By examining the existing
The first component that we identify in the cards are ac-
                                                                                     cards, we identify the possible set of options for card targets
tions. Actions define what effect the card has on the state
                                                                                     to be either from player’s hand, discard pile, draw pile or
of the game. For example, a “Gain Mana” action means that
                                                                                     exhaust pile. As for the agent, if the target is not the player
when the card is played, it changes the amount of available
                                                                                     (self), it’s from the enemies. We also noticed in a set of third
mana for the player. Some of these actions are visualized in
                                                                                     party cards from community mod packs that the target can
Figure 6.
                                                                                     also refer to all the agents (i.e. both the player and the
   The actions are defined as atomic, meaning that when
                                                                                     enemies).
we analyze a card, we break down its effect into indivisible
actions that cannot be further decomposed. We then allow
these atomic actions to be combined together in any order                            4.3. Status Effects and Events
by defining an AND decorator that creates an action from                             Slay the Spire defines a set of status effects, or buffs and
the combination of any two actions.                                                  debuffs, which can be used to indicate when an agent is
   Finally, many actions in the game require one or more                             weak (deals less damage for a number of turns), vulnerable
targets. For example, the “Deal damage” action affects one                           (takes more damage for a number of turns), etc. While we
or more enemies which are selected in a specific way. We                             can implement only these effects by using specialized code
make this possible by defining actions that need a target. For                       that only covers these cases, we want the definition of a
each of these actions, the designer should specify how the                           status effect to be more open-ended and include a flexible
required targets are selected, whether based on player input,                        infrastructure, since status effects are the foundation of rule-
random selection, or chosen as “all the possible targets.”                           based cards.
These actions are considered incomplete unless they are                                 So far, we have defined atomic actions and targets which
decorated with TO and a target definition. We discuss the                            enable many of the available cards in the game to be ex-
target definitions in the next subsection.                                           pressed in MiniStS. However, many of the most interesting
   Note that the AND decorator can still be applied before or                        cards in the game, especially the cards that change the rules
after defining a target. Figure 9 shows pseudocode for two                           of the game, cannot be defined with the actions alone. For
example cards, and Figure 10 shows how the second card can                           example, the card “After Image” is defined as “Whenever
be redefine to apply its underlying actions to two, possibly                         you play a card, gain 1 block.” Instead of having an instant
different, targets. Figure 8 visualizes the two example cards.                       effect on the state of the game, these cards can have a last-
                                                                                     ing effect that can be triggered at certain points, such as
4.2. Targets                                                                         whenever a card is played, at the start of every turn, until
                                                                                     the end of this turn, etc.
As mentioned previously, the effect of a card can be ex-
                                                                                        To understand how best we can cover these types of ef-
pressed by a set of atomic actions, some of which require
                                                                                     fects in MiniStS, we first look at how StS communicates
a target. By analyzing the existing cards, we see that StS
                                                                                     these cards and their effects with the player. StS uses status
cards can target agents (i.e. the player or the enemies) or
                                                                                     effects to visualize these changes to the rules of the game.
cards. Each of these targets can be expressed as one of the
                                                                                     For example, the card “After Image”, which we discussed
following types:
                                                                                     above, applies a specialized status called “After Image” on
                              Gain                                                                     Discard




                                                                                                                 Target
                                       Target
                                                To              Self            And                                       To           Choose              Hand
                              Block                                                                     Card




                                     Deal                              Apply




                                                                                Target
                                                 Target
                                                          And                                     To       Choose                Enemy
                                    Damage                             Status




Figure 8: visualization of implementing "Survivor: Gain 8 Block. Discard 1 card." and "Bash: Deal 8 Damage. Apply 2 Vulnerable." Both
cards can be defined by combining atomic actions and targets with AND and TO. However, Bash uses the same target for both actions,
which requires using AND before defining the targets with TO, whereas Survivor have different targets and uses AND after seperately
defining the targets.




                                                                                                                                        Battle


                                                                                                                   End Turn            Play Card
                                                                                                                                                            …
                                                                                                                    Event                Event

                                                                                                                              Before               After
                                                                                         Status
                                                                                         Effect
                                                                                                            Callback              Subscribe
                                                                                                          Gain x Block            Game State
Figure 9: Pseudocode showing implementation of two example
cards, "Survivor: Gain 8 Block. Discard 1 card." and "Bash: Deal 8              Figure 11: Definition of card “After Image” in MiniStS. The
Damage. Apply 2 Vulnerable." The pseudocode is simplified from                  applies a special status effect, called “After Image”, to the player.
the actual implementation.                                                      The unique callback is subscribed to the event of “Play Card”
                                                                                to trigger after every time it happens. The callback then, given
                                                                                the whole state of the game, applies some amount of block to
                                                                                the player depending on the strength of the status effect which
                                                                                directly maps to how many times the card was played.



                                                                                 to register the callback to that event. The callbacks can be
                                                                                 subscribed to trigger before or after an event. Figure 11
                                                                                 demonstrates how status effects and the event system can
                                                                                 be used to create “After Image.”
Figure 10: Pseudocode showing implementation of an imaginary                        The events can also be defined in a way to manipulate
card, "Bash*", which deals 8 damage to one target, and then
                                                                                 a value. For example, the status effect “vulnerable” makes
applies 2 Vulnerable to another, possibly different, target. The
                                                                                 it so that the affected creature takes 50% more attack dam-
pseudocode is simplified from the actual implementation.
                                                                                 age for some number of turns. The vulnerable status ef-
                                                                                 fect is implemented by subscribing to the “attack damage”
                                                                                 event. Basically, whenever the “deal attack damage” action
the player. Each effect also has a set of properties. For exam-                  is performed in the game, the event triggers and expects
ple, “After Image” status effect does not decrease during the                    the callbacks subscribed to it to manipulate the amount of
battle, and can stack (i.e. if “After Image” is played twice,                    damage. Each event system can have any type of input that
the value of status effect is increased to two).                                 it desired, or not have an input at all. Each callback is then
   Finally, the status effect performs some behavior when                        required to specifically get that type of input and returns
the appropriate event triggers. To implement this, we use an                     the manipulated value.
event system. The event system provides a formal definition                         Finally, multiple callbacks can be defined on each event.
of how the events and callbacks related to status effects                        For example, “weak” and “vulnerable” effects are both de-
should be added to the game. Each event has broadcast and                        fined to trigger when attack damage is happening in the
subscribe functions. Broadcast is used by the entity that                        game and manipulate its value. However, the order in which
relates to the condition of the event, while subscribe is used
these effects apply completely depend on how the card de-           be implemented as combination of two actions by keeping
signer have envisioned the effects. Because of this, it’s im-       track of the cost in the game state.
portant for any new callback to be subscribed at the correct           StS includes multiple characters, some of which have spe-
order compared to other callbacks.                                  cific mechanics. The current implementation of the game,
                                                                    which is a simplified version, does not implement these
4.4. Gameplay Loop                                                  mechanics. Furthermore, the current version of MiniStS im-
                                                                    plements some but not all the existing actions, status effects,
The gameplay loop simulates the events of a battle. The             and enemies in the game, and only simulates one battle to
event and values of this component are a simulation of the          compare agents instead of multiple battles. However, such
events in Slay the Spire. Each turn consists of the following       components can be added to MiniStS without any major
events:                                                             changes to the code.
    1. Gain Mana: The player gains full mana at the start
       of the turn.                                                 6. Conclusion
    2. Draw a Hand: The player draws cards equal to the
       number of pre-defined draw count. If at any times            Games with dynamic rule systems are games in which a set
       the draw pile is empty, the discard pile is shuffled         of composable rules exist which can be activated through
       back into the draw pile.                                     playing the game. While the designer is the one who cre-
    3. Play (Player Side): The player side is played, mean-         ates these rules, the player also participates in game design
       ing that the player agent would take its turn, and           decisions by playing the game. This unique property, a
       then the enemy side would lose any remaining block.          key characteristic of collectible card game and roguelike
       Note that some damage types would apply after this           genres, offers unique research opportunities. AI agents can
       event, bypassing enemies’ blocks.                            be cast into the role of the designer or the player in the
    4. Play (Enemy Side): The enemy side is played, mean-           system. As a designer, these agents are required to reason
       ing that the enemies would take their turn one by            about the synergy effect of rules and the distribution of the
       one, and then the player side would lose any remain-         possible designs that arise from different rules activated in
       ing block.                                                   each playthrough. As a player, these agents are required to
    5. Discard Hand: The cards in player’s hand are then            reason about game design in order to combine the rules in
       discarded and moved to the discard pile.                     a way that gets them closer to their goal.
                                                                       In this paper, we introduced MiniStS, a simplified imple-
   The game will continue repeating the events described            mentation of Slay the Spire. MiniStS enables researchers to
above every turn until the battle has ended, i.e. the player        explore the StS environment and its dynamic rule system
or all the enemies are dead. Note that these events can be          in two ways. First, with the role of a player in the system
affected by the cards, e.g. a card can change the number of         and as a rule-playing agent, and second, with the role of
draw count, make the cards not get discarded at the end of          a designer and as a card generation task. We describe the
the turn, etc.                                                      steps with which both of these tasks can be approached in
   The gameplay loop is also connected to the game state            MiniStS. Finally, we described different components of Mini-
such as the available deck of cards, properties such as draw        StS and discussed how each of these components facilitate
count or maximum mana, and state of the battle including a          these two applications by making it possible to define new
the list of cards in player’s hand, discard pile, draw pile and     cards and rule-playing agent without any major changes to
exhaust pile, and the player and enemies and their respective       the code and by using a streamlined process.
states such as HP, mana, block, and so on.

                                                                    References
5. Limitations
                                                                     [1] M. Persson, Infinite mario bros, Online Game (2008).
One limitation of the system is that it respects the basic           [2] G. Smith, M. Treanor, J. Whitehead, M. Mateas,
rules of the game Slay the Spire, so any changes that are                Rhythm-based level generation for 2d platformers,
related to the foundation of the game would require chang-               in: Proceedings of the 4th International Conference
ing the system. For example, the order of events (e.g. the               on Foundations of Digital Games, FDG ’09, Associa-
player plays first, then the enemies take their actions), the            tion for Computing Machinery, New York, NY, USA,
existence of only a single type of mana, or the fact that this           2009, p. 175–182. URL: https://doi.org/10.1145/1536513.
is a single player card game cannot be modified without                  1536548. doi:10.1145/1536513.1536548.
applying significant changes to the code.                            [3] A. Khalifa, M. C. Green, G. Barros, J. Togelius, In-
   Another limitation of the system is regarding the types               tentional computational level design, in: Proceed-
of input the system expects from the system. As discussed                ings of the Genetic and Evolutionary Computation
in Section 4.2, the game expects each action to be applied               Conference, GECCO ’19, Association for Computing
to at most one agent or card. Because of this, any action                Machinery, New York, NY, USA, 2019, p. 796–803.
that requires a new type of input does not exist in the game.            URL: https://doi.org/10.1145/3321707.3321849. doi:10.
For example, one can imagine a card defined as “Remove                   1145/3321707.3321849.
one of the status effects of your choosing” which would              [4] M. Cerny Green, L. Mugrai, A. Khalifa, J. Togelius,
require a new form of input from the player. Furthermore,                Mario level generation from mechanics using scene
actions that are defined on multiple target types do not exist           stitching, in: 2020 IEEE Conference on Games
in StS or MiniStS, such as “Discard a card and deal damage               (CoG), 2020, pp. 49–56. doi:10.1109/CoG47356.
equal to 5 times its cost.” It’s worth noting that this still can        2020.9231692.
 [5] P. Mawhorter, M. Mateas, Procedural level genera-                https://magic.wizards.com/en/news/making-magic/
     tion using occupancy-regulated extension, in: Pro-               lenticular-design-2014-12-15.
     ceedings of the 2010 IEEE Conference on Compu-              [23] M. Stephenson, J. Renz, Procedural generation of
     tational Intelligence and Games, 2010, pp. 351–358.              levels for angry birds style physics games, Proceed-
     doi:10.1109/ITW.2010.5593333.                                    ings of the AAAI Conference on Artificial Intelligence
 [6] S. Karakovskiy, J. Togelius, The mario ai benchmark              and Interactive Digital Entertainment 12 (2021) 225–
     and competitions, IEEE Transactions on Computa-                  231. URL: https://ojs.aaai.org/index.php/AIIDE/article/
     tional Intelligence and AI in Games 4 (2012) 55–67.              view/12871. doi:10.1609/aiide.v12i1.12871.
     doi:10.1109/TCIAIG.2012.2188528.                            [24] R. Rodriguez Torrado, A. Khalifa, M. Cerny Green,
 [7] J. Togelius, S. Karakovskiy, J. Koutnik, J. Schmidhuber,         N. Justesen, S. Risi, J. Togelius, Bootstrapping condi-
     Super mario evolution, in: 2009 IEEE Symposium                   tional gans for video game level generation, in: 2020
     on Computational Intelligence and Games, 2009, pp.               IEEE Conference on Games (CoG), 2020, pp. 41–48.
     156–161. doi:10.1109/CIG.2009.5286481.                           doi:10.1109/CoG47356.2020.9231576.
 [8] J. Muñoz, G. N. Yannakakis, F. Mulvey, D. W. Hansen,        [25] P. Taveekitworachai, F. Abdullah, M. F. Dewantoro,
     G. Gutierrez, A. Sanchis, Towards gaze-controlled                R. Thawonmas, J. Togelius, J. Renz, Chatgpt4pcg com-
     platform games, in: 2011 IEEE Conference on Com-                 petition: Character-like level generation for science
     putational Intelligence and Games (CIG’11), 2011, pp.            birds, in: 2023 IEEE Conference on Games (CoG), 2023,
     47–54. doi:10.1109/CIG.2011.6031988.                             pp. 1–8. doi:10.1109/CoG57401.2023.10333206.
 [9] G. Wallner, N. Halabi, P. Mirza-Babaei, Aggregated          [26] M. Stephenson, J. Renz, X. Ge, L. Ferreira, J. Togelius,
     visualization of playtesting data, in: Proceedings of            P. Zhang, The 2017 aibirds level generation competi-
     the 2019 CHI Conference on Human Factors in Com-                 tion, IEEE Transactions on Games 11 (2019) 275–284.
     puting Systems, CHI ’19, Association for Comput-                 doi:10.1109/TG.2018.2854896.
     ing Machinery, New York, NY, USA, 2019, p. 1–12.            [27] C. Hu, Y. Zhao, Z. Wang, H. Du, J. Liu, Games for
     URL: https://doi.org/10.1145/3290605.3300593. doi:10.            artificial intelligence research: A review and per-
     1145/3290605.3300593.                                            spectives, 2024. URL: https://arxiv.org/abs/2304.13269.
[10] C. Lewis, J. Whitehead, Runtime repair of software               arXiv:2304.13269.
     faults using event-driven monitoring, in: Proceedings       [28] S. Ontañón, N. A. Barriga, C. R. Silva, R. O. Moraes,
     of the 32nd ACM/IEEE International Conference on                 L. H. S. Lelis, The first microrts artificial intel-
     Software Engineering - Volume 2, ICSE ’10, Associa-              ligence competition, AI Magazine 39 (2018) 75–
     tion for Computing Machinery, New York, NY, USA,                 83. URL: https://ojs.aaai.org/aimagazine/index.php/
     2010, p. 275–280. URL: https://doi.org/10.1145/1810295.          aimagazine/article/view/2777. doi:10.1609/aimag.
     1810352. doi:10.1145/1810295.1810352.                            v39i1.2777.
[11] D. Perez-Liebana, S. Samothrakis, J. Togelius, T. Schaul,   [29] N. Heijne, S. Bakkes, Procedural zelda: a pcg en-
     S. Lucas,        General video game ai: Competi-                 vironment for player experience research, in: Pro-
     tion, challenges and opportunities, Proceedings                  ceedings of the 12th International Conference on
     of the AAAI Conference on Artificial Intelligence                the Foundations of Digital Games, FDG ’17, Associa-
     30 (2016). URL: https://ojs.aaai.org/index.php/AAAI/             tion for Computing Machinery, New York, NY, USA,
     article/view/9869. doi:10.1609/aaai.v30i1.9869.                  2017. URL: https://doi.org/10.1145/3102071.3102091.
[12] L. Ferreira, C. Toledo, A search-based approach for              doi:10.1145/3102071.3102091.
     generating angry birds levels, in: 2014 IEEE Confer-        [30] O. Vinyals, T. Ewalds, S. Bartunov, P. Georgiev, A. S.
     ence on Computational Intelligence and Games, 2014,              Vezhnevets, M. Yeo, A. Makhzani, H. Küttler, J. Aga-
     pp. 1–8. doi:10.1109/CIG.2014.6932912.                           piou, J. Schrittwieser, J. Quan, S. Gaffney, S. Petersen,
[13] M. Carroll, R. Shah, M. K. Ho, T. Griffiths, S. Se-              K. Simonyan, T. Schaul, H. van Hasselt, D. Silver, T. Lil-
     shia, P. Abbeel, A. Dragan,          On the utility of           licrap, K. Calderone, P. Keet, A. Brunasso, D. Lawrence,
     learning about humans for human-ai coordination,                 A. Ekermo, J. Repp, R. Tsing, Starcraft ii: A new chal-
     in: H. Wallach, H. Larochelle, A. Beygelzimer,                   lenge for reinforcement learning, 2017. URL: https:
     F. d'Alché-Buc, E. Fox, R. Garnett (Eds.), Advances              //arxiv.org/abs/1708.04782. arXiv:1708.04782.
     in Neural Information Processing Systems, vol-              [31] B. Bateni, J. Whitehead, Language-driven play: Large
     ume 32, Curran Associates, Inc., 2019. URL: https:               language models as game-playing agents in slay the
     //proceedings.neurips.cc/paper_files/paper/2019/file/            spire, in: Proceedings of the 19th International Con-
     f5b1b89d98b7286673128a5fb112cb9a-Paper.pdf.                      ference on the Foundations of Digital Games, FDG
[14] M. Charity, A. Khalifa, J. Togelius, Baba is y’all:              ’24, Association for Computing Machinery, New York,
     Collaborative mixed-initiative level design, in: 2020            NY, USA, 2024. URL: https://doi.org/10.1145/3649921.
     IEEE Conference on Games (CoG), 2020, pp. 542–549.               3650013. doi:10.1145/3649921.3650013.
     doi:10.1109/CoG47356.2020.9231807.                          [32] W. Ling, E. Grefenstette, K. M. Hermann, T. Kočiský,
[15] Mega Crit Games, Slay the spire, 2019.                           A. Senior, F. Wang, P. Blunsom, Latent predictor net-
[16] A. Teikari, Baba is you, 2019.                                   works for code generation, 2016. URL: https://arxiv.
[17] Berlin Interpretation - RogueBasin, 2013. URL:                   org/abs/1603.06744. arXiv:1603.06744.
     https://www.roguebasin.com/index.php/Berlin_                [33] A. Santos, P. A. Santos, F. S. Melo, Monte carlo tree
     Interpretation.                                                  search experiments in hearthstone, in: 2017 IEEE
[18] E. McMillen, F. Himsl, The Binding of Isaac, 2011.               Conference on Computational Intelligence and Games
[19] Supergiant Games, Hades, 2018.                                   (CIG), 2017, pp. 272–279. doi:10.1109/CIG.2017.
[20] Nolla Games, Noita, 2019.                                        8080446.
[21] Hopoo Games, Risk of Rain 2, 2019.                          [34] T. Chen, S. Guy, Chaos cards: Creating novel dig-
[22] M. Rosewater, Lenticular design, 2014. URL:                      ital card games through grammatical content gen-
     eration and meta-based card evaluation, Proceed-
     ings of the AAAI Conference on Artificial Intelligence
     and Interactive Digital Entertainment 16 (2020) 196–
     202. URL: https://ojs.aaai.org/index.php/AIIDE/article/
     view/7430. doi:10.1609/aiide.v16i1.7430.
[35] T. Chen, S. Guy, Gigl: A domain specific language for
     procedural content generation with grammatical rep-
     resentations, Proceedings of the AAAI Conference on
     Artificial Intelligence and Interactive Digital Entertain-
     ment 14 (2018) 9–16. URL: https://ojs.aaai.org/index.
     php/AIIDE/article/view/13025. doi:10.1609/aiide.
     v14i1.13025.