Pages

Monday, June 30, 2008

Spore

Following this post at Ned Batchelder blog, I've been playing with Spore Creature Creator, the new game by Will Wright, which apart from Sid Meier, is my favorite game desginer (actually, those are the only two game designers I know by name).
I won't write about the game itself, it suffice to say that from the computer science point of view, it's already marvelous, and from the biology point of view, it could be better. I would like to write a bit about how creatures are saved.
It turns out that spore saves its creators in plain .png files. Here's an example (WayneRTron):

If you open those file with any regular image viewer, you'll just see a picture of the creature. However, if you drag those images into Spore Creature Creator, the 3d model of the creature would open up.
It is still a mystery how Spore is able to do that. One thing is almost sure - the creature model is coded in the LSBs of each pixel in the image. You can see it by taking only those pictures which are fully transparent (the white background around the creature above). You'll notice then that only the LSBs of those pixels are changing. This shows that indeed something is hiding in the LSBs (why would they otherwise change if the pixels are transparent?), and that there's nothing coded in the other bits.
Not convinced yet? Take a look at the following picture.Don't worry if you don't see anything. I promise you there is indeed a picture in the center of the blank lines above (try right clicking around). The deal is that all of its pixels are either fully transparent or almost fully transparent, and if the contrast of your screen is not set to an high level, you won't see a thing. Try to save the image and load it to Spore, and lo and behold, you would see a simple green worm like creature. If you would look at the pixels composing the image, you would notice that only the LSBs are changing.

Reading the LSBs (if you haven't gone to Ned's post, do so now, to get a python script to read those pesky bits), you'll see no pattern at all. It seems that Spore's creators have either encrypted the creature's model, or compressed it. Moreover, saving again the same creature would create a different set of values for the LSBs, though the only thing that changes in the creature's model is probably a timestamp.

So we can't (yet) read the creature's model from its .png file. Can we at least change the LSBs of one creature to another's LSBs? Can we take an innocent png file and load into it a very vulgar creature (like this one, be warned), and publish it in Sporepedia? Apparently the answer is no. Such a chimera fails to load in Spore. Apparently the creature model encodes a checksum of some sort for the whole picture. I'm hopeful that this limitation could be overcome in the near future. In my next post I'll write a bit about how can one do research in this area. (A spoiler - don't upload your creatures to Sporepedia using your main email address).

4 comments:

  1. I'm not sure what an "LSB" is, but they've said the way they're putting the creature information into the images is via containers in the PNG file.
    A similar example is the way JPG files can store EXIF data.
    PNG containers are structured in such a way as to allow programs to read the data that is relevant to them and ignore any data that isn't.
    I don't know if there's a PNG container viewing program about, but that may give you a place to start if you're interested. :)

    - Mythor
    sporedaily.com

    ReplyDelete
  2. Hey Mythor,
    LSB is the least significant bit, which in our case means the bit that changing it would cause the least noticeable change in colors.
    As for PNG containers, this would be the obvious place to save the creature's data. Alas, Maxis chose not to do so, and there isn't any specially created container in the files.

    ReplyDelete
  3. I read somewhere that this has already been figured out. There is a python script that will extract or embed the model data in a png. It's xml once you descramble it.

    ReplyDelete
  4. Yes, I should have updated the post. I found it too (and as far as I know, responsible to making it more publicized), and wrote a short description of the encoding mechanism here

    ReplyDelete