ad
ad
Topview AI logo

Playing Your Cards Right: The Hierarchical Portfolio Search AI of Prismata

Education


Introduction

In this article, I’ll be discussing the Hierarchical Portfolio Search System (HPS) I created for the AI of Prismata, a hybrid strategy game developed by Loon Arc Studios. Although the title may seem complex, I assure you that the underlying concepts are quite straightforward.

Prismata is described as a two-player game where players take turns, combining elements from card games like Hearthstone or Magic the Gathering with real-time strategy (RTS) mechanics reminiscent of Starcraft. Unlike conventional card games, losing the physical cards allows for a more responsive experience, but it also complicates AI development due to the randomized initial game state, which can affect the level of predictability and strategy required.

Each player starts with a pool of resources, five types in total, which allow them to purchase units and technologies during their turns. The ability to activate unit abilities means that strategic positioning and resource management become vital components of gameplay. Units do not enter a hand or deck; instead, they appear directly on the battlefield, which distinguishes them from traditional strategy games.

Key Properties of Prismata:

  1. Perfect Information: Neither player has hidden information from the other, making assessments and decision-making clearer.
  2. Deterministic Gameplay: The game operates with predictable mechanics, barring the randomization of starting states.

Given the complexity of the rules and the importance of tutorial mechanisms, we set several design goals for the AI system:

  • Establish a comprehensive tutorial for new players transitioning through game mechanics.
  • Provide sufficient challenge for experienced players looking to practice strategies.
  • Ensure an enjoyable single-player experience with substantial replay value.
  • Maintain a modular design that accommodates balance changes or varying levels of AI difficulty.

Despite its academic origins, the task of creating a robust AI involved overcoming significant challenges. The game state space is vast, given the exponential growth in calculations when units and actions increase. Traditional search methods such as Alpha-Beta pruning alone struggle to navigate this complexity.

This led to the concept of Hierarchical Portfolio Search (HPS), which attempts to mitigate the state space issue by:

  1. Generating a Smaller Subset of Moves: Instead of searching through every possible move, the algorithm generates a more manageable portfolio of tactical maneuvers based on defined strategies or algorithms.
  2. Applying a High-Level Search Algorithm: Once the intelligent moves are generated, a high-level search algorithm is applied to assess the best move based on the current game state.

Components of HPS:

  1. Game State: Represents the current conditions of the game.
  2. Actions: Various activities available to units, such as clicking or purchasing.
  3. Move: A complete sequence of actions that the AI will take during its turn.

The Player Function manages the AI’s decision-making logic, while what I call the Partial Player Function generates tactical moves tailored to specific phases or unit types within the game. By decomposing the game into phases, such as defensive, ability, purchasing, and breaching, we create different partial players that contribute to the overall strategy.

For implementation:

  • Collaborate with game designers to develop a portfolio that encompasses diverse behaviors — aggressive, defensive, or economic strategies.
  • Export possible permutations of these behaviors for subsequent evaluation during decision-making.

Evaluating Moves: Utilizing Monte Carlo Tree Search, Alpha-Beta pruning, or simpler methods, the AI can weigh the actions it can perform based on predicted outcomes from simulated play.

AI Difficulty Levels: Through modularity, we can tailor the AI to various difficulty levels:

  • Master AI: Utilizes MCTS for optimal play.
  • Expert AI: Employs depth-limited alpha-beta search for more instantaneous decisions.
  • Medium AI: Randomly selects from a pool of intelligent potential moves.
  • Easy AI: Simplifies actions for less experienced players.
  • Pacifist AI: Plays accordingly without aggression, allowing players an easier challenge.

Benefits of HPS: The HPS framework not only allows adaptation to game dynamics but also provides reliable search capabilities without the risks of emergent, unpredictable AI behavior. It is designer-friendly, enabling easy adjustments to the AI system based on game changes.

Evaluations & Future Directions: Testing confirmed the validity of the AI across various difficulty levels, and feedback indicated that players enjoyed the fresh experience of playing against a sophisticated AI. Additionally, solutions suited for AI like HPS can also apply to bug testing or balance evaluations.

Overall, HPS provides a pathway to implementing effective AI strategies while retaining flexibility and ease of use for game designers.


Keywords

Prismata, Hierarchical Portfolio Search, AI, strategy games, perfect information, deterministic gameplay, Monte Carlo Tree Search, Alpha-Beta pruning, modular design, natural game states, player functions, difficulty levels.

FAQ

1. What is Prismata?
Prismata is a hybrid strategy game that combines elements from traditional card games with real-time strategy mechanics.

2. What are the primary goals of the AI in Prismata?
The AI aims to create a smooth tutorial for new players, offer a challenge to experienced players, ensure an enjoyable single-player experience, and maintain a modular design for adapting to balance changes.

3. How does Hierarchical Portfolio Search work?
HPS generates a smaller subset of intelligent moves for evaluation instead of searching over every possible move, which greatly helps in managing the complexity inherent in strategy games.

4. What search algorithms can be utilized with HPS?
HPS can utilize various high-level search algorithms, including Monte Carlo Tree Search, Alpha-Beta pruning, or simpler methods depending on the desired AI difficulty level.

5. How does HPS support modularity in AI design?
The design allows for easy adjustments across different AI difficulty levels and accommodates changes in game balance without overhauling the entire system.