## Timeslicing Batched Algorithms in Games

This post is part of my Game Programming Series.
The source files for generating the animations in this post are on GitHub.

A very useful technique to improve the performance of batched algorithms (multiple instances of the same algorithm) is timeslicing: instead of running all instances of algorithms in a single frame, spread them across multiple frames.

For instance, if you have 100 NPCs in a game level, you typically don’t need to have every one of them make a decision in every single frame; having 50 NPCs make decisions in each frame would effectively reduce the decision performance overhead by 50%, 25 NPCs by 75%, and 20 NPCs by 80%.

Note that I said timeslicing the decisions, not the whole update logic of the NPCs. In every frame, we’d still want to animate every NPC, or at least the ones closer and more noticeable to the player, based on the latest decision. The extra animation layer can usually hide the slight latency in the timesliced decision layer.

Also bear in mind that I will not be discussing how to finish a single algorithm across multiple frames, which is another form of timeslicing that is not within the scope of this post. Rather, this post will focus on spreading multiple instances of the same algorithm across multiple frames, where each instance is small enough to fit in a single frame.

Such timeslicing technique applies to batched algorithms that are not hyper-sensitive to latency. If even a single frame of latency is critical to certain batched algorithms, it’s probably not a good idea to timeslice them.

In this post, I’d like to cover:

• An example that involves running multiple instances of a simple algorithm in batch.
• How to timeslice such batched algorithms.
• A categorization for timeslicing based on the timing of input and output.
• A sample implementation of a timeslicer utility class.
• Finally, how threads can be brought into the mix.

## Game Math: Curve Approximation via Curve “Projection”

This post is part of my Game Math Series.

Also, this post is part 2 of a series (part 1) leading up to a geometric interpretation of Fourier transform and spherical harmonics.

Drawing analogy from vector projection, we have seen what it means to “project” a curve onto another in the previous post. This time, we’ll see how to find a the closest vector on a plane via vector projection, and then we’ll see how it translates to finding the best approximation of a curve via curve “projection”. This handy analogy can help us take another step closer to a geometric interpretation of Fourier transform and spherical harmonics later.

Posted in Uncategorized | 3 Comments

## Game Math: “Projecting” a Curve onto Another

This post is part of my Game Math Series.

Also, this post is part 1 of a series (part 2) leading up to a geometric interpretation of Fourier transform and spherical harmonics.

Fourier transform and spherical harmonics are mathematical tools that can be used to represent a function as a combination of periodic functions (functions that repeat themselves, like sine waves) of different frequencies. You can approximate a complex function by using a limited number of periodic functions at certain frequencies. Fourier transform is often used in audio processing to post-process signals as combination of sine waves of different frequencies, instead of single streams of sound waves. Spherical harmonics can be used to approximate baked ambient lights in game levels.

We’ll revisit these tools in later posts, so it’s okay if you’re still not clear how they can be of use at this point. First, let’s start somewhere more basic.

Posted in Uncategorized | 1 Comment

## Game Math: “Dot Product” of Curves

OK. Based on some feedback, turns out the wording of this post is logically loose and not entirely correct. Here is a revised version of this post.

## 我的Uncharted 4開發雜記

Here is the original English post.

Uncharted 4已經發售，終於可以分享我負責開發的部分了

Posted in Gamedev | 19 Comments

## A Brain Dump of What I Worked on for Uncharted 4

This post is part of My Career Series.

Here is the Chinese translation of this post.

Now that Uncharted 4 is released, I am able to talk about what I worked on for the project. I mostly worked on AI for single-player buddies and multiplayer sidekicks, as well as some gameplay logic. I’m leaving out things that never went in to the final game and some minor things that are too verbose to elaborate on. So here it goes:

Posted in Gamedev | 31 Comments

## 我的秘境之旅

Posted in Gamedev | 6 Comments

## My Uncharted Journey

This post is part of My Career Series.

Here is the Chinese translation of this post.

Note: This post was written before Uncharted 4 went gold, so it might contain tones or implications that Uncharted 4 hasn’t gone gold yet. Sorry for the confusion.

I started working on Uncharted 4: A Thief’s End almost two years ago, and here we are, less than two months before release. This would be my first shipped title as a full-time game programmer (I shipped Planetary Annihilation during a summer internship). Looking back now, I realized that I’ve really come a long way since I first wanted to make games more than a decade ago. I would like to take this opportunity to write down this journey to share with you and as a note for myself.

## DigiPen: 我的遊戲學校

Posted in Gamedev | 8 Comments

## DigiPen: The Game School I Went To

This post is part of My Career Series.

Here is the Chinese translation of this post.

Disclaimer: This post is all about my personal experience with DigiPen and is in no way intended to represent anyone else’s experience or opinions.

I went to DigiPen Institute of Technology to learn how to make games in 2011, and graduated last year (2014). I graduated one year earlier than my fellow classmates in the same year, because I transferred in some credits I had already earned at my previous college in Taiwan.

I have written one post about my life at DigiPen every year on a game design forum in Taiwan. Also, many of my DigiPen friends just graduated and have started their jobs in the game industry. So I thought, why not write a dedicated post about my experience at DigiPen in English on my blog?

Posted in Gamedev | 20 Comments