Anna Howard

Games Computing Graduate & Programmer/Game Developer

Overview
HearthPy is a genetic algorithm which designs and attempts to balance cards for a card game efficiently enough to be performed at runtime. The card format is based upon Hearthstone and the algorithm was originally prototyped in Python. The name HearthPy stuck after that.
The algorithm is primarily composed of two main parts, the design evaluating genetic algorithm, and a quality diversity algorithm which prevents over-homogenisation within generated card sets. HearthPy uses a point-based system to evaluate how balanced a card design is, with some effects having dynamic costs dependant on other elements of the card design.
HearthPy generates cards in sets. The quality diversity algorithm tries to ensure the generated set's card composition matches the set composition of real Hearthstone sets.
Reflection
With the benefit of hindsight, the way in which genes are used to create designs could be improved to be more dynamic. Theoretically with enough decomposition and appropriate structure it would be possible to have the algorithm generate its own keywords or effects. Such an approach would likely be significantly more complex and potentially result in longer runtimes. However, the increase in variety, depth and capabilities of the generated designs could be worth this trade-off. Such an implementation may be better suited as a design assistant tool and could be explored in a future project.
One of the limitations of HearthPy needing to be efficient enough to work at runtime is that the balance of a card is determined in a vacuum. An assistant tool could evaluate it in the context of the entire set and potentially be more accurate in it's balance assessments.
Design
Each card design consists of 37 genes, 7 unique genes and 30 genes which specify a card's effects. A card design has three keywords, each of which consist of 10 genes. One of the unique genes controls how many of these keywords are active. Only active genes are considered to be part of the design, So inactive genes are not displayed as part of the card and are not included when evaluating balance.
HearthPy implements a blacklist system when evaluating a card's effects. Certain gene combinations result in either nonsensical or incredible powerful effects which would require a more nuanced design, When these gene combinations are active in a design the card's balance score is heavily penalised to effectively prevent the card being selected when generating the next generation of designs. This system is used instead of generating a new design to maintain the algorithm's speed.

HearthPy

A Card Generating and Balancing Genetic Algorithm
GitHub Page
Read Full Project Report
Return to Projects