Casanova 2, a Domain Specific Language for General Game
Total Page:16
File Type:pdf, Size:1020Kb
Tilburg University Casanova 2 Abbadi, Mohamed Publication date: 2017 Document Version Publisher's PDF, also known as Version of record Link to publication in Tilburg University Research Portal Citation for published version (APA): Abbadi, M. (2017). Casanova 2: A domain specific language for general game development. [s.n.]. General rights Copyright and moral rights for the publications made accessible in the public portal are retained by the authors and/or other copyright owners and it is a condition of accessing publications that users recognise and abide by the legal requirements associated with these rights. • Users may download and print one copy of any publication from the public portal for the purpose of private study or research. • You may not further distribute the material or use it for any profit-making activity or commercial gain • You may freely distribute the URL identifying the publication in the public portal Take down policy If you believe that this document breaches copyright please contact us providing details, and we will remove access to the work immediately and investigate your claim. Download date: 30. sep. 2021 mohamed abbadi C A S A N O VA 2 ,ADOMAINSPECIFICLANGUAGEFOR GENERALGAMEDEVELOPMENT TiCC Ph.D. Series No. 52. Corso di Dottorato di ricerca in Informatica - Ciclo 29 - SSD: INF/01 Final Version as of September 24, 2017. ISBN: ... Print: ... All rights reserved. No part of the Thesis may be reproduced, stored in a retrieved system, or transmitted, in any form or by any means, electronically, mechanically, photocopying, recording or otherwise, without prior permission of the author. © Mohamed Abbadi C A S A N O VA 2 ,ADOMAINSPECIFICLANGUAGEFOR GENERALGAMEDEVELOPMENT PROEFSCHRIFT ter verkrijging van de graad van doctor aan Tilburg University op gezag van de rector magnificus, prof.dr. E.H.L. Aarts, en Ca’ Foscari, University of Venice op gezag van de rector magnificus, prof. M. Bugliesi, in het openbaar te verdedigen ten overstaan van een door het college voor promoties aangewezen commissie in de aula van Tilburg University op vrijdag 10 maart 2017 om 14.00 uur door MOHAMEDABBADI, geboren op 19 augustus 1988 te Abu Dhabi, Verenigde Arabische Emiraten Promotores: Prof. Dr. A.A. Maes Prof. Dr. P.H.M. Spronck Prof. Dr. T. Cortesi Copromotor: Dr. G. Maggiore Overige leden van de promotiecommissie: Dr. R. Bidarra Prof. Dr. E.O. Postma Prof. Dr. H. Hlavacs Dr. Ing. S. Göbel Prof. Dr. M. L. Jaccheri Amare et sapere vix deo conceditur. I dedicate this work to my mother, for being the best example for me in my life, and to Soha for bringing light into my life. ABSTRACT In today’s society, the pervasiveness and sales of video games is at an all-time high. Video games are used in a variety of application scenarios, from pure entertainment to supporting research, raising social awareness, and training. Video games are no longer developed only by professional programmers, but also by experts in other domains. This has made the problems surrounding the process of game development increasingly ev- ident. One such problem is the lack of a clear methodology for defining video games, supported by user-friendly tools. Indeed, the available tools for making video games are either too specific or too general. When too specific, the abstractions provided by the tool are so poor that only few game genres are expressible. When too general the abstractions provided by the tool are so generic that even expressing simple domain concepts requires a lot of effort. These problems lead to the process of developing video games being a costly one, in terms of time, money, and necessary knowledge. Such costs negatively affect the development process, and may even lead to the impossibility to develop certain games. When a solution is offered that reduces the cost of game development, this will benefit in particular the developers for whom game development is not their main job. This thesis starts by analyzing the process of making a video game, and examines the available tools for making them. It then proposes a solution to the high costs of making games. This solution comes in the shape of a programming language that is exclusively focused on the domain of video games. This language, which we call Casanova 2 (inspired by its predecessor language Casanova, with which it shares goals and philoso- phy), is designed to offer abstractions built around the typical aspects of video games. Casanova 2 is not bound to any video game genre. Due to the specificity of the domain of game development, and the strong require- ments it brings with it, the compiler behind the Casanova 2 language is able to apply code analysis. Together with a series of optimization layers, it is able to turn complex domain code into a highly-performant executable. Casanova 2 comes with a series of advantages such as embedded network- ing, and high-performance encapsulation support, which positively affects the production of games. The thesis evaluates Casanova 2 by comparing it with representative lan- guages, that are often used for video games, on expressiveness, compact- ness, speed, ease-of-development, and maintainability. It demonstrates that Casanova 2 is either equivalent to or outranks all competitors in these re- spects. This warrants the conclusion that Casanova 2 achieves its goal of offering a game development language that can be successfully used by a wide variety of developers to build video games. vii PUBLICATIONS Abbadi, M., Di Giacomo, F., Orsini, R., Plaat, A., Spronck, P., and Maggiore, G. “Resource entity action: A generalized design pattern for RTS games.” In: International Conference on Computers and Games (pp. 244-256). Springer International Publishing. Abbadi, M., Di Giacomo, F., Cortesi, A., Spronck, P., Costantini, G., and Maggiore, G. “Casanova: a simple, high-performance language for game development.” In: Joint International Conference on Serious Games (pp. 123- 134). Springer International Publishing. Abbadi, M., Di Giacomo, F., Cortesi, A., Spronck, P., Giulia, G., and Mag- giore, G. “High performance encapsulation in Casanova 2.” In: Computer Science and Electronic Engineering Conference (CEEC), 2015 7th (pp. 201-206). IEEE. Abbadi, Mohamed, “Taxonomy of Game Development Approaches.” In: Entertainment Computing and Serious Games (pp. 119-147). Springer. Di Giacomo, F., Abbadi, M., Cortesi, A., Spronck, P., and Maggiore, G. “Building game scripting DSL’s with the Metacasanova metacompiler.” In: Intelligent Technologies for Interactive Entertainment: 8th International Confer- ence, INTETAIN 2016 (pp. 231-242). Springer International Publishing. Di Giacomo, F., Abbadi, M., Cortesi, A., Spronck, P., Costantini, G., and Maggiore, G. “High performance encapsulation and networking in Casanova 2.” ACCEPTED In: Entertainment Computing. Elsevir. ix That you are here—that life exists and identity, That the powerful play goes on, and you may contribute a verse. — Walt Whitman [101] ACKNOWLEDGMENTS Thank you to my family for being always there, you are and will be always my lighthouse. Thank you to Giuseppe for being my friend, brother, and mentor. Thank you to Pieter and Fons for having helped me to become the re- searcher I am today, and for having always been there for me in the past 3 years. Thank you to Tino for putting your trust in me and for sharing your knowl- edge and experience with me. Thank you to Jerry and Parastoo for being always there ready to give me advice and support. Thank you to all the people who believed, and still believe in me: Francesco, George, Ahmad, Enrico, Giulia, Farzad, and the list goes on. I will always carry you in my heart and will always be grateful to you. xi CONTENTS 1 introduction1 1.1 Traditional games 1 1.1.1 Key ingredients of traditional games 1 1.1.2 Functions/goals 2 1.2 Video games 3 1.2.1 What is a video game? 3 1.2.2 Business impact 6 1.2.3 Functions/purposes 7 1.3 Building video games 7 1.3.1 On the process of making a video game 8 1.3.2 Technological complexities 10 1.3.3 Video game developers 12 1.3.4 Current approaches 14 1.4 Our focus and problem statement 14 1.5 Contribution and thesis outline 15 2 taxonomy of game development approaches 17 2.1 What is a game? 17 2.1.1 Video Game 17 2.1.2 Formal definition of a video game 18 2.2 Game development 21 2.2.1 Assembly language (hand made everything) 23 2.2.2 Game Creation Systems 25 2.2.3 Graphics API 29 2.2.4 Game Engines 34 2.3 Discussion 38 2.4 The necessity for a domain specific language 41 3 the casanova 2 language 45 3.1 Technical challenges in games development 45 3.1.1 Running example in pseudo-language 45 3.1.2 Discussion 47 3.2 Casanova 2 48 3.2.1 The basic idea behind Casanova 2 48 3.2.2 The running example in Casanova 2 49 3.2.3 Syntax 50 3.2.4 Semantics 51 3.3 Summary 52 4 compiler architecture 53 4.1 The structure of the Casanova 2 compiler 53 4.2 Code generation 54 4.2.1 Entities 55 4.2.2 Attributes 56 4.2.3 Rules 57 xiii xiv contents 4.2.4 Generating state machines for rules’ code 60 4.3 Supporting third-party tools and engines 69 4.4 Summary 71 5 compiler optimization 73 5.1 Maintainability vs. speed 73 5.2 Focus of the work and related works 75 5.2.1 Runtime dynamic machinery 76 5.2.2 Compile-time code generators 76 5.3 Encapsulation in games - an example 77 5.3.1 Design techniques and operations 77 5.3.2 Discussion 78 5.4 Optimizing encapsulation 80 5.4.1 Optimizing lookup 80 5.4.2 Optimizing temporal/local predicates 80 5.4.3 Language level integration 81 5.5 Implementation Details 81 5.5.1 Casanova 2 rule 82 5.5.2 Compilation