Tag! You’re it!

Sirentist told you about the user’s side of “tagging” in her last post, and now I’d like to add something about the technology behind this “tagging” thing and why we chose that way. At the end of this post you’ll probably be able to tell what the (boring) technical reason to call it “tagging” was, but I like Sirentist’s idea way better!

Before anyone was able to yell “Tag! You’re it!” several things had to happen. And before we even had the idea to solve our problem this way, we tried something else (and failed) … but let me start at the beginning.

TinySpeck released most of the Glitch source code (client and server) under a CC license.1 The important word here is “most” — they did not release everything, especially not all the data we would need to get back Ur the way it was before the world ended. There’s a lot to say about the things we do or don’t have; Aroha has already told you about it and I bet there will be more posts on the subject. However, today I wanted to tell you about some of the things we had to do to get Ur back to the state it was.

As Sirentist said, everything in Ur had its own TSID, which is the unique key or ID of every item, every street, every player and so on. For each of those TSIDs, there was an XML-file that contained all the information related to that object. Among the assets TinySpeck released were the XML-files for (nearly) all locations (streets). Each of those XML-files contains information like the label, the TSID, references to that street’s geometry files, a list of players currently in that street, and so on. In addition, every location had a list of items contained in that street. An entry might look like this:

<objrefs id=”items”>
<objref tsid=”IA5HOD6RUSF3922″ label=”Fruit Tree”/>
<objref tsid=”IA5C9TB8OTS2N5S” label=”Shrine to Zille”/>
<objref tsid=”IA5CH4UBOTS2TL5″ label=”Street Spirit”/>
<objref tsid=”IA23I4QA23T2L15″ label=”Quoin”/>
</objrefs>

As you can see, the XML-file for a location contains only the TSIDs and the labels of the items. So not only are we missing the position of the item in the street, but we’re also missing all detailed information about the items. Things like what kind of Street Spirit? What did it look like? What type of quoin? When was the last time that Fruit Tree was watered? How many harvests are left? I think you get the idea.

Getting this level of detail was one part of the problem. We needed some of those values to initialize the items in the street. That part can (mostly) be done automatically. We could create the items in-game and use the result as a template for our new items. So far, so good. But how do we get the original positions of the items in the street back?

Idea #1: There has to be a way to do this automatically

Well, I’m sure there is, but it wasn’t as easy as it first seemed. The idea was to have screenshots of all streets in Ur and then use those to automatically find the position of, let’s say a Fruit Tree, in a street. Thanks to Mackenzie2, we had a complete and perfectly organized collection of full street snaps. We used python and the initial results looked really promising:

snap

Find The Fruit Tree!

It looked like 90% of the job was already done. However, as is typical, the remaining 10% turned out to be a problem. We soon ran into several complications:

  • There is not one Fruit Tree; Fruit Trees exist in 60 (again in words: sixty!) different states.
    Fruit Tree

    Fruit Tree

    While this is not a showstopper, it would have made our progress significantly slower. We would have had to check for all 60 versions every time. Besides that, it would have led to a lot of false positives.

  • In some cases the items are really difficult to find with the algorithms we tried, like this dirt pile here:

    Dirt Pile

    Brown Dirt Pile on brown background

  • The XML-files that we have for the locations are from an arbitrary point in time, pretty close to the end of the world. Let’s call it foo. The screenshots we have of those streets, meanwhile, are from a different arbitrary point in time. Let’s call it bar. Now between foo and bar (or bar and foo, for that matter) the world changed. People poisoned trees, for example, and what once was a Fruit Tree (on the snap) became a Bean Tree (in the XML-files). Or the other way around. Or nothing was replanted and there was only a patch left. Or, or, or. In other words, many streets had XML-files and screenshots that didn’t perfectly match.

Altogether, these reasons made us give up on this approach and try something else…

Idea #2: Tag! You’re it!

So instead, we needed a “semi-automatic” way to solve this problem. In the end, a human being would have to decide what item to place where, but we could at least try to make that process as simple and fast as possible. After all, we’re talking about more than 21000 items on about 1300 streets.

Using the above-mentioned snapshots of the streets, we set up the first version of the “tagging server.” A small python web server and some magic jQuery libraries (similar to those used on some photo tagging sites) are the core components. We know what items are expected on a given street from the XML, and those need to get converted to our target format (JSON). With that info, we generate the colored list of items you saw on Sirentist’s screenshots. That list is updated on the fly so the tagger always sees the current state, without having to reload the page every single time. For every tagged item, we get a JSON with x- and y-coordinates, width and height of the drawn box and the TSIDs of the street and the original item. Then we use the geometry file of the location to map these pieces of information to a position in the street. Finally we use the label to create a new instance of the item class of that TSID (like our Fruit Tree). Repeat that about 21000 times and you get all items back into Ur.

Remember? This is where we went before we had the Spice Route

Remember? This is where we went before we had the Spice Route

When we started to work on this, I thought it would take a long time to tag all those items, but I was definitely wrong. With the help of some very enthusiastic members of Project Eleven it was a matter of weeks, and not months, like I had expected, and it was done. Of course, this is only one of many steps to get Ur back the way it was. But it does feel good to walk through the streets again and see all the trees and quoins and dirt piles and peat bogs and some of the old inhabitants!

 

 

1 I would like to thank everyone at TinySpeck again. Without the sources, without the instance of Slack we have or without all the help current and former TinySpeckers have given us, we would be nowhere near where we are now.

2 Special thanks to Mackenzie (Jade)! Her knowledge and experience have been invaluable for us!

3 thoughts on “Tag! You’re it!”

  1. I’m so impressed by everyone’s hard work at putting this together and their dedication; my excitement to be back in the world of Glitch someday is tangible!

Leave a Reply