What Sorts of Algorithms and Data Structures are Useful to Game Programmers?

Started by
17 comments, last by archanian 11 years, 5 months ago
Thank you for pointing this out. I believe it is an important difference.
Not to be on the defensive but I still haven't had the chance to experience what you picture.

Previously "Krohm"

Advertisement
All right, thanks for the input guys. I guess I should have expected these types of answers. Game programming is a broad subject as is data structures and algorithms so it's hard to give a solid answer. I'll just keep coding and reading and I'm sure my question will be answered in time. I bought the book because I don't have a formal education in computer science and I thought it would be usefull to learn some of this stuff. Plus, it was recommended by Mike McShaffry in the book "Game Coding Complete" that a programmer learn this stuff if he wants to write games. So I thought, hey what the heck.

@Krohm: I'd have to disagree. The "concept x is useless because I've never used it before." argument doesn't hold much water. Unless I'm just misunderstanding your point, in which case I apologize.
Really everything in STL.
For a game developer, you don't really need to know that in detail. But know how data structures work. For example you should know how trees, linked lists and dynamic arrays work.
And learn to use the interface.
An invisible text.
I primarily use the following:

-Lists
-Dictionaries
-Stacks and Queues
-Arrays

Dictionaries are pretty much hash tables. If I need to store items and pull them out by some key value, then I use a dictionary. If I just need to store a collection of items, I use a list. I rarely use stacks and queues, but sometimes the occassion pops up where they're useful. Arrays are handy for keeping data continguous in memory (which helps with CPU caching), but I think I recall that C# lists are really just arrays wrapped into a list class. It might be worth looking into that...

I rarely ever use binary trees, but I do use binary space partitioning ideas (for QuadTrees) and recursion.
Since I primarily use dictionaries and look up items by a key, I never need to sort my items.

I think the very core of programming most software is about logically managing lists of data :P At least, that's what I find myself doing a lot.

For a game developer, you don't really need to know that in detail.

Depends on what type of game developer. if you are working on mobile/console, then you are likely going to need to know a whole lot about cache architectures, efficient algorithm design, etc. If you are writing for PC, can probably get away without.


I think the very core of programming most software is about logically managing lists of data tongue.png At least, that's what I find myself doing a lot.

Then you should be learning LISP wink.png

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

I did a search on this page for 'shader' and was shocked to find it lacking.
Game developers often wear many hats (particularly early in their career) and at some point you will probably be writing a shader, even if it's a simple one. But before anyone will really accept you in this industry (that is to say, hire you) you will need to have made a game or at least a solid demo of a game. The unfortunate truth is you will likely be doing this alone. Get a case of redbull and every programming book you can afford; long nights ahead.

-Aeramor

CTO at Conjecture, Inc.


For basic game logic, you need to understand at least basic trees because that's what you need to represent hierarchical things.

Basic algos: at least binary search, breadth-first search. The latter is a simple way to solve a wide range of general problems, including pathfinding. A*, IDA* etc. are more complicated, potentially more efficient ways of solving similar problems but you can look at them later if and when you actually need performance.

For performance you are going to have to learn heaps and hashes.

As an aside, you'll rarely want to use a linked list because the performance sucks in practice. Vectors/arrays are usually the right way even when textbook logic would suggest linked list. A lot of the time you will want to keep these sorted so that you can use binary search on them.

I've reintroduced myself to a data structure that's simpler but as effective as a binary (search) tree. It's called the skip list. :)

Beginner in Game Development?  Read here. And read here.

 

In my opinion its more important to know that other data structures and algorithms exist, and that using an array (or a list) will normally work, but there are often data structures much better for the task at hand. The trick is recognising those situations.

Be aware of data structures, but you don't need to go around implementing them until you actually have a use for it.
[size="2"]Currently working on an open world survival RPG - For info check out my Development blog:[size="2"] ByteWrangler
I think this is good advice, but the only way to know the appropriate uses for such algorithms/structures is to understand how they work and what their strengths/weaknesses are, for which you will need to at least study them, and preferably practice using them.

I know a lot of programming can be done by just "using what works", but for me it all depends how seriously you want to take your game development. If you want to make a career out of it, you're going to need to know a lot of theory as well as practical experience.

This topic is closed to new replies.

Advertisement