Hagl: Haskell Game Language
Hagl is a DSEL for experimental game theory (also called evolutionary game theory or behavioral economics). It supports defining games and strategies, then executing them repeatedly in order to collect and observe the results.
Hagl provides built-in support for standard game representations, such as normal and extensive form, and constructs for defining games in terms of the manipulation of a shared state (as in tic-tac-toe). New game representations can be easily added by instantiating a type class.
A monadic strategy DSL supports concise and vaguely English-like definitions of strategies for playing these games, usually iteratively.
While Hagl provides some basic game analyses, its primary focus is simulation and experimentation. Games can be executed and strategies can be pitted against each other for repeated play and in various kinds of tournaments.
Hagl is available on GitHub! Older versions of Hagl corresponding to specific papers are linked to below.
- Domain-Specific Language Support for Experimental Game TheoryMS thesis, Oregon State University, 2011
Experimental game theory is the use of game theoretic abstractions—games, players, and strategies—in experiments and simulations. It is often used in cases where traditional, analytical game theory fails or is difficult to apply. This thesis collects three previously published papers that provide domain-specific language (DSL) support for defining and executing these experiments, and for explaining their results.
Despite the widespread use of software in this field, there is a distinct lack of tool support for common tasks like modeling games and running simulations. Instead, most experiments are created from scratch in general-purpose programming languages. We have addressed this problem with Hagl, a DSL embedded in Haskell that allows the concise, declarative definition of games, strategies, and executable experiments. Hagl raises the level of abstraction for experimental game theory, reducing the effort to conduct experiments and freeing experimenters to focus on hard problems in their domain instead of low-level implementation details.
While analytical game theory is most often used as a prescriptive tool, a way to analyze a situation and determine the best course of action, experimental game theory is often applied descriptively to explain why agents interact and behave in a certain way. Often these interactions are complex and surprising. To support this explanatory role, we have designed visual DSL for explaining the interaction of strategies for iterated games. This language is used as a vehicle to introduce the notational quality of traceability and the new paradigm of explanation-oriented programming.
- A Domain-Specific Language for Experimental Game TheoryJournal of Functional Programming (JFP), vol. 19, 645–661, 2009
Experimental game theory is increasingly important for research in many fields. Unfortunately, it is poorly supported by computer tools. We have created Hagl, a domain-specific language embedded in Haskell, to reduce the development time of game-theoretic experiments and make the definition and exploration of games and strategies simple and fun.
- Varying Domain Representations in Hagl – Extending the Expressiveness of a DSL for Experimental Game TheoryIFIP Working Conf. on Domain-Specific Languages (DSL), LNCS 5658, 310–334, 2009
Experimental game theory is an increasingly important research tool in many fields, providing insight into strategic behavior through simulation and experimentation on game theoretic models. Unfortunately, despite relying heavily on automation, this approach has not been well supported by tools. Here we present our continuing work on Hagl, a domain-specific language embedded in Haskell, intended to drastically reduce the development time of such experiments and support a highly explorative research style. In this paper we present a fundamental redesign of the underlying game representation in Hagl. These changes allow us to better leverage domain knowledge by allowing different classes of games to be represented differently, exploiting existing domain representations and algorithms. In particular, we show how this supports analytical extensions to Hagl, and makes strategies for state-based games vastly simpler and more efficient.
- A Visual Language for Representing and Explaining Strategies in Game TheoryIEEE Int. Symp. on Visual Languages and Human-Centric Computing (VL/HCC), 101–108, 2008
We present a visual language for strategies in game theory, which has potential applications in economics, social sciences, and in general science education. This language facilitates explanations of strategies by visually representing the interaction of players’ strategies with game execution. We have utilized the cognitive dimensions framework in the design phase and recognized the need for a new cognitive dimension of “traceability” that considers how well a language can represent the execution of a program. We consider how traceability interacts with other cognitive dimensions and demonstrate its use in analyzing existing languages. We conclude that the design of a visual representation for execution traces should be an integral part of the design of visual languages because understanding a program is often tightly coupled to its execution.