Tweaking your game with Google Spreadsheets

tweaksheet Our latest game, Grunts: Skirmish, has 200 tweakable parameters. There are 9 player units with three levels of upgrade, and another 9 enemy units. Each unit has between three and ten parameters that can be altered.

We tried a few approaches – hand-editing a large XML file (but it was too large and spread out) and an in-game tweaking UI (but it was too much work to get the UI to be friendly to use). The old standby of having the designer and artist file bug reports to have the programmer update the game wasn’t getting us very far, either.

“Well,” says I, “We’re some sort of Web 2.0 startup, right? And we’re developing a Flash game aren’t we? And Flash can talk to websites, can’t it? And don’t we use Google Docs for everything?”

It turns out there is an XML feed from public Google spreadsheets. And ActionScript 3 supports E4X, so you can directly manipulate XML without any extra work. Now we tweak our game using a shared spreadsheet up on Google Docs.

I wrote a parser for their format:

// Extract the entries. It's namespaced, so deal with that.
var xmlns:Namespace = new Namespace("xmlns", "http://www.w3.org/2005/Atom");
tweakXML.addNamespace(xmlns);

// Parse into a dictionary.
var cellDictionary:Dictionary = new Dictionary();
for each(var entryXML:XML in tweakXML.xmlns::entry)
{
   cellDictionary[entryXML.xmlns::title.toString()] = entryXML.xmlns::content.toString();
}

And wrote a quick component that would fetch the spreadsheet feed, parse it, and stuff it into the right places on named objects or template data. Now I have a little entry in our level file that looks like:

<object id="googleTweaker">
   <component class="com.pblabs.debug.GoogleSpreadsheetTweaker">
     <SpreadsheetUrl>http://spreadsheets.google.com/feeds/cells/0d8somekey848x/od6/public/basic</SpreadsheetUrl>
     <Config>
        <!--  Grunt Level 1 tweaks -->
        <_><Cell>B3</Cell><Property>#TheGruntProxy.creator.WarPointCost</Property></_>
        <_><Cell>C3</Cell><Property>!Grunt.health.mMaxHealth</Property></_>
        <_><Cell>D3</Cell><Property>!Grunt.ai.AttackSearchRadius</Property></_>
     </Config>
  </component>
</object>

Each line maps a cell in the spreadsheet to a property on a template or active game object. Some properties have to be set several places, which the system deals with automatically.

The biggest wrinkle was Google’s crossdomain.xml policy. Basically they do not allow random Flash apps to access their site. So I had to write a small proxy script, which sits on our development server next to the game and fetches the data for it. Figuring out I had to do this took more time than any other step.

The main difference between the snippet and the full code is the version in our repository is 220 lines long. I only have around 150 of the full set of 200 parameters hooked up, but after a hard afternoon’s work, the process for tweaking the game has become:

  1. Open Google Docs.
  2. Edit a clearly labeled value – like level 1 grunt health.
  3. Restart the game, which is running in another tab in your browser.

This takes you about a minute between trials. Not too bad. Before this, the process was:

  1. Get the game source from SVN.
  2. Find the right XML file – there are several.
  3. Find the right section in the XML – altogether we have 200kb of the stuff for Grunts!
  4. Change the value.
  5. Commit the change.
  6. Wait 5-15 minutes for the build system to refresh the live version of the game.

Ten minutes per tweak is not a good way to develop.

I’ve heard about developers using Excel spreadsheets for tweaking, but can’t find anything about using Google Docs to do it. But Google Spreadsheet is obviously a better choice. It has built-in revision tracking. You can edit it simultaneously with someone else. You can access live data in XML either publicly (like we did) or privately via their authentication API. It’s absolutely worth the half-day of your time it will take to add Google Spreadsheet-based tweaking to your game – even if it’s a non-Flash game, downloading and parsing XML is pretty easy with the right libraries.

I strongly suspect this feature will find its way into the next beta of the PushButton Engine. Which, by the way, you should sign up for if you are interested in developing Flash games. We’re bringing people in from the signup form starting this week. If you want more information, or just like looking at cool websites, click below to check out the new version of the PBEngine site, which has a bunch of information on the tech. Tim did an awesome job on the site design.

betashot

Edit: Patrick over on the GG forums asked about the proxy script. It’s actually ludicrously simple. Not very secure either so I wouldn’t recommend deploying it on a public server. I got my script from a post on Aden Forshaw’s blog. In the real world you would want to have some security token to limit access to your proxy script… but since this is for tweaking a game that is in development I didn’t sweat it.

Author: Ben Garney

See https://bengarney.com/ and @bengarney for details.

29 thoughts on “Tweaking your game with Google Spreadsheets”

  1. What we will probably do is just store a dump of the RSS data in the game and have the tweaker apply it right away rather than fetching it from outside. We could also go in and hand-apply all the values, but I'm only doing that if I absolutely have to. πŸ™‚

  2. A bit late for a reply but I was wondering about your release strategy with this XML thing. Do you plan using the google feed on the released version of your game or do you plan on packaging the xml file with the game? Or integrating the final tweaks into an internal structure in the .swf?

  3. It was just editing what was in the game. The issue was that it was a little cryptic, and too tied to the internal structures of the game. So the designer was faced with this deep tree of weird fields. The Google approach is way better because data is laid out sensibly, and most designers are good with spreadsheets already. Plus you get the whole cloud/collaborative thing.

  4. well it's certainly easier not to build the UI in the first place… I'm really more interested in the proof of concept rather than the actual use I guess πŸ™‚ Especially since we don't have designers…When you were using the custom UI was it in fact hooked up to the Google Spreadsheet, or was it just editing local data?

  5. Actually, that's a really good point. For our designers, the Google Spreadsheet UI is actually easier to work with than the custom UI we built originally. So I think that wrapping it would actually hurt productivity (at least for us). If your designers find Google Spreadsheet intimidating, then a custom UI might be worth it.

  6. so next step… a UI layer that lets you tweak the parameters for Grunts, editing the data in your spreadsheet at the same time. Doesn't seem like their API allows it unfortunately, although I haven't dug that much.

  7. It only takes a little bit of time to make an awesome Flash game… So give it a try! ;)Seriously, though, Google Spreadsheets is awesome. We use it and the rest of docs daily.

  8. Heheh – it's amazing how much can go into even a simple game! It's really cool seeing how it comes together now that all the pieces are there to make it fun.

  9. Nice idea. I just hacked together a similar deal using TinyXML and Libcurl. Took about an hour, mostly trying to get libcurl to link properly under VS2008.

  10. Hey Ben, thanks for pointing out an excellent use for Google Spreadsheets. I'm not sure how I missed that one. :o)And congrats on getting the PushButton Engine to the public beta stage. If I had more time that's certainly something I'd like to check out.

  11. Wow. Very clever usage: “It has built-in revision tracking. You can edit it simultaneously with someone else. You can access live data in XML either publicly (like we did) or privately via their authentication API.” That is just awesome.Btw, 200kb worth of tweaks for Grunts? Good lord! I'm really getting hyped now

  12. This is a great use of Google Spreadsheets. I've been looking at this for my job at ISU with some of the data that we work with on the lab team. Very cool work!

  13. Oh, cool. JSON is good – and that's a really neat example of what you can do with it.I do wish there was a way to access the API directly from Flash (ie a valid crossdomain.xml), even if it required an API key… That would save some trouble.But Spreadsheets still rocks. πŸ™‚

  14. I like the spreadsheet approach, especially after seeing it used quite sensibly in Startopia. Taking it to the next level with Google Spreadsheets is nothing short of amazing!

Comments are closed.

%d bloggers like this: