A Component-based Game Engine for the Game-O-Mat Game Generation System Mike Treanor American University treanor@american.edu Abstract (Ivey et al. 2018). Those researchers shared many of the same goals of this project and they presented a methodol- This paper describes the game engine of the forthcoming ogy for designing engines targeted for game generation. Ivey game generation system titled The Game-O-Mat. As under- et al. describes the process of “capturing inspiring exam- lying game engines strongly constrain the space of possible games that a generator can create, the goal of this paper is ples” by adding many parameters freely and then refining to fully document the design considerations and features of them through consolidation. The Game-O-Mat’s engine was this game engine that was designed with game generation as likewise augmented and enhanced by implementing several a priority. This paper is aimed at helping future developers of classic, yet simple, games, and features and components game generation systems. were added as needed. This process was applied until it be- came unlikely that a generator would be able to create the game examples. This paper concludes with an advanced ex- Introduction ample that shows the limits of what the generator might be The purpose of this paper is to document the features and able to handle. design considerations that have gone into the forthcom- ing game generation system titled The Game-O-Mat. The Game-O-Mat system (which is heavily inspired by Game- Another project very close to The Game-O-Mat in nature O-Matic) (Treanor et al. 2012), has been designed with the is Gemini (Summerville et al. 2018), an impressive generator goal of enabling the easy creation of games that represent that made use of computational interpretations of its games ideas through gameplay metaphors built from graphical log- as it generates. During development, the engine itself was ics (Wardrip-Fruin 2020). Rather than evaluate the system’s given to human developers who were tasked with creating generator (which has been in concurrent development), this games. As described below, this process was lightly emu- paper will compare and evaluate the design of the game en- lated as sample games of increasing complexity were hand gine itself. In the game AI research field, a spects s uch a created to test the engine. Other game generation systems generator’s game engine are often only loosely described, and game description languages exist and provide valuable and regarded as implementation details, as they do not di- insights. For example, some incarnations of ANGELINA rectly describe the use of particular artificial intelligence (Cook, Colton, and Gow 2017) were designed with genre- techniques. While it is true that the design of a game en- specific goals (e.g. Metroidvania), and the VGDL project gine is arguably a matter of software engineering and game was designed around creating games that could be played design, it is a mistake to not recognize that the underlying and evolved using automated players. Similarly, Duplantis engine of a generation system strictly constrains what kinds et al. similarly present an example of a genre specific game of games a system can generate, as the generator needs to description language for role playing games in the style of manipulate the engine to create games. Furthermore, the de- the games made for Game Boy (Duplantis et al. ). sirable features of a game engine designed for generators to manipulate will be different than the desirable features of a game engine designed for human creators. Game generation is arguably one of the most difficult A large part of the design and development of this challenges for procedural content generation because there component-based engine involved determining the set of be- are so many interrelated facets involved (Liapis et al. 2019). havior components, and how they would interface together. There will be no solution to this challenge, and instead re- Ivey et al. encountered a similar scenario while developing searchers will present a set of generators that support dif- their physics-based parameter driven game system, Gamika ferent aesthetic experiences of varying levels of complexity. This paper simply hopes to fully document what the games Copyright © 2021 for this paper by its authors. Use permitted of The Game-O-Mat are made out of in order to help future under Creative Commons License Attribution 4.0 International creators of game generation systems. (CC BY 4.0). Engine Features tags. For example, if there were to be a “Tank Controller” component, it could be tagged as a component that enables At the core of The Game-O-Mat, and most component-based movement, and the generator could know that there was a game engines, are game objects and behavior components. game object to control in the game when it saw that any Game objects are typically the objects that move around on game object had a component with that tag. The Game-O- the screen that collide with, and create other game objects. Mat’s generation engine will need determine that there is a Behavior components control what these game objects do controllable game object using a more sophisticated method. and how they interact. Components are modular in that they are created to operate independently. The idea of viewing Component Parameters Each component has a small set certain games as graphically represented entities that behave of parameters that configure the component’s behavior. Ex- according to rules, and that react when they collide/overlap amples might include the “Rotate” component’s rotation with one another is central to what Wardip-Fruin describes speed, or the amplitude of the “Movement” component’s as games with graphical operational logics (Wardrip-Fruin y axis sinusoidal movement. Each parameter is assigned a 2020). The game engine for The Game-O-Mat is designed default value, and for numerical parameters minimum and to be able to represent the space of simple one-screen 2d ac- maximum values. Furthermore, the engine is able to trans- tion games comprised of graphical logics (such as those that late terms such as “fast”, “moderate”, “very fast”, etc. into were played on the Atari 2600). In addition to components, appropriate numerical values for parameters. Additionally, a game objects can be associated with variables that either can range can be provided that will be randomly resolved when be used as blackboards for inter-component communication, evaluated. These details are very important, as the genera- or a mechanism to track an individual game object’s state. tor will struggle to make fine adjustments, and the ability Game object variables can also be used and displayed as part to coarsely and minimally specify games is essential for the of the game’s mechanics (see Orbital example below). generator to operate. To add concrete ways for games to end, this engine also provides mechanisms for a game to terminate (i.e. be won Component Targets Some components control a game or lost). These win-and-lose conditions make reference to object with regard to some other game object. For exam- either a counter or a meter. Counters are numerical values ple, the “Move Towards” component needs to know what it tracked by the engine, and conditions are comprised of sim- is moving a game object towards. This engine refers to these ple equality/inequality checks on their values. Meters are vi- game objects as “targets,” and a component can target an ar- sually represented counters. bitrary number of other game objects, or a group of “tagged” game objects (game objects can belong to an arbitrary num- Components ber of groups by sharing a tag). When a component targets more than one game object, it will default to targeting the The set of components, their ability to adapt, and their ex- closest one. Components can also target the mouse pointer. pressivity define the range of possible games that can be developed in a component-based game engine with prede- Component Activators By default, when a game object fined components (as is the case with The Game-O-Mat). is assigned a component, that component will perform its The Game-O-Mat’s engine particularly strives to provide a behavior upon that game object. However, components can minimal set of components that are adaptable to many cir- be configured to only perform their behavior under certain cumstances without requiring an inordinate amount of con- conditions. The mechanism that controls these conditions, figuration. The set of components of the current The Game- called “activators,” are shared by all components and they O-Mat engine was arrived at through balancing the conflict- drastically enhance a component’s versatility. Once an acti- ing priorities of generality and ease of configuration. vator’s conditions are met, it will make it so the component As a concrete example of these conflicting priorities, con- will apply its behavior to the game object for a specified sider a single “Tank Controller” behavior component that duration. If no activator’s conditions are met after that du- would make any game object rotate when the player pressed ration, the component’s behavior will no longer be applied left and right, and move forward and backwards when the to the game object. Below is an overview of the currently player pressed up and down. This very common player con- available activators: troller behavior could also be represented by two different components that simply rotated on input, and a second that • Collision: A component is only active if it is graphically moved forward on input. The Game-O-Mat’s engine chose overlapping with a targeted game object. to avoid components of the “Tank Controller” variety, and • Distance: A component is only active if it is within a instead abstracted the conditions under which a component specified distance of a target. would be active to allow for components to focus on one task at a time (described below). The point of highlighting • Input: Make a component active when specified mouse this choice is to emphasize this unavoidable engine design or keyboard input is received. challenge, and to motivate the design of the activation sys- • Timer: A component is activated after a specified amount tem described below. of time passes. This activator can optionally reset itself. This design decision is a departure from Game-O-Matic. Game-O-Matic made use of less general components and • Meters/Counters State: Activate a component when a thus was able to make more use of descriptive component counter or meter reaches certain states (e.g. score ¿ 0). Figure 1: Kaboom! is relatively easy to represent using The Game-O-Mat’s game engine. • Component or Game Object Parameter: Activate a pa- Scored Rule Engine rameter when one of the game object or component’s pa- rameters reach a specified state (e.g. when the game ob- Built into The Game-O-Mat is a rule system called the ject’s scale is greater than 2). Scored Rule Engine (SRE). SRE is able to answer a wide • Conjunction: This activator is configured with a list of range of questions about the game state by evaluating rules activators (such as those described above). The compo- and returning truth values and bindings. While primarily nent will only be active if all of the activators in the list’s used by the generator not described in this paper, these bind- conditions are met. Note that the original list of activators ings can be useful for providing targets and also can mod- is by default a disjunction of the supplied activators. ify the game state is certain real-time scenarios. The set of queries the system can make currently are: • SRE: Make a component active when a Scored Rule En- gine (SRE) rule evaluates to true (details below). • HasComponent: Does an game object have a specified Component Effects Effects are external changes that a component assigned to it? component can make to a game when it is activated. The pri- • HasTag: Does an game object have a specified tag as- mary use of effects is to modify meters and counters, how- signed to it? ever they can also be used to spawn other game objects. • Colliding: Are two game objects currently colliding? Development Platform One of the primary goals of game generation systems de- • GameObjectPropertyCheck: Does a game object have scribed in this paper are to enable non-experts to rapidly a property that meets some condition? create and share games about anything. While Game-O- Matic partially delivered on this goal, the platform it was For an example of a SRE rule being used as an activator, developed for, Flash, is no longer supported on contempo- see the Orbital example below. rary browsers, and thus games cannot be created or shared While SRE and the activator system duplicate some func- any longer. In response to this, The Game-O-Mat is be- tionality, SRE is able to make much more sophisticated ing developed using ECMAScript 2015 (ES6) without tak- queries of the game state. However, because rule evaluation ing advantage of libraries and development platforms that requires exploring the search space of logical binding possi- may become defunct. The graphics engine is currently p5, bilities, it is computationally expensive and should be used though the interface to the graphics engine is clean and The sparingly for real-time applications (at least until perfor- Game-O-Mat has also used PhaserJS. This paper is aimed at mance enhancements are made). Finally, it should be noted helping future developers of game generation systems, and that the engine does not make full use of the rule system choosing a long lasting platform to develop for, in this case (particularly the ‘Scored’ part which is used by the genera- the web browser without plugins, is strongly recommended. tor while making design decisions). Figure 2: The iOS game Orbital was able to be created in this engine, but required nuanced engine manipulation that would be hard to a generator to perform. Example: Kaboom! “DestroyOnTrigger” components with collision activators Below is a description of how this engine implements the are applied. One that targets the player that has the effect of classic game Kaboom! (1983). In Kaboom!, the player con- causing the Score to increase, and the other targets the world trols the left and right movement of a graphical depiction of object (described below) that has the effect of decreasing the buckets of water using the arrow keys. The goal of the game Lives counter by one. is to catch the bombs that a mad bomber is hurling down at Finally, the world game object is a sized to be a long rect- the world below. When the player (buckets) collides with a angular game object at the bottom of the screen. bomb, the score is increased, and when a bomb gets by the This example illustrates how game objects, components, buckets they lose a life (presumably because the bomb deto- activators, and effects all work together to create a game. nated in the unseen world below). Other games that this engine can represent with similar complexity (as measured by lines of JSON and compo- The Game-O-Mat’s engine represents Kaboom! in 210 nent/activator assignments) are Pong and Breakout. lines of expanded JSON that makes use of basic engine fea- tures with lightly configured components. To begin with, two counters are created for Lives and Score. Next the mad Finding the Limits of the Engine: Orbital bomber game object is created and placed at the top of the While The Game-O-Mat’s engine can relatively easily repre- screen, and given a random x velocity (to begin it moving sent games with the complexity of many Atari 2600 games, left or right). Next, it is assigned a “ModifyGameObject- the same cannot be said for games with more sophisticated Property” component with parameters that will multiply the game mechanics. As an example, consider the early iOS ac- game object’s x velocity by -1, as well as a timer activa- tion game, Orbital (2009). Orbital is a one-button game, tor that will activate the component periodically. Next, an where the player controls the launch of a small projectile “EdgeWrap” component is applied. These two components from the bottom of the screen. The object that launches the get the Mad Bomber moving left and right in unpredictable projectile is slowly rotating from left to right, making the ways. Next a “CreateOnTrigger” component is applied with game primarily about choosing when to press the button in parameters specifying that is should create a bomb (details order to control the trajectory of the projectile. A launched below) at its current position, and a timer activator that will projectile bounces off the side of the screen and slows down control the rate that bombs are created. according to a model of physical drag. When it stops, it The bombs game object description involves first applying expands in size until it collides with either the side of the a ”Movement” component that constantly moves the game screen, or with another stopped projectile. Stopped projec- object downward (no activators are needed as it is desired tiles display a number, and this number decreases when- for this to be constant behavior). Next, a ”Lifetime” com- ever a projectile collides with it. When a stopped projectile’s ponent is applied that will remove the game object after 6 number hits zero, the stopped projectile is removed from the seconds (this is done for performance reasons). Next, two screen and the player’s score increases. The goal of the game is to earn a high score. generation. In the case of The Game-O-Mat, it is currently It is clear that Orbital is a game with considerably more more of a priority to enable the generation of Atari 2600 complex dynamics than Kaboom! While The Game-O-Mat’s style games, and no “Orbital Projectile” component will be engine is able to represent Orbital, it takes 419 lines of ex- introduced. However, the engine does support the represen- panded JSON (roughly twice the size of Kaboom!), and this tation of such games. JSON is considerably more nuanced than that of Kaboom!, and it makes used of highly configured advanced features of Conclusion and Future Work the engine. To illustrate this, this section will describe some This paper presented the game engine that the forthcoming aspects of the Orbital projectile and its behavior. Game-O-Mat is going to use to represent the games it gener- First, projectiles are given a tag so that other components ates. The goal of the paper is to document in detail some of can target them. They also need to have two variables: one to the considerations and design choices made in order to cre- represent the counter that decreases on collision (as part of ate an engine that is configurable by an artificial intelligence the game’s main mechanics), and another as a flag to track system. Future work will of course involve the completion whether the projectile is in its moving state or a stopped of the generator and the crafting of the user experience. In state. addition to being a media artifact that stands on its own, the For the simple part of the component assignment, the goal of this project is to serve as a platform for research in projectiles need to have a “Forward Movement” compo- component-based game generation. nent to make them shoot out from the launching turret, and a “Bounce” component to make them bounce off of other References game objects with the projectile tag. Things start to become more complicated because the projectiles behave differently Cook, M.; Colton, S.; and Gow, J. 2017. The angelina whether they’re moving after being launched, or expanding, videogame design system—part i. IEEE Transactions on or stopped. Representing these different states required mak- Computational Intelligence and AI in Games 9(2):192–203. ing use of the conjunction activator, and making the conjunc- Duplantis, T.; Karth, I.; Kreminski, M.; Smith, A. M.; and tion conditional on a property activator that checks the value Mateas, M. A genre-specific game description language for of one of the game object’s variables. For example, we need game boy rpgs. to make sure we only have the projectile bounce off the left Ivey, P.; Ferrer, B.; Saunders, R.; Gaudl, S. E.; Powley, E.; and right walls when it is moving. If we didn’t do this, when Nelson, M.; Colton, S.; and Cook, M. 2018. A parameter- the projectile was done expanding (and likely touching a space design methodology for casual creators. In ICCC. wall), we would be constantly activating the component that Liapis, A.; Yannakakis, G. N.; Nelson, M. J.; Preuss, M.; reverses the x velocity which would cause strange movement and Bidarra, R. 2019. Orchestrating game generation. IEEE when the projectile should be staying still. Instead, we make Transactions on Games 11(1):48–68. the component that modifies the velocity first target the left and right walls, and then make use of a conjunction activator Summerville, A.; Martens, C.; Samuel, B.; Osborn, J.; with both property activator checks seeing if the projectile is Wardrip-Fruin, N.; and Mateas, M. 2018. Gemini: Bidirec- moving or not, and also a normal collision activator. In order tional generation and analysis of games via asp. Proceedings for this to work, we need to change the value of the moving of the AAAI Conference on Artificial Intelligence and Inter- variable to false at a different area of the game description. active Digital Entertainment 14(1):123–129. Orbital also necessitated the use of a Scored Rule En- Treanor, M.; Blackford, B.; Mateas, M.; and Bogost, I. 2012. gine (SRE) type activator in order to decrease a projectile’s Game-o-matic: Generating videogames that represent ideas. counter. In English, each projectile checks the following four In Proceedings of the The Third Workshop on Procedural conditions: Am I colliding with something (Colliding)? Is Content Generation in Games, PCG’12, 1–8. New York, that something another projectile (HasTag)? Is that other NY, USA: Association for Computing Machinery. thing moving (GameObjectPropertyCheck)? Am I not mov- Wardrip-Fruin, N. 2020. How Pac-Man Eats. MIT Press. ing (GameObjectPropertyCheck)? If the answer is yes to all four questions, activate the “ModifyGameObjectProperty” component and decrement the counter variable of the game object. These are just two of many nuanced and interconnected uses of the engine that were required to create Orbital. The purpose of these examples was to demonstrate the point at which the structure of this engine limits its expressivity. While the generator can in principle create a game with dy- namics like Orbital, it is unlikely. This example also shows how more committed and spe- cific components could be authored to enable certain sets of mechanics (i.e. the behavior of an Orbital projectile could in principle we a single component). Situations like these are important to consider when creating a game engine aimed at