Generating Rules for Video Games
Total Page:16
File Type:pdf, Size:1020Kb
feature Creativity In Code: Generating rules for video games Mediums such as fine art and poetry are common subjects in computational creativity—but what about something closer to home? Can computers be as creative in programming as they are in poetry? By Michael Cook DOI: 10.1145/2460436.2460449 omputational creativity research is littered with work in various high-culture domains: fine art, poetry, musical composition, and more. Both the general public and researchers themselves are fascinated by questions of aesthetics, whether machines can evoke emotion from us, and whether there is anything that sets Shakespeare Capart from Siri. Away from the arts lies an equally challenging medium, however; one that thousands of creative people engage with every day, and one that lies closer to computational creativity than any other—programming languages themselves. Many areas of computer science leveraged for personal creative expres- BAFTA-award winning Journey (see have already tried to tackle the prob- sion. The popularity of the Java-based Figure 1), or the taut depiction of war lem of programs that write programs. processing environment among artists in Spec Ops: The Line, we can also see Some subfields of artificial intelligence and designers is a good example of this. evidence that games are becoming an ex- grew out of kinds of program genera- The popularity of projects like Code pressive medium on an individual level. tion, such as inductive logic program- Year and Codecademy demonstrates Designer and critic Anna Anthropy ming or neural networks. In software the general public’s desire to under- calls for exactly this in her book Rise of engineering many optimization and stand the world of data and code and the Videogame Zinesters: “[the] transmis- abstraction techniques involve code reflects the increasingly prominent role sion of ideas and culture from person to that can “unroll” or automatically se- of programming in modern society. person, as personal artifacts instead of lect code templates for expansion. Perhaps the clearest example of pro- impersonal creations by teams of forty- However, none of these applications gramming being used as a medium five artists and fifteen programmers.” fully appreciate programming as a cre- for creative expression is that of video If we are to tackle code generation ative endeavor. games. Gaming has risen from being from the perspective of computational In his book Creative Code: Aesthet- an idle distraction to a major creative creativity, and to try and understand ics and Computation, John Maeda de- medium, now occupying a broad spec- how software can write software not scribes programming as “not a tool trum from pure entertainment on for purely functional ends but for cre- [but] a new material for expression.” one end to meaningful artistry on the ative ones, video games seem a fine We can see this to be true, program- other. While mainstream gaming now place to start. Their innate interactiv- ming is not merely a means for getting includes complex works such as the ity lends itself well to evaluation; their things done, but increasingly is being religious pilgrimage depicted in the popularity ensures we are never lost for 40 XRDS • sUMMER 2013 • VOL.19 • NO.4 contemporary human-authored com- mechanic design, such as the Experi- initely well motivated, but how do we parators (or willing survey participants mental Gameplay Project. get software to write software? What for that matter); and their interrelated- So we know game mechanics are would a mechanic-inventing computer ness with graphical, audio, and cultur- important to people, and building sys- program look like? al content makes them a fascinating tems that can write new ones could For the last few years, I’ve been crucible of artistic mediums, all bound offer exciting new technology to the building a piece of software called up in this central medium: code. games industry. We also know it’s a ANGELINA (A Novel, Game-Evolving But where do we start? If we want to great way to test out new ideas about Labrat I’ve Named ANGELINA). ANGE- begin an investigation into how com- generating program code for creative LINA uses computational evolution to puters can write program code creative- means; because video games are huge produce game elements like level de- ly, which part of a video game should we programs at their heart, but they also signs, or powerups, and by simulta- begin with? Anna Anthropy sums it up express really creative ideas. We’re def- neously evolving these smaller game best when she describes games as “an components it can design an entire experience created by rules.” To build game, with each component designed systems that engage with the heart of a to fit in with all the others. This modu- video game, we must start with the rules Games are filled lar design has had lots of advantages, that build the game’s inner systems. one of which is that it’s easy to de- There are many different types of with rules, including velop new components over time and rule within games, but by far the most game mechanics, add them into the process. Late last interesting are the rules that govern year, I worked on a brand new compo- what we, the player, are allowed to do. which convey nent called Mechanic Miner that de- These rules, or game mechanics, are experiences on signs game mechanics by changing a the laws that decide what happens game’s program code. when you press X, and what numbers the player. Not just Mechanic Miner performs a three- go up or down when you land on that big experiences stage process. First, it generates game flashing spike over there. Major inter- mechanics by looking at program code. national games industry awards rec- like feeling sad Then, it evaluates the best mechanics ognize innovation in game mechanics, or triumphant, that it finds. Finally, it designs levels like the Independent Games Festival’s that use the new mechanic in their Nuovo Award, and lots of game design but little pockets solution. Although currently operat- events center around unusual game of micro meaning. ing on a small scale, Mechanic Miner’s XRDS • sUMMER 2013 • VOL.19 • NO.4 41 feature new parts of the level, or until it reach- Figure 1. Journey is an independently-developed award-winning game about es the exit (whichever comes first). If pilgrimage, co-operation, and humanity—and great evidence that games are we do this with the standard template becoming culturally important. game, it’ll tell us it’s not possible. Since we know the level isn’t solv- able using the normal game code, we can make small changes to the game and then record what changes in the solution. So if Mechanic Miner adds one of its generated game mechan- ics, and then discovers that it can reach new areas or complete the lev- el, it knows the new mechanic added something to the game. This black- and-white evaluation technique lets Mechanic Miner evaluate game me- chanics without needing extra infor- mation about how to use the mechanic or what the mechanic does—it keeps trying to use any buttons available to it techniques are general enough to ex- ducts an experiment. Figure 2 is a basic until it reaches the exit, or gets stuck. tend to a wide variety of applications template of a level from a Super Mario- This technique gives such clear and scales, and its integration into like game. Imagine you were the player feedback on how useful a mechanic is ANGELINA will let us explore these trying to get to the exit, you might no- that even with a complex problem like through the project in future research. tice that it’s impossible; Mario can’t code modification Mechanic Miner is To generate new game mechanics, jump high enough to clear the wall in still able to generate and identify use- Mechanic Miner first takes the code the middle of the level. This is the exact ful game mechanics out of thousands for a complete game written in Java. level that Mechanic Miner used in our of potential game variables. Examples For our purposes we use a Java port prototype work to evaluate game me- of game mechanics generated by the of the popular Flixel game library (the chanics. By outfitting Mechanic Miner system include the ability to flip grav- origin of which was the iPhone and with the ability to execute and play the ity upside-down (as seen in the indie online hit game Canabalt), and a basic game, we can ask it to try “solving” this platformer VVVVVV) and to make template platform game with the bare platform level by trying every combina- the player’s character bounce off the basics of moving and jumping. In order tion of moves until it can’t reach any ceiling and floor (similar to ideas in to simplify the design problem for this prototype system, Mechanic Miner currently generates a very specific Figure 2. A basic template level used by Mechanic Miner to test mechanics out type of game mechanic—one that tog- for usability. The player, as Santa, must somehow get to the present. gles between two states each time a but- ton is pressed. Mechanic Miner search- es for variables in the game’s code, and then applies a randomly selected modifier to it, such as addition, sub- traction, or inversion. For example, a generated game mechanic might double the player’s “currentHealth” variable when a button pressed. Most mechanics generated in this way won’t be as useful, of course. In reality, at this stage Mechanic Miner has no understanding of which variables it is choosing.