Wednesday, January 13, 2010

Towards a Universal Game Language

If you can express a game to a computer (through the act of programming), then there must be a language (as in a language produced by a generative grammar) that can describe that game and all games that can be similarly expressed. You could say that such a language is a programming language—which is true—but we can clearly make a non-programming language that can succinctly and precisely express game mechanics of any game that can be programmed into a computer.

A game, as it exists and is played, is just billions of ones and zeroes on your harddisk. All of the game assets and compiled code that resides on your machine expresses a game to your computer. Your computer reads and interprets these chunks of binary data to put certain pixels on your screen at a certain time depending on a myriad of game rules and your input. The compiled code and assets on your machine represent everything that the game can be, as an entity. They are a complete expression of the game.

All modern computers (computers that use the von Neumann architecture) are simply glorified Turing Machines. A programming language is a way to tell that overgrown Turing Machine what to do. Any problem solvable by a computer can be expressed as a Turing Machine whose behavior is specified by a recursively-enumerable language. Programming languages are nothing more than recursively-enumerable languages.

Games are simply creative expressions of problems through the use of programming languages, graphics, and sound. If you can program a game into a computer, there must be a simpler language you can invent to specify games directly.

Let’s call this universal game language GLang. Here’s what we know about GLang without even doing any heavy lifting:

  • GLang will be no more complex than a Turing-complete programming language (a recursively-enumerable language) like C, C++, Java, Python, Ruby, Perl, etc.
  • The expression of a game in GLang will be shorter (probably by several orders of magnitude) than the code of the game, because games have to have a lot of code that manages assets such as graphics and sound, runs the server, and does all kinds of non-game-mechanic-related stuff.
  • A game expressed in GLang will be specified in a clear, precise, unambiguous, machine-readable way.
  • A specification in GLang can be verified as a complete expression of a game. Unfortunately, it’s not certain that you’ll be able to verify that it’s a complete expression of the game you want to express—that’s a chicken-and-egg problem, really.
  • Though the terminology different game designers use to describe their designs won’t all match up, we’ll have a distinctly and precisely defined set of terms for each game by the nature of the specification of that game in GLang. It doesn’t matter what you or I specifically call something (“stat” or “attribute” for instance), the game mechanic will be operationally defined by its relationships to other mechanics.

It’s clearly possible to make GLang a reality—it’s just a matter of applying ourselves to the problem and doing thinking damn hard for a damn long time. Forward-thinking designers like Raph Koster and Daniel Cook have begun work on ways to succinctly and clearly describe games. Koster has Game Grammars and Cook has Skill Atom Chains, and there's also St├ęphane Bura's attempt. I’m fascinated by this concept; I’ll be giving it a shot myself.

5 comments:

Sara Pickell said...

I may have to take a shot at that myself. Either way though, I'll be interested in seeing what you come up with.

valyard said...

Google MetaProgramming System from JetBrains. Your GLang looks like another use of a Domain Specific Language.

foolsage said...

Yeah, that's a topic that's occurred to me more than once as well. Game development would be drastically aided by a fairly high-level (in programming terms) language to describe mechanics; we're after all dealing with a fairly high level of abstraction. A modular approach would be optimal, allowing for design elements to be logically laid out and interconnected.

Tolthir said...

You might want to check out Zillions of Games (www.zillions-of-games.com). It's described as a "universal gaming engine", although it only works for abstract strategy games.

I'm honestly skeptical about the ability to create a truly universal game grammar because of the huge variety of possible games. It's definitely possible for specific subsets of games though.

Aliuar said...

I've started working on a graphics engine several times, and it forced me to rethink how much Math knowledge I had. I knew I had very little but I honestly had no idea what I was getting myself into.

The thing about the context of the screen is that it represents what you can consider a very large set of possible combinations. In a game we are essentially limiting the permutations of the screen to a subset that literally is our own operators to try to keep the system "ordered" but incomplete. No one has the time to see every possible image on the screen.

A language attempts to take the role of the explicit operator but it has to do more than just select some set of images to render, it needs to have an impact in the mind of the reciever and be "interactive" to that reciever.

I often take a step back and consider the ramifications of the monitor. It was very fasciating when I realized you could generate any image of the past present or future on the monitor.

One of the projects I'm working on, and will continue to do so, is an image rendering framework that enables the highest degree of expressionability for rendering dynamic content. A general goal but an inquiry which I hope to learn many things.

To be quite frank, when I started building a graphics engine, I was 24 years (2 years ago) and had little to no math background, perhaps a 7th grade math background, a little prelagebra.

Now I'm studying fluid dynamics, and honestly infinite series blew my mind, there are a lot of really neat things in life that we fundamentally don't know until we somehow intersect that tidbit of knowledge or realization.

Wow, but there's just so much to do.