Sign in to follow this  
Inian

Game Design Patterns

Recommended Posts

Inian    122
Hello everyone, yet again I post a new thread. I apologize in advance if a similar one exists, I only did a quick search before giving up. If you know of one please post a link to it and shut this thread down. Now, on to business. Right now I'm interested in reading up on design patterns that are frequently used in games. I found 3 books in the books section that seem the most interesting on the subject. They are: Software Engineering and Computer Games Design Patterns: Elements of Reusable Object-Oriented Software Patterns in Game Design They all have varying reviews and seem to be on an introductory level, which seems like a good place to start. I'm wondering if anyone knows any similar books that dig a little deeper? Gamasutra seemed to have some game design pattern information too, but I couldn't check it out since I'm not registered there. Anyone know if the information at Gamasutra is any good? And finally, since I'm poor and unemplyed at the moment, I wouldn't mind if you suggested some common game design patterns that I could read up on over the internet. To help me pass the time untill I can actually afford to buy the books. (And I'm predicting someone will mention the library, I've already checked there, none of the above books were available nor were any similar ones.) Thanks in advance!

Share this post


Link to post
Share on other sites
nife87    520
Just register on Gamasutra - it's free ;)
And there's lots and lots of usable information on everything to gain from registering (including game design patterns and the like).
For example, there's a great article about the MVC pattern used in Vietcong and postmortems from many, many games (like Diablo II, AoE and Thief).
You won't finish soon, I can guarantee you that much.

Share this post


Link to post
Share on other sites
ApochPiQ    23000
I second the suggestion to hunt around on Gamasutra; they have some excellent resources.

In general, the kinds of patterns I've seen and used personally in the game world tend to be fairly similar to the "standard" patterns. Some of them will be more useful than others, but that's always true.

Some particular suggestions, in no particular order:
  • Focus on the Interpreter pattern. It appears in many forms in games and is probably the single most important pattern to really understand. Underestimate it at your own peril.

  • Remember that patterns are just patterns, not blueprints. They should be used to give you ideas for good ways to organize your code, not as detailed plans for exactly how to build a system.

  • You can get all kinds of good information and history from the original C2.com wiki, which documents the "canonical" design patterns from the Gang of Four book. It's a great place to get lost for hours. The best way to read the wiki is as a sort of point/counter-point discussion; a lot of people have woven in alternative views and perspectives. Don't treat it as gospel, but rather use it as a way to develop your own opinions and understanding.

  • A solid understanding of concurrency will also be very important. Getting familiar with multithreading, multiprocessing, distributed systems, network synchronization, and so on is highly advisable.

  • Hang around on programming.reddit.com for a while, and you'll see some recurring links and blogs that are good resources as well. Very little of it is games-specific, but the principles are generally solid and applicable across most fields, including games.

  • If you only have cash for one book, buy The Pragmatic Programmer. It'll serve you very, very well. Also, make sure you reread it at least once a year, because you'll learn something new every time through.



That ought to keep you busy for a while [smile]

Share this post


Link to post
Share on other sites
Inian    122
Thank you both, I'll get right on Gamasutra and start poking around.

It's funny you should mention MVC nife87, as it is the only pattern I've read about at all.

The interpreter pattern sounds like fun, I have no idea what it is but I'll read up on it as soon as possible. I've heard a log about the Gang of Four, I should really check out their stuff. :P

Threading is something I stink at right now, so far I've only done some small programs with semaphores and shared memory to synchronize and communicate between threads. And I really did not enjoy it. Networking on the other hand is on my "to do soon" list, I'm thinking of using raknet and to do that I'm going to have to dissect it and see what makes it tick.

The Pragmatic Programmer got good reviews in the books section, I'll check it out. Right now I'm reading C++ books I borrowed at the library, trying to freshen up my memory on the stuff I rarely use. Also it felt wrong not having read Stroustrups own book on C++ when it is my main language. =)

Share this post


Link to post
Share on other sites
dingojohn    159
Why is the interpreter pattern used that much in game development? To me it seems that it is only a solution when interpreting strings etc. Mind that I have never used it or read muh about it.

Share this post


Link to post
Share on other sites
ldeej    308
The books that I have found which have some useful information on the topic are:

Object-oriented Game Development by Julian Gold, in this book the author goes into some detail on how to create an object oriented game engine with the usage of design patterns.

C++ for game programmers by Noel Llopis, a book that goes into several different implementation techniques, which are actually different patterns. The title is missleading, it is actually a pretty good book.

Share this post


Link to post
Share on other sites
ApochPiQ    23000
Quote:
Original post by dingojohn
Why is the interpreter pattern used that much in game development? To me it seems that it is only a solution when interpreting strings etc. Mind that I have never used it or read muh about it.


Interpreter is at the core of the scripting language systems used in pretty much every large-scale game developed in the last 10 years. Remember, the strings it works on don't necessarily have to be human-readable/English text; that makes virtual-machine based script systems and embedded languages candidates.

Even in cases where a full scripting language isn't used, Interpreter is often employed to assist with high-level game logic, map descriptions, and so on. I would wager that any AAA title on the shelves has at least one, and probably two or more, implementations of Interpreter.

It is well worth the time to study it further and look beyond the (very rudimentary) description given in the GoF book. The important thing, as with all design patterns, is the general concept, not the specific example or code provided in books and reference materials.

I would go so far as to say that a good understanding of Interpreter, alongside a solid understanding of why Lisp's s-expression code format is so powerful, are two of the most important revelations a programmer can have. Each will make you a better coder, and the combination is guaranteed to have profoundly positive effects on your code quality and productivity.

Share this post


Link to post
Share on other sites
SnOrfys    200
I personally found the GoF book to be horrible. You'd be better off going to www.dofactory.com (though it's a .NET resource) - it has infinitely better examples to wrap your head around, and it's free.

I'll also second The Pragmatic Programmer. It's strangely true that you do learn something new each time you read it (so I know 5 things - I need to get reading).

As per games, I've seen the flyweight pattern used a fair bit - mostly for improving memory management for threads and lots of on-screen objects (like bullets in side scrollers).

The factory pattern works well in some situations (in a game that I worked on we had multiple character classes that the user could play as - this made it fairly easy to manage remote/ai players as well as the user).

Obviously State and Composite are essential if you're going to do any AI.

I heard recently that the command pattern can be used for networking (asynchronous send/receive calls), but I've yet to research it and try it out - you be the judge.

Share this post


Link to post
Share on other sites
bombinator-dev    134
Pattern Hatching: Design Patterns Applied by John Vlissides (one of the GoF) is a pretty good introduction to design patterns and their use. Holub on Patterns is a fantastic book but be warned that it is no introductory level text.

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