GX: Player statistics-o-rama

Some stats on Germination X player activity since November:

Total num players: 310
Time spent playing total: 181.80 hours
Average player return duration: 9 days
Players who returned for periods longer than 30 days: 21 players
Average num sessions per player: 2.47 sessions
Average num fruit/seed picked per player: 12.53 fruit
Average num plants planted per player: 12.31 plants
Average session length per player: 16.09 minutes
Median session length: 3.82 minutes
Average plantings per session for all players: 8.73 plants

These sorts of player behaviour stats can be an important part of developing online games, as they provide a way to get feedback on changes you make to the game. In that vein – here are some statistics before and after a couple of big changes to attempt to see how they changed the experience, based on the average number of plants planted per session by all players:

Tutorial feature:
Average plants per session – before: 6.47 after: 12.23

Player avatar feature:
Average plants per session – before: 8.23 after: 11.20

I think it’s possible to take these kinds of stats too seriously (especially in small sample sizes as here) but in combination with focus study feedback you can start to build up a useful picture that can be used to influence decisions.

Drawing plant spirits in Brussels

Some pictures from the Germination X plant spirit drawing workshop, part of FoAM‘s contribution to Open House Brussels, a public invitation for people to visit the artistic groups and labs in the city.

The plant spirit drawing system has improved a bit from last year’s workshop at Pixelache Helsinki, being able to upload to the public server. It was great to see these spirits in the latest version (some of them are still frolicking in the game at the moment).

Germination X: Player characters

After another code sprint on Germination X, I’ve added player characters (avatars) to the game. Based on the falmouth focus group feedback this seemed one of the major things missing that players felt would improve the game.

The character design came from the Mandrake plant, which has been cropping up in groworld projects for some time – as a magical plant known to resemble human forms as it grows.

This change also allowed a much needed clean up and decluttering of the user interface for the game – as navigation now happens by moving your mandrake around by clicking on things. Your location is persistent, so when you log in you go back to the same place. All existing players in the game have been given mandrakes scattered around the world.

As the mandrakes represented a new type of entity in the world, able to move around, and linked to players – this was quite a lot of work, particularly in terms of updating the existing database. I had a lot of trouble doing this manually with MongoDB’s save command in the script interface. This seemed to be creating duplicate records (and creating very hard to track down bugs) that took a long time to find. The better approach seems to be to upgrade the database automatically in the game code, by checking a stored version number – and mapping over entries like this:

;; map over each player in the db
 (fn [player]
   (println "upgrading" (:name player) "to include tile and avatar")     
   ;; get a random tile in the world
   (let [tile (first (db-get-random-one :tiles {}))]
     (db-update! ;; update it, adding an avatar
      :tiles tile
      (merge tile {:entities
                   (cons (make-avatar
                          (:id player)
                          (:name player)
                          (make-vec2      ;; random position
                           (rand-int 5)   ;; in the tile
                           (rand-int 5))
                          (:layer player) ;; show the player's score on the avatar
                          (count (:flowered-plants player)))
                         (:entities tile))}))
     ;; add the tile location to the player
     ;; so we can find the avatar again
     (merge player {:tile (:pos tile)})))

This also means that the latest code will work with snapshots I’ve taken of the game world regardless of how old they are. This turns out to be really important – I can try some changes and rewind the whole world back to the same starting point, as well as testing code locally on a copy of the current public world version.

Germination X graph of solutions

Last week I posted the big graph of problems based on feedback from the Falmouth Loading Bar focus test. I went through each area building up a list of possible solutions – the general idea being to find solutions that might solve more than one problem at a time.

I now have quite a reasonable todo list for another code sprint. Hopefully there will be some new things implemented, based on this – we will see how it goes.

Here is an image of a mass of feedback post-its neatly arranged into lines:

Germination X graph of problems

During the Germination X focus test I asked the participants a set of questions in 4 areas based on work we had done at SICS mobile life in Stockholm. This was useful as although there was a lot of information (and a load more free form feedback after the questions) – at least there was a structure to help understand it later.

Despite the glowing words of the post-event review, the important thing is to look at all of the criticisms from the post-it notes to create an depressing “graph of badness” – in order to pinpoint the areas needing urgent attention.

The game world

The main problems with the general game world seem to be a lack of distinction between the different elements – telling the fruit/seeds apart from the plants, how did the plant spirits relate to things. One tester found it very difficult to get plants to react to what they were doing, and therefore got very frustrated.

The Plant Spirits

Perhaps the most unusual, and certainly the most challenging aspect of the game, the plant spirits caused a lot of negative feedback. Some testers felt that they were random, and even aimless – zooming around and popping in and out of existence from player to player. The FAtiMA fixes had also caused them to over react to so many people playing at once – so they were moving too fast for people to even read their messages.

Even when they were understood, a well meaning but disastrous last minute ‘tweak’ made them ask people to help other players by planting plants they couldn’t pick yet, which lead people to think they were taunting them!

This prevented most players from interpreting any useful meanings from their actions (a lot ignoring them). It was only later when people went back to playing in a less intensive way (which I was pleased that a lot did over the following days) that they were reacting more normally.

Other players

The main problems flagged up when asked about their relationship with other players was the lack of a visible physical presence – no avatars. Other player’s actions were noticed quite strongly, but only indirectly – and not entirely helpfully. The lack of a map or overall view came up here too. Although the gifting mechanic was added to the tutorial only a couple of players tried it out, the others either didn’t notice it or forgot to try it.


The problems of ownership were related mainly to the problems with the game world, differentiation between elements – also some players didn’t notice the “glow” around their plants (which isn’t in the tutorial). More interestingly, some players found that being restricted to a single action – “planting” with no follow up meant they didn’t care as much about their plants as they could.

Predictably perhaps, this was also an area with a noticeable differences between the gamers and non-gamers, the ones more used to gaming felt their role was to “create the best garden” while the others tended to feel that they should be “helping each other to create a balanced world”.

The next Germination X post will be about solutions to some of these problems!

Fast HTML5 sprite rendering

After quite a lot of experimentation with HTML5 canvas, I’ve figured out a way to use it with the kind of big isometric game worlds used for Germination X which are built from hundreds of overlapping sprites. There are lots of good resources out there on low level optimisations, but I needed to rethink my general approach in order to get some of these working.

It was quite obvious from the start that the simple clear screen & redraw everything way was going to be far too slow. Luckily HTML5 canvas gives us quite a lot of options for building less naive strategies.

A debug view of the game with 10 frames of changes shown with two plant spirits and one butterfly moving around.

The secret is only drawing the changes for each frame (called partial re-rendering in the link above). To do this we can calculate sprites which have changed and the ones they overlap with. The complication is maintaining the draw order and using clipping to keep the depth correct without needing to redraw everything else too.

In the game update we need to tag all the sprites which change position, rotation, scale, bitmap image, transparency etc.

Then in the render loop we build a list of all sprites that need redrawing, along with a list of bounding boxes for each overlapping sprite of the changed sprites that touch them. There may be more than one bounding box as a single sprite may need to be redrawn for multiple other changed sprites.

For each changed sprite:
    Get the bounding box for the changed sprite
    For each sprite which overlaps with this bounding box: 
        If overlapping sprite has already been stored:
            Add the bounding box to overlapping sprite's list 
            Store overlapping sprite and current bounding box.
    Add the changed sprite to the list.

Assuming the sprites have been sorted into depth order, we now draw them using the list we have made (we would only need to loop over the redraw list if we built it in depth sorted order).

For each sprite:
    If it's in the redraw list:
        If it's not one of the originally changed sprites:
            Set a clipping rect for each bounding box.
        Draw the sprite.
        Turn off the clipping, if it was used.

With complex scenes and multiple moving objects, this algorithm means we only need to redraw a small percentage of the total sprites visible – and we start to approach Flash in terms of performance for games (I suspect that flash is doing something similar to this under the hood). The code is here, currently written in HaXE, but will probably end up being ported to Javascript.

Germination X: More on platform independence

More detail on yesterday’s HTML5 canvas version of Germination X. The game engine it uses (known in the source code as “truffle”) is carved up into several layers in order to allow it to make use of HaXe’s cross platform abilities. This is exactly the same concept as used with console games – you set up some standard interfaces to be used from the game code, and implement them for each target at the lower level. The main thing it to make sure you continually build and test both versions.

Here’s a diagram with rounded corners:

There are a few things in the game code I needed to go directly to flash for, one was the glow effect on the plants owned by the player – using a filter. The other was doing an image pixel colour lookup to get the emotional colours for the spirits – both of these are switched off in the canvas version, to be fixed later.

One of the things I’m most impressed by is the ability to send a HaXE closure to Javascript code, store and run it from there (for example on those pesky mouse events on sprites). Of course this works as it’s all Javascript in the end, it’s just one of those cool things that takes you by surprise.

Germination X in HTML5 canvas

I’ve spent a couple of days on an experimental not-quite-working-yet port of Germination X to HTML5. Port is probably a slightly misleading word, as it’s actually running exactly the same HaXE code, it’s just compiled to Javascript rather than swf with a load of extra Javascript filling in the stuff needed to replace Flash. The game engine that Germination X is built on is now officially cross platform! It’s great to finally have a non-proprietary browser option for the game, and HTML5 is much faster now than when I first tried it, but it’s still got a long way to go. Problems I’ve noticed so far:

It’s still slow. I’m aware of the limitations and background to browser tech, but it’s depressing that it’s somehow problematic drawing a few hundreds of sprites in 2012 while my ancient Gameboy DS can manage quite fine thankyouverymuch 🙂

Tinting images is quite a basic thing to do in order to efficiently use images and save bandwidth and memory. Why do I have to loop through pixels in javascript to do this? This is the main cause of slowness in the HTML5 version of the game ATM, hopefully a simple bitmap cache will fix this. There are also some neat ways to do it with offscreen bitmaps and blendmode tricks, but they seem even slower.

Having to write your own mouse event detection for sprite down/up/over/out. I guess this is one of the biggest reasons for the explosion of HTML5 game engines. It’s quite non-trivial and un-fun to set up properly. Actually getting the real mouse coordinates is also quite hard to do.

On the plus side, it’s a breath of fresh air to get back the control of immediate mode – it seems historically that this tends to be the optimal approach, give us the render loop!

Now you’ve got this far – here is some accidental art which happened this morning, and which I’m particularly proud of: