Archive for December, 2015

How do you even develop a 4D game?

Monday, December 21st, 2015

A question I get a lot is: How do you even develop this game? This is related to the question: how can you think in 4D?

Personally when I approach a problem in 4D the key is to find which dimension is the least important and mostly ignore it, so I can think in 3D instead. For example to understand something about the main mechanics, I might think about the 2D/3D levels which I have shown in the trailer. In these levels, the up axis is obviously important, and the rotation is happening in the other two (horizontal) axes, switching from one to the other. In the 4D there is an additional axis, but it is not affected by the rotation of the character, so it can often be ignored.

Later, when I need to write down the 4D math for the model I was thinking about in 3D, it is often the exact same math as in the 3D case. This is because in linear (and geometric) algebra we strive to work in a “coordinate-free” manner, which means we don't write down the x,y,z, and w components of a position but rather work with all the coordinates at the same time, without needing to write them down. Any operation we do works on all the components, one by one, implicitly. For example adding two 2D vectors means adding their x and y components, and adding two 3D vectors means also adding their z components. Having an additional component does not fundamentally change anything about the operation. We are working in a way that does not depend on the number of dimensions. This also works for rotations, which are fundamentally two dimensional in the sense that they rotate one vector into another, regardless of the number of dimensions. I sometimes use 4D Rotors, which have the same interface as Quaternions but for 4D.

That's it! I got better at finding which dimensions to ignore over time.

This approach kind of breaks down a little bit when thinking of objects that change in all dimensions at once (such as duocylinders for example), but the general idea is the same: you can work with math without needing to see all of what it represents at once. Imagining different parts of it one at a time is often enough. The math, and the computer that works with it to display it, can do the rest.

By the way, someone asked a similar question about Intuitive crutches for higher dimensional thinking on mathoverflow and a few outstanding mathematicians even provided answers. I certainly used many of the other things mentioned as well.

Abstraction Design

Sunday, December 6th, 2015

The Introduction to a talk I gave recently...


Creating an abstraction means to take a phenomenon or concept and reduce it to a simpler version by ignoring certain factors. We can then use an abstraction to predict things about the more complex phenomenon or concept.
For example, we can predict the motions of entire planets just using a few simple equations, despite the fact that planets are extremely complicated, by reducing planets to points with mass.

When building abstraction with the goal of predicting something the goal is to simplify as much as possible, but not too much so that we don't lose the ability to predict what we want to predict. An abstractions that is more detailed (ignores less effects) can potentially predict more about the world, but at the cost of being more complicated.
In some sense that is what we have evolved to do as humans, is to learn to ignore the parts of the chaos of our universe that are not necessary for our survival.


If we take a model/abstraction and look at a particular case, we get a prediction.
If we are doing a thought experiment we can imagine what the future state might be.
Or if we have an equation that models some part of the world we can plug in some numbers into it and it will output predictions of what the state of the object will be in the future, for example.
But it recently got very interesting because computers have made this step much easier to do.

For example to produce images of a 3D scene a computer uses abstractions of how light bounces around in the world before it reaches our eyes to produce the images we see, and computes this 30 or 60 times per second.
In some way, by instancing abstractions computers turn them back into “realities” because they can feel surprising, interactive, etc...


There is another thing we can do an abstraction. We can take any abstraction and generalize it without concern for whether it has a physical representation in our universe. You could say this is what pure mathematics is about.
For example, we can add a fourth number to space (x,y,z,w) and see what that would be like.

Any game does this and in a sense games are a natural part of a process to understand the universe, a universe in a more general sense including its generalizations.
For example, Sim City is based on a model (i.e. is an instance of an abstraction) of a city created by Jay Wright Forrester. Adding Godzilla to Sim City is a generalization.

Designing Abstractions

When you look at the world to design an abstraction, ideally if you are a physicists the abstraction might contain surprising results because it might encode more about the world than what you based in on when you designed it.

For example one of the things that made Einstein famous is that his theory of relativity predicted that light’s path would get bent by heavy objects, and in 1919 during a solar eclipse, it was confirmed by looking at starlight as stars passed behind the sun.

When you are making a Video Game, you have to decide what the abstraction level for each component is going to be.

The highest abstraction (i.e. the less detailed) might be “if statements,” for example: if (main character does this) then { react like this } else { react like that }.

For more detail we could use an equation for example to compute the path of a projectile. The equation might become more detailed: we could consider air friction, etc...

An equation might return something that the designer of the equation didn't expect. That's interesting because it means that systems that are at a more detailed level of abstraction are more interesting to explore since the designers themselves more often do not know everything that could happen with them. This effect is what I care about a lot as a designer.

If statements are essentially step functions, which also create discontinuities that are often a source of problems in models. It is possible to combine lots of step functions to make a smooth-looking curve, but it takes a lot more effort.

By the way, I am not saying that all if statements are bad, just that as a designer we chose to focus on a region to explore, and where we explore it is better to use more detailed abstractions. For example, in Miegakure there are characters that walk around using simple state machines. I choose to not explore their internal state very much, as just their change in position is interesting enough with respect to the core of the game.