• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
sunnysideup

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

18 posts in this topic

Hello to you all. I purchased the book "Introduction to Algorithms" because I'd like to get a better understanding of the sorts of algorithms and data structures that are used in game programming. The first thing that I noticed about the book is that it is HUGE. There's no way I could just sit down and read this thing from cover to cover, and even if I did I would hardly be able to retain all of that information.. I plan on going through all of the sorting algorithms since the book mentions that they are used by many of the other algorithms, and I am already familiar with linked-lists. What other algorithms and data structures are common in game programming?
0

Share this post


Link to post
Share on other sites
Sorry but I disagree.

Sorting algorithms. Here's what you need to know.
[url="http://www.cplusplus.com/reference/algorithm/sort/"]std::sort()[/url].
Having spent several months at sorting algorithms, I feel safe stating that this is the only thing I care about sorting as an algorithm book would discuss.

Pathfinding algorithms.
Spending effort on them even before starting is a bit of a stretch. I'm not saying this is not necessary, but you can get a lot of mileage before this becomes a blocking stop.

Object pooling.
Studying that in theory is complete nonsense. Get a real problem first. Profile. Fix (if necessary).

What's really needed? How to build sane code. Documentation, style, engineering, knowledge of real-world problems.
Or more related to implementation: object lifetimes, smart pointers, proper OOP, various code patterns etc. Edited by Krohm
1

Share this post


Link to post
Share on other sites
Game programmers use every algorithm and data structure. An unhelpful statement, but true.

You have to classify the different types of game programming tasks to understand what algorithms and data structures are applicable.

For example, someone implementing a 3D rendering system will use totally different things than the guy writing high-level gameplay logic.

My suggestion: Some tasks in code are FAR more common than others. You can get 80% of any programming job done with nothing but simple lists (std::vector, System.Collections.Generic.List<T>, etc) and map/filter operations (map = convert one list to another by applying a conversion function to each element, filter = return a subset of a list based on a function that tests each element). Learn how to use these well. When you run into a case where performance or memory use is too unacceptable, open your book up and look for something that's specific to your situation. Edited by Nypyren
2

Share this post


Link to post
Share on other sites
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.
1

Share this post


Link to post
Share on other sites
Get familiar with graphs and trees, most spacial algebra, coordinate spaces, translation, rotation, scale, cinematic physics, smart pointers are useful but expensive, there is nothing like knowing how to be careful with dynamic memory, state machines... profiling and debugging tools & techniques...
0

Share this post


Link to post
Share on other sites
Oh, also get a good grip on recursivity and asynchronous execution, they are tough topics many people crash against sooner or later
0

Share this post


Link to post
Share on other sites
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.
2

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
[quote name='lride' timestamp='1351890692' post='4996667']
For a game developer, you don't really need to know that in detail.[/quote]
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.

[quote name='slayemin' timestamp='1351891266' post='4996669']
I think the very core of programming most software is about logically managing lists of data [img]http://public.gamedev.net//public/style_emoticons/default/tongue.png[/img] At least, that's what I find myself doing a lot.[/quote]
Then you should be learning LISP [img]http://public.gamedev.net//public/style_emoticons/default/wink.png[/img]
0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
[quote name='Stroppy Katamari' timestamp='1351849220' post='4996481']
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.
[/quote]
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. :)
0

Share this post


Link to post
Share on other sites
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 [i]actually [/i]have a use for it.
1

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0