A Framework for Modelling Tabletop Game Rules
Total Page:16
File Type:pdf, Size:1020Kb
Masaryk University Faculty of Informatics A Framework for Modelling Tabletop Game Rules Bachelor’s Thesis Jan Pokorný Brno, Fall 2019 Masaryk University Faculty of Informatics A Framework for Modelling Tabletop Game Rules Bachelor’s Thesis Jan Pokorný Brno, Fall 2019 This is where a copy of the official signed thesis assignment and a copy ofthe Statement of an Author is located in the printed version of the document. Declaration Hereby I declare that this paper is my original authorial work, which I have worked out on my own. All sources, references, and literature used or excerpted during elaboration of this work are properly cited and listed in complete reference to the due source. Jan Pokorný Advisor: prof. RNDr. Jiří Barnat, Ph.D. i Abstract A framework for digitally describing tabletop game rules is proposed, implemented in a library, and evaluated on a case study of a real-world tabletop game. The framework uses a tree-like structure of tokens and fields to represent the physical aspects of the tabletop game. Custom dispatch logic is used for handling rules and their special cases. The framework was implemented as a JavaScript library and evaluated on a case study of a real-world game, Citadels (Faidutti 2000). Im- plementation turned out to provide a sufficient level of abstraction. Resulting digitized game rules are logically and semantically very close to the natural language counterparts. The library simplifies the process of tabletop game digitization and enables faster iteration in digital tabletop games development. ii Keywords tabletop games, board games, card games, rules, digitization, JavaScript iii Contents 1 Introduction 1 1.1 Context of digitizing tabletop games .............1 1.2 Goals of the developed framework and library ........2 1.3 Structure of this thesis ....................3 2 Prior art in representing tabletop game rules digitally 5 2.1 Board Game Arena ......................5 2.1.1 BGA Studio . .5 2.1.2 BGA Sandbox . .6 2.2 OCTGN ............................7 2.3 Vassal Engine .........................7 3 Analysis of requirements on the framework 9 3.1 Representing the game state ..................9 3.1.1 Feasibility of recording the exact positions of tokens . .9 3.1.2 Using a flat field-token structure . 10 3.1.3 Using a tree-like structure . 10 3.1.4 Representing state not contained in tokens . 11 3.2 Representing rules ...................... 11 3.2.1 Rule language . 11 3.2.2 Non-linearity . 12 4 Framework definition 13 4.1 Representation of physical state ................ 13 4.1.1 Example representation . 14 4.2 Representation of rules .................... 15 4.2.1 External framework behavior . 15 4.2.2 Rule definition . 15 4.2.3 Commands returned from rules . 15 4.2.4 Invocation types . 16 4.2.5 Interaction loop . 16 5 Library implementation 19 5.1 Technology used ........................ 19 5.2 Installation .......................... 20 v 5.3 Token definition ........................ 21 5.4 Rule definition ........................ 22 5.4.1 Command definition . 23 5.4.2 Special states . 24 5.4.3 Example rule . 24 5.5 API description ........................ 25 5.5.1 GameManager .................... 26 5.5.2 Token ......................... 27 5.5.3 Choice ........................ 29 6 Case study on the board game Citadels 31 6.1 Structure of the case study code ................ 31 6.2 Rules ............................. 31 6.2.1 Introduction . 32 6.2.2 Components . 32 6.2.3 Game round and player turns . 32 6.2.4 Game end and scoring . 32 6.2.5 Characters . 33 6.2.6 Special districts . 33 6.3 User interface ......................... 34 6.4 Modelling tokens ....................... 35 6.5 Modelling rules ........................ 35 6.5.1 Core game loop . 36 6.5.2 Play of 2, 3, and 7 players . 37 6.5.3 Collecting taxes . 37 6.5.4 Character powers . 37 6.5.5 District powers . 38 6.5.6 Rule ambiguity . 39 6.6 Example rule explanation ................... 39 7 Evaluation of the case study 43 7.1 Library evaluation ...................... 43 7.1.1 Generality and universality . 43 7.1.2 Closeness to the natural language rules . 43 7.1.3 Ease of writing rules . 44 7.2 Possible future improvements ................. 44 7.2.1 Direct support for client-server communication 44 7.2.2 Add debug visualizations . 45 vi 7.2.3 Rely on the programming language’s type system 45 7.2.4 Add direct integration with a presentation layer 45 8 Conclusion 47 Bibliography 49 vii 1 Introduction This thesis aims to design and implement a general framework1 for programmatically describing tabletop2 game rules. A data model to represent game tokens and related metadata is defined, as well asa system for coherently expressing rules. The framework is then implemented in an embeddable library. The goal of the developed library is to simplify the process of digitizing tabletop games by providing useful abstractions and enabling the digital rule expression to be semantically close to the natural language version. The library is published to GitHub3. As a case study, the library is used for digitizing the rules of the tabletop game “Citadels”. The case study is then used to evaluate design and usefulness of the framework and the library. 1.1 Context of digitizing tabletop games Many famous tabletop games were digitized [1, 2], including Settlers of Catan4, Carcassone5 and Agricola6. Game creators may decide to offer the digital versions for free, as a means of marketing forthe physical version. However, it is also common to sell digitized tabletop games in the same way as other video games. Most players prefer physical versions of tabletop games [3]. Fur- thermore, it has been confirmed by many studies that automating certain “boring” elements of tabletop gaming hinders enjoyment [4, 5, 6, 7]. Despite that, there is usually a demand for digital versions of popular tabletop games, sometimes even leading to the creation of unofficial ones by fans [1, p. 5, Digitising Agricola]. 1. This thesis uses the word “framework” to represent the abstract system for formal description of tabletop game rules, and the word “library” to represent the actual source code implementation. 2. This is a blanket term for board games, card games, pen and paper games and other types of turn-based games usually played at a table using physical props. 3. <https://github.com/JanPokorny/tabletop-engine> 4. <https://catanuniverse.com/> 5. <https://boardgamearena.com/#!gamepanel?game=carcassonne> 6. <http://www.asmodee-digital.com/en/agricola/> 1 1. Introduction As of the date of this writing, many platforms are providing the possibility to digitize a tabletop game. Some of them, like Vassal En- gine7, OCTGN8 or BoardGameArena9, each use a different proprietary system of describing rules. Others, like Battlegrounds Gaming En- gine10, Tabletopia11, and Tabletop Simulator12, have no way of imple- menting game rules at all, leaving the burden of conforming to game rules to players. The absence of automatic rule enforcement is usu- ally marketed as a feature, allowing faster iterations when designing games. However, many digital ports of tabletop games are realized through a conventional game engine, such as Unity13 or Construct14. Using general game engines enables almost unlimited possibilities of game mechanics but comes with a cost of high complexity, as these engines do not tailor to the specific limitations of tabletop games. 1.2 Goals of the developed framework and library The developed framework aims to be general enough to allow digiti- zation of virtually all “traditional”15 tabletop games. A library is developed aiming to be an embeddable, cross-platform component enabling various game platforms to enforce tabletop game rules digitally. Separating the rules from the presentation layer enables different software components to use the same rule code internally. Components that may benefit from this approach include client-side rule checking, online games with server-side rule checking, or AI players. 7. <https://www.vassalengine.org> 8. <https://www.octgn.net/> 9. <https://boardgamearena.com> 10. <http://battlegroundsgames.com/battlegrounds-gaming-engine/> 11. <https://tabletopia.com> 12. <https://www.tabletopsimulator.com/> 13. <https://unity3d.com/> 14. <https://www.construct.net/> 15. Such games primarily use physical tokens to represent the game state and have a clear set of rules for players to follow. Games that focus on role-playing or physical player interaction may not be a good fit for this library. 2 1. Introduction The library is developed to be a black-box, providing only the game state to the outside and accepting player choices. There are no assumptions made on how the player input is obtained (live player, AI, ...) and how the game state is presented to the player (rendered in a 2D/3D canvas, serialized and sent over the network, ...). Separation of the rule logic allows the game designer to focus on implementing the game rules and to stop worrying about things like user input or network code. Another aim of this library is to make the digitized tabletop game rules more human-readable and closer to the natural language version. A clear correspondence between the two simplifies the process of digitizing a board game as a whole. Having a close-to-reality digital representation may also allow easier prototyping and development of the rules themselves, by using the digitized version to evaluate different rule variants. The framework and the corresponding library are focused on pro- viding a black-box programmatic interface, with no assumptions on the presentation layer. The library thus does not provide any form of human interface. 1.3 Structure of this thesis This thesis first briefly examines the prior art in the field ofboard games digitization, focusing on the different systems to describe rules. Then, requirements for the framework are decided based on an analy- sis of general principles in board games.