Hacker News new | past | comments | ask | show | jobs | submit login
“Game Programming Patterns” is now finished (gameprogrammingpatterns.com)
988 points by rockybox on Apr 23, 2014 | hide | past | web | favorite | 74 comments

Congratulations, Bob!

He had some interesting comments on his writing process in a previous thread entitled, "Write Code Every Day." [1]

He also graciously answered some questions I had regarding his writing workflow, as well as his plans to self-publish a print version of the book. [2]

[1] https://news.ycombinator.com/item?id=7569108

[2] https://news.ycombinator.com/item?id=7569660

> Congratulations, Bob!


> He also graciously answered some questions I had regarding his writing workflow

I've got a long blog post about the whole writing process I'll put up soon.

this is really cool. thanks for putting this up! design is hard :'(

It is, but, like everything, it just takes practice and iteration. Every design I do gets a little better than the last.

I remember seeing one of Bob's posts earlier about how he struggled to finish this. Congratulations to him, I know how difficult it is to complete big projects (they say there's the first 90%, then when the finish line is in sight, there's the second 90%). His perseverance is inspiring!

True, always the last 10% consume as much effort as the 90%

I've always phrased it tongue-in-cheek:

"The first 90% of the work takes 90% of the time. The last 10% of the work takes the other 90% of the time.

That reminds me of the Pareto Principle (20/80):


I've found it to apply to many things in life.

Edit: why would this be downvoted?

Because someone tried to upvote you on a smartphone, and Hacker News has a stubbornly non-mobile friendly design, with no undo.

Does anyone know what the rationale for not allowing users to undo votes is? I'd be happy even if it were only accessible for the first few minutes after the initial action...

There have been several times where I've accidentally upvoted low-quality (sometimes malicious) posts, and I never feel good about it.

Lol. Yep. I accidentally do that every so often, and I always feel bad about it.

Individual downvotes are sometimes errors and are usually quickly corrected.

"Baseball is 90 percent mental. The other half is physical."

   -- Yogi Berra
Same math applies to software and book-writing

Writing software is 60% understanding the problem, 25% understanding the tools, 20% understainding requirements, and -5% hacking the solution to make it fit requirements.

    Mental: 64.29%
    Physical: 35.71%

The 90/90 rule fits a lot of things, to the point that whenever I see it, it seems cliche now. That doesn't make it any less applicable and relevant though, which is why we see it so much.

Looks great! I think it would add greatly if you have a chapter that illustrates the development of a simple game where many of these ideas are illustrated.

I teach coding to high-school kids. When I tell them that "We'll be building a game" attention increases exponentially; unfortunately I know nothing about how to program anything beyond simple board games, e.g. tictactoe. I can totally use ideas from your book in my course.

Also, many of the students are also in the school's FIRST Robotics Team. I noticed that programming the robot and game programming are quite a similar (at a high level). So this might help with that, too.

Thanks a lot once again, I entered my email and will definitely be following along.

You might be interested in StoneSoup, a project a friend of mine developed for teaching his week long Intro to Video Game Programming for middle school and high school students. Most of the students have little to no prior programming experience, and by the end of the week they have several games in Processing which they can call their own.


You might be interested in http://codecombat.com/

Why doesn't the section on double buffering mention triple buffering? Double buffering is useful but it has a very important limitation: if the consumer is slower than the producer then the producer can stall while the consumer is still working, and then the consumer gets stale data for its next iteration. The extra memory cost of triple buffering is always worth it for gaming, because none of the ephemeral state data is all that large, and latency matters.

Bob, if you're lurking this thread:

Congrats. Any idea when I'll be able to buy it?

Like the other free-online-first books I've read, I've gotten enough value from it that I'd like to thank you by paying for it.

> Any idea when I'll be able to buy it?

As soon as possible!

Unfortunately, I don't know how long that will be. I'm going to be typesetting it myself with lots of love using InDesign. I hope the final result will be a really nice book, but it could take me a while.

Still, I plan to work on it every single day, so maybe it will go quickly.

> I've gotten enough value from it that I'd like to thank you by paying for it.

Just a thanks is more than enough, but buying a copy of the print book will be the best way to throw money at me (short of showing up at my house and making it rain, I suppose).

this is where marketplaces like fiverr.com really prove their value - you could pay a couple of people 20 bucks each to do a 90% job of typesetting and you could finish it up later.

YMMV - but you dont have a lot to lose. You could be surprised by the time you save.

> I'm going to be typesetting it myself with lots of love using InDesign.

Have you perhaps considered LaTeX/XeTeX? Would get you incredibly beautiful typeset foundations, then you can customise it a lot further.

Likewise, I don't really need to own a physical copy though so if there was some system whereby I could donate a copy to a school then I'd be very keen.

You can also donate here: https://www.gittip.com/munificent/

I'll redirect you to here: http://www.reddit.com/r/programming/comments/23qnnc/i_finish...

The author is the submitter of the post and is replying to comments. He addressed the same question there too.

I'd like to buy it in physical form, if that is in the works. I've had a hard time using mobile versions of non-trivial texts and tend to bookmark without ever revisiting.

I'd like to second this. I would very much like to throw money your way.

Thanks so much for all of this. It's extremely well put together.

I'm still trying to figure out the optimal way to organize every part of a Dwarf Fortress-style simulation (but multi-threaded of course), and I feel like I'm reinventing the wheel somewhat poorly. Component-based design is an important part of that, but there are still so many hairy problems to solve.

These are problems which most games don't encounter because they're not complex simulations. And the agent-based simulation literature isn't much of a help either.

Something you can do with components if you set some strict restrictions is do static or runtime analysis to determine which sets of components are disjoint in terms of systems that access them. For example, if the combat system only needs access to combat components, and the builder system needs pathing and inventory components, then those two systems can run completely in parallel.

One place this is likely to break down is the transform (position) component, but one strategy for that is to differentiate between read-only and write access. Lots of systems need to know where things are (const access) but few need to change where things are (write access). All the systems that can deal with const access can still run in parallel.

The trick here is you have to strictly enforce all this. You CAN'T have a method for getting an arbitrary component from an entity, and this may drive you nuts. Instead you have to have each system specify ahead of time exactly what components it needs and how it uses them, and then hand them those components, and only those components. As soon as you let someone write "entity->GetComponent(Physics)" in leaf code, you've lost your ability to analyse the dependency tree.

For a lot of games, the other problem you're going to run into is that one or two systems are going to take up most of your time and every other system is just going to sit around waiting for those anyway. Usually those are physics and rendering. Which you might be happily avoiding by making a dwarf fortress style game!

I have a coworker who's got a "toy" engine at home that does all this and some other fairly amazing tricks. He says he's going to open source it, still waiting on that. Sorry for this pointless tease, just wishing he'd hurry up out loud.

That's an ambitious project you're undertaking. Can you share more?

As I said, on a technical level think Dwarf Fortress - but with a bit less detail and a much larger world (potentially distributed across multiple servers). I'd like to be able to truly simulate a medieval/fantasy RPG world, so a player can see logical consequences from their actions.

The same underlying simulation could conceivably be used for a peaceful economic sim, or a highly strategic military game, or just an RPG with a ton of depth.

This is something I have been thinking would be great, Mount and Blade has been the only game that has come close in my opinion.

Don't really understand how you would stop players just slaying all your NPC's? Which I think isn't a problem in the whole if it was offline single player but after playing many online games I just can't see it actually working online.

Also recreating DF with a lot less detail in real time across multiple servers seems like a insane technical challenge good luck!

Thank you so much for writing this! As someone working to transition from webdev and enterprisey CRUD app development to something that, if not gamedev itself, deals more with simulation and modeling worlds, it's been difficult to deal with the true change in mindset that's needed. Over the past few weeks I've had "read a chapter of Game Programming Patterns" as a recurring to-do item, and it's opened my eyes greatly.

I had to force myself to close the window to get back to work. Great job on the content. I was pleased to see a reference to entity-component systems on the component page, too.

I'm not a game programmer, but the movement around ECS is very interesting to me.

Congratulations Mr Nystrom! I've been reading through each chapter as you posted them, and I've found your writing style throughly enjoyable and your ability to describe complex code patterns with ease.

It's really hard to get the motivation to finish such a project, serious kudos to you; I shall be buying that e-book!

You and everyone else who ever posted something nice about the book were the ones who provided the motivation. I absolutely would not have finished without that.

Does anyone know about such a book/list with game-play patterns?

Most of the time I work with game engines, which already use the patterns mentioned here. I struggle with stuff like moving entities in specific directions, collision detection, physics, gravity, etc.

Game Mechanic Explorer[0] covers some of these, with examples and source code.

[0] http://gamemechanicexplorer.com/

This was recently posted on HN: http://gamemechanicexplorer.com/

This is a great read. It goes into detail about the practical application of design patterns- when to use them, when not to use them, and some gotchas that are not mentioned in other books. I'd pay for a downloadable PDF version of this!

Good choice of font. I can't stand reading long online material with sans-serif.

Yes, it drives me crazy when people use sans serif fonts for body copy. You need the serifs to help tie the line together!

There are sadly few serif fonts on Google Web Fonts that have consistent letterforms, good metrics, a nice middle-of-the-road x-height, and good bold and italics, but Merriweather is quite nice.

Congrats to Bob! He's been working on this forever, in public.

Over four years!

You are a legend. Seriously.

I've really enjoyed reading your book since I last came across it on HN! Thanks for writing this! I'd be glad to donate a bit, if you add a donation option.

I'll gladly purchase an epub for this, looks wonderful.

Great work, and thank you from the community.

I've been looking for something like this for a long time, game development still seems like something of a dark art and a lot of the resources I've found online are either too high-level or too focussed.

Does anyone have a script to package this into an ebook format? I'd love to be able to read it on my Kindle.

Thank you Bob! I've been reading through your book and applying the patterns to both work (web applications) and my hobby game projects. The way you describe the patterns, especially the component pattern, made it clear exactly how to apply it to my projects. This is an awesome resource.

Exciting to see this finished. I remember his comments in Write Code Every Day - https://news.ycombinator.com/item?id=7569108

Super excited to see that his writing strategy worked and it is released. Nice work Bob.

love the way this stuff is written. no overloaded jargon. the Command pattern chapter was amazingly straight-forward and everything else learned was immediately applicable to a game project I'm refactoring. hard to say that about many similar books on the subject. bravo! :)

Thank you very much for this book! As a beginning game developer this was just what I was looking for. After learning how to do rendering, physics, AI and so on I was missing how to put it all together in a proper way. This is a great resource! :)

This looks awesome - I have been wishing for a resource exactly like this for a while now. With my first game under my belt I learned the hard way how difficult game programming can be. I need some high level advice and this looks perfect.


This is a valuable resource, and congrats on completing it! Although I don't know if it 100% complete... please provide source for the lurchIneffectively() method mentioned in the Command patter chapter :D .

Left as an exercise for the reader!

Wow, great work! I'm reading through this - it seems to apply to other programming fields other than just games programming. Really, really appreciate this hard work and making it free!

This is a marvel, I can't thank you enough. I'm a mobile application developer, and I really wants to make game someday. The introduction is one of the best I've read.

This is pure gold. Well written and informative. Thank you!

Congratulations! That's a great achievement, and you finished it much faster than I thought. As soon as I get it, it's next on my to-read list :)

It didn't feel fast to me!

I don't often login and comment, but i just have to say thanks to Bob. yYou thought me one or two new ways to think about things :)

I was hoping it would be about patterns of games, not patterns of programming. These patterns are not specific to games.

The drawings are cute and immensely helpful. I will pay money for this once it's in print!

Has game development got a target singularity? What would it be? Simulated Worlds like Matrix?

Nope. Games are widely varied in their scope and delivery. I am fairly confident there is no single target.

This is great, congrats. I've been wanting to get more into game development.

Cool!Start reading now.

Great work!

Looking forward to ponder on it.



Registration is open for Startup School 2019. Classes start July 22nd.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact