Engineering An Update – Part Two


I wrote a post last week about my struggles and dilemmas while creating the new Trainyard Engineer Update. This week I’d like to talk about what I actually did in this update. I’m not going to get too technical, but if you have technical questions about anything I did, I’d love to answer them, just ask in the comments section.


The backend for this update was probably the biggest area of concern for me. I was seriously considering switching to something like Amazon Web Services, but eventually decided to stick with my current backend (PHP+MySQL on Dreamhost PS). I finally got around to learning a whole lot more about SQL (big thanks to Jim McGinley) and optimized the database with better indexes and smarter queries. I also wrote dozens of new scripts for handling uploaded puzzles, solutions, and other user data.

I rewrote most of the frontend code on the website, creating “AJAX-style” puzzle and solution browsing systems. I added the ability to comment on puzzles, and the ability to open puzzles directly from the site if you’re browsing on an iOS device with Trainyard installed.

The editor

The in-game puzzle editor itself was a huge amount of work, and took a ton of planning to get right. I went through pages and pages of sketches and potential interface designs before I settled on its current look and flow. I’m really happy with how it turned out, but man, it took a lot of effort to get there.

Although creating the puzzle editor itself took a lot of time, I spent even more time creating all the extra stuff to surround it. For example, there’s a screen to enter the puzzle name and description, a screen to let you solve your own puzzles, and even a screen to show you the data you’re about to submit, so you can verify that it’s correct before submitting it.

On top of all that, there are also tons of little subtle features that most people will never see. One small example: if you submit a puzzle that’s identical to a puzzle someone else submitted, it’ll warn you and even allow you to download their puzzle instead.

If you want to see how the editor works and the whole process of creating a puzzle,  just watch the video below:


Creating the system for browsing puzzles was also a lot of work. One of the key issues for me was discovery; I needed players to be able to find great puzzles without having to shuffle through thousands of so-so puzzles. The solution I arrived at is now called “featured puzzles”. This is a list of puzzles that I’ve hand-picked, and that I can update online at any time. This ensures that there will always be a stream of fresh, interesting puzzles.

For players that are brave enough to explore all of the user-made puzzles, I made a “worldwide puzzles” section. There are a bunch of different search options there, so for example, you can find puzzles that are new, popular, or unsolved. I also created a Facebook-ish “like” system where players can choose to like a puzzle after they’ve solved it. As of writing this 5 days after release, there have already been over 10000 likes submitted.

The last two areas of puzzles are “my puzzles” and “saved puzzles”. “My puzzles” is a list of puzzles that the user has created, regardless of whether they’ve been submitted or they’re still being created. “Saved puzzles” is a list of all the puzzles that a given user has tried, whether they’re solved or not.

The video below shows me going through all the different puzzle browsing sections so you can see how they work:


If you’re familiar with the normal game in Trainyard, you’ll remember that all puzzles award “stars” when solved. I decided to do the same thing in engineer mode, but with “wrenches” (spanners for you UK people). I let users assign their puzzles an arbitrary wrench count between 1 and 30 when they submit the puzzle. In theory the wrench count represents the difficulty of the puzzle, but in reality it’s not always accurate, which is totally fine. I considered some more accurate systems for determining puzzle difficulty, but it just wasn’t worth the effort, because wrenches really don’t matter for anything anyway.


The last major thing I added to the game is the “Goodies” section. Goodies is essentially just a catch-all for all the features I had wanted to add but didn’t have a chance. It’s also very flexible so it’s super easy to add more features to it in the future if needed. Here are the items that are there right now: News, Achievements, Tutorials, Mailing List, Tips & Tricks, Solutions.

Goodies: News

News is a list of Trainyard related news items for users to read. The data comes from an xml file hosted on Amazon S3. Each news item has HTML content that can be shown in a webview, which allows for stuff like embedding YouTube videos.

If I want I can also specify that a news item is an “alert”, and then it will pop up when the user starts the game. I can also do things like targeting news alerts to specific users, for example, to those who have a certain version of the game, or to those for whom this version is an update (rather than the first time they’ve played).

Goodies: Achievements

One of the biggest requests for Trainyard has been Game Center support, so I finally decided to put it in this version. The tough part of integrating it was that Trainyard allows you to have two local users, so I had to figure out how to make that work with Game Center.

What I ended up doing is making it so that the local data is authoritative on achievements. The game will never download achievement progress from Game Center. Instead, if an achievement has more progress locally than in Game Center, it’ll automatically push that progress to the server.

This has the benefit that both of the local users can still earn achievements by themselves independently. It doesn’t matter what has happened in Game Center. It’s almost like Game Center acts like a “high score list” for your achievements, they’re only submitted when they’ve improved.

I also have a really cool technical system for keeping track of the achievements. I won’t go into it here too much, but basically any time something good happens, an “achievement source” gets incremented. You can base multiple achievements on a single achievement source (ex solve 1 puzzle, solve 5 puzzles, solve 10 puzzles). It also has a system for tracking uniqueness, so that if you solve the same puzzle 10 times, it’ll only count as one puzzle in the “solve a puzzle” achievement.

All of this was pretty complicated to create, but now I have an extremely robust and flexible way to do achievements that will work for any kind of game in the future.

Goodies: Compare Stars

It’s not in the actual “Goodies” list, but Compare Stars is an option under Achievements. It’s basically just a Game Center high scores list where you can compare how many stars you’ve earned to how many your friends have earned.

Goodies: Tutorials

A tutorial list has been a highly requested feature for a long time. Normally the tutorials are interspersed throughout the levels, but this makes them a lot easier to browse through.

Goodies: Mailing List

I’ve had a Trainyard mailing list set up for a long time, but it’s always been on an obscure area of the Trainyard site where it was super hard to find. I decided I’d finally make it easier to sign up in this update. I’ve been using MailChimp, and they have a super easy API that was really easy to integrate.

Since the update went live 5 days ago, more than 200 people have signed up for the mailing list. That’s not too shabby considering there were only 300 people in the list a week ago. The way I look at it, that’s 200 people who are likely to buy whatever my next game is. I wish I’d put it in sooner.

Goodies: Tips & Tricks

I really wasn’t sure about this section but I threw it in at the last minute. It works similarly to the news section, but each item just contains a single YouTube video. Each of the videos is a short tutorial on some aspect of the game. You can watch them all in this YouTube playlist if you want.

Goodies: Solutions

Not much to say about this. It’s just a link to I’m hoping it’ll cut down on the number of “How do I solve *****?” emails, and if I’m really lucky, it’ll cut down on the number of “Trainyard Solutions” copycat apps as well.

Wrapping Up

Phew. Ok, a golden horse to everyone who made it this far. There were a ton of other smaller features that I didn’t cover in this post, but I think I hit on most of the major ones. Once you consider creating all of these elements and integrating them all cleanly (and mostly buglessly), I think you can probably see why this update took me 3 months to make, hah.

I hope you enjoyed these last two posts. If you have any questions, especially about technical stuff, I’d love to hear it, so just leave a comment down below. As usual you can also reach me on Twitter at @MattRix, cheers!

This entry was posted in App Store, Game Design, iOS Development, Trainyard. Bookmark the permalink.

6 Responses to Engineering An Update – Part Two

  1. Zach says:

    Matt, great set of blogs. Glad to see some new (trainyard) info, I saw it pop up in the
    “New & Noteworthy” games for iPad the otherday, hope the update does well for you.

    I believe you actually stumbled across our game (Refraction) thanks to a blog I wrote. In it I mentioned we were in the progress of getting an iOS port going.

    One of the things we have been wrestling with is whether to include a level editor for the game for the initial release. The bulk of our time thus far has been wrapped up in improving and tweaking every little detail that we didn’t like, or had comments on for the Android version. However creating a level editor would need to be done “from scratch” requiring a lot of time. I am curious what your opinion is regarding such a feature vs the time required.

    I realize the context is vastly different, as this would be an initial release for a little known game, vs a large content update for an already successful game, but any words of wisdom would be great!

    - Zach.

    • Matt says:

      Hmm. I’d say don’t do a level editor right off the bat. It’s a HUGE amount of work to do correctly, and I really don’t think it’ll be that “killer feature” that makes your game stand out. Just focus on the current game and make it as good and *simple* as it can possibly be.

  2. Mark says:

    Just one comment about Wrenches….

    While it’s true they don’t “do” anything, ideally they’d be useful for selecting difficult puzzles. As it is now, there are a good number of trivial puzzles with ridiculous wrench values, making it somewhat useless for that purpose.

    Perhaps a user voting system that would show the average user rating?
    Even a simple sanity check, like “Hey, you only have 2 puzzle pieces, why are you rating this 30 wrenches” would be an improvement.

  3. Toby says:

    Just wondering what the longest solution done is?

    I did a quick google search and found something for 6.4million on the green line. I’m currently running a custom map i just made (called “Longest Possible”). I’m at about 6million now and probably 1/2 – 1/3 done.

    Is there any chance we can do a search on longest solutions, or if there’s a preferred map (like Green Line) to attempt these on.

    btw, thank heavens i finally figured out the super turbo mode (after about 1.5million) when running the solution!!

  4. Toby says:

    Also – a big congratualations on a great game. It is so addictive that i’ve literally lost many hours sleep trying to figure out ‘one last’ puzzle.

Leave a Reply to Matt Cancel reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>