On Metacomputers - PART I


First, I made a couple games in March. Actually, I finished five games, the other three are here.

@p Hence I've not done a great job blogging or even working on Texas, which I've just picked up again today. At any rate neither of these games is released yet, but should be soon:

Demonick Farmer Gabo Screenshot Paradise Perfect Boat Rescue Screenshot

First is Demonick Farmer Gabo. It's a farming sim with a twist, the twist that you are a resurrected monkey demon with a thirst for human blood. Eating your cereal crops throughout the season don't always cut it so you tend to go berserk and eat villagers.

@p Second is Paradise Perfect Boat Rescue. You are the driver of a boat trying to rescue people in various scenarios. This one is really fun, and should come to the Intel AppUp Store soon I hope! (fingers crossed.)

@p On with the meat of this post...

Data Code

There is a Koan in programming that says something like this:

First, know there is code, and there is data.

@p Then, know that all code is data.

@p Finally this: all data is code.

Decoded, what it means is that when a person learns to program they will learn that there are data (e.g., int i = 5) and code (e.g., for (int i = 5; i < 10; ++i) {...}). As you learn more about how machines work, you realize that your code is translated into machine langauge which is, itself, bytes of data.

@p But there is a final realization which is that all data is actually code. That is to say:

Data is waiting for some interpretation to give it meaning.

In the above example, "i" is code. It's a special bit of code that the interpreter, in this case the for loop, looks at each time through and uses to measure how many times it should execute. The meaning of "i" is something close to "how many times have we gone through the loop." The for loop itself is like a tiny computer that takes as it's input code this pregnant-with-meaning little letter as part of it's instruction set.

@p If this sounds crazy, keep striving: you have not yet attained mastery.

Metacomputers

Computers, after all, are just layer upon layer of interpreter.

@p An example is OpenGL. This spec itself you can view as a computer, with instructions like glBegin () and glVertex3f (x, y, z), etc. Your commands "glBegin ()" and so forth in C++ are clearly code, but in fact they can be stored just as easily sequentially into a database. There is no particular reason why they have to be called from a programming language, but even if they are stored in a database, they are still code.

@p So is all data in the database.

@p If you're a game designer, then your level data is code describing how to build the level. It might be that you store it as an array of bytes describing tiles, or a list of polygons, or many other types of code. Your level_init () method or perhaps even your physics/collision code is like an interpreter that runs this program.

@p Thought of this way, you can see how computers are just one interpreter on another, on another, on another, and ad infinitum.

So this is relevent how?

It's relevant because good programming means seeing where you can take code written for one metacomputer (e.g., some lines of PHP or C++ or Lua) and create another metacomputer which is simpler to program for but accomplishes the same effect (e.g., a template, or some rows of data in a database describing business rules, and so on.)

@p Then, you can stop programming in the original language and start writing for the metacomputer.

To be continued...

The next blog post will dig into the enemy AI metacomputer system that I have set up and talk about all this in a little more detail.

@p Until then, stay tuned and thank you! =)

@p EDIT: PART II

2010-04-07


◀ Back