I got the Introduction to Algorithms book, and it has algorithms on sorting, order statistics, BST’s, B-Trees and lots more. So I just wanted to know how useful these are in game programming, it would be helpful if someone could give an in game example as it will motivate me
Many of those algorithms are extremely useful in games programming, bearing in mind algorithms go hand-in-hand with their associated data structures - the two concepts are often inseparable.
Some examples of their use:
A* open list / priority queue - best implementation is a binary heap, if you actually want pathfinding in real time
Sorting - frequently used all over the place for stuff like sprite depth sorting though you will probably never need to implement your own as the JDK contains good sorting algorithms
Quadtrees / octrees / bsptrees - used in various styles of games to enable collision detection in reasonable time
Cas
Algorithms and data structures are like the fundamental of every game and game/render engines.
Especially “spatial data structures” (and corresponding algorithms) such as Octrees, kD-trees and really any sorts of Binary Space Partitioning (BSP) trees to partition space in order to speed up calculations on fewer elements than what naive algorithms would need (that’s why they are called “acceleration data structures” or “spatial acceleration data structures”).
Where they are being used (at least what I read and heard of):
- Octree, kD-tree (as well as some variants of these) in physics engines
- Octree, kD-tree and very domain-specific variants of these in ray/path tracing engines (although that might not count as “game” render engines)
- Tree structures (based on bounding boxes) for grouping meshes in order for efficient usage of occlusion queries in render engines (there is a GPU gems article about that)
Basically, with rendering and physics engines you have all sorts of tree structures and algorithms everywhere.
Fundament has an amusing other meaning I suggest fundamental :point:
Cas
Oh… There was a brief moment when I asked myself about whether “fundamental” was right, but it sounded so adjective-like, as in “Algorithms are a really fundamental thing in game development”.
So I guess I just dropped the “-al” and it would be the noun.
But then again, English is not my first language. Thanks for correcting!
[quote=“PocketCrafter7,post:1,topic:54762”]
This question is pretty broad, since the term “algorithm” is itself pretty broad. An algorithm is just a set of steps to solve a particular problem, which can describe pretty much any computer program. Substitute in the term “approach” instead of “algorithm” and you’ll see how huge a question like “are approaches helpful in game programming?”
Of course they are. Game development, and programming in general, is the process of creating your own approach to a problem by combining approaches that have been implemented in the past.
Your book probably goes through some of the more famous algorithms, but what it’s really trying to teach you is how to break a problem down into multiple steps and then think about each of those steps in terms of efficiency trade-offs. If you’re planning on being a programmer, that’s pretty much what you’ll be doing for the rest of your life.
Now, you can debate how useful it is to get into the nitty-gritty, like which sorting algorithm is best- after all, you’ll probably just use Collections.sort() instead of implementing your own sorting algorithm. But the process of thinking about the trade-offs of different approaches is useful, and that’s what the book is trying to teach you. It’s not really trying to teach you those algorithms (although that’s part of the process). It’s trying to teach you how to think about algorithms in general. And that’s the part that’s useful.
Jepp, totally true.
Algorithms and Data Structures do not exist out of thin air, but because people invented them to solve a specific problem in an efficient way. So people invented them while thinking about the problem and the various restrictions and constraints any algorithm has to face when being implemented on a computer (for example). Frederick P. Brooks, a very popular computer pioneer, once said that, mostly in the past, all the problems we had with trying to solve problems and to handle their complexity rise from the attempt to trying to solve those problems using a computer.
That’s what he called the “Accidental Complexity” as opposed to the “Essential Complexity.”
And popular algorithms and data structures we hear of are popular because they are very general and applicable to solving a broad set of reoccuring problems.
I mean there are soooo much “algorithms” being developed every day for very very specific problems. A former fellow student of mine developed a mesh reconstruction algorithm which works with arbitrary point clouds and tries to reconstruct a surface mesh from these.
And those algorithms, I tell you, are so twisted and complicated. But that’s because they also try to solve a very complicated problem in a not so common domain.
And consequently, these are the subjects of some many dissertations. But you usually never hear of those things, if you didn’t work in that field.
EDIT: Found that article of Mr. Brooks as a PDF: No Silver Bullet (this is still my favorite read after some years

But then again, English is not my first language. Thanks for correcting!
OT: I suspect most English speakers don’t know the secondary meaning of “fundament” either though For your amusement, Edward the Confessor’s death
Cas
Fundament has an amusing other meaning
I suggest fundamental :point:
It really was amusing xD
Thanks everyone for answering my kinda silly question