Category Archives: lirec

Isometric engineering

The first report from south western Sweden where I am on unofficial residency/hacking retreat in the environs of the Tjärnö Marine Research Laboratory.

This is a great place for my main task, to focus on Germination X, and I’m starting with new isometric ground tiles. I’m aiming for the feeling of roots and interconnectedness with just a whiff of geological process.

Germination X is about thinking by sketching, and this started with a couple of rough drawings playing with different pathways across squares. If the connection points are kept consistent they fit together to build cubes, and automatically, the cubes joined together too.

I also thought that varying the widths of the paths would be more interesting, and built a kind of template from the master Germination X cube.

If I kept to these guidelines the plan should work – but I wasn’t sure how it the end effect would actually look. Using the template (visible underneath the paper, still in analogue mode) I drew five different variations of these pathway cubes.

After a bit of fixing and colouring in the gimp, this is an example chunk of world rendered in the Germination X 2D engine. Although the lining up is still not perfect, I like the roughness. Any combination of cubes will fit, you can swap any one for any other without breaking the pattern. The only tricky bit is that the random number generator is seeded from the position of the cubes, so the same pattern is generated consistently for any part of the world without having to store anything.

Colourful emotions

We’re currently putting the new plant spirit characters in Germination X and thinking more about how to use colour changes as part of the expression of the many emotions the FAtiMA agents contain.

I made this chart quickly, deliberately avoiding thinking about potential reasons for my choices. Interestingly I found I needed to start with the motion curves first (which describe how the colours are blended between over time) and these seemed much less arbitrary than the actual colours I chose. The reason could be that there is a closer connection between movement (however simple) and gestural expressions.

GX companion planting diagnosis

Finally the spirits in Germination X can provide some kind of help by diagnosing what is wrong with your plants if they get ill, and sending you a hint via a small message. They also look for other players who can plant seeds and ask them to help you. All the actions being driven by the FAtiMA modular AI system.

Visually we’ve also been experimenting with increasing the size of everything and allowing you to look around the world by dragging (which is quite jumpy at the moment). I still need to update the graphics to this higher resolution and fix the jumpiness, but I think it could be a better way of exploring the larger world than the separate “tiles” approach we have now.

Messages from plants and plant spirits

In Germination X plants can now send messages to the players that planted them – and these are stored individually for each player as well as globally so you can see what other people are up to. Plant spirits can also send you messages when they see something happening that interests them (such as a plant of their permaculture layer getting ill).

The messages are obviously more debug text than anything helpful at the moment – but they will be expanded.

We’ve been talking about making a kind of transition from the players thinking of the plants as being their property to the reverse situation. Playing with these messages might give us a way to make this possible.

Un-lazy-fying clojure

I’m finding Clojure has a similar feel to C++ about it – it requires a higher degree of understanding of the underlying implementation than I think is probably optimal. Partly this could be because it’s a new language – but it’s also what makes it interesting.

A common problem I’m having is running out of Java stack due to lazy structures – this is a problem in a game or simulation loop such as Germination X, where if the values are not used by something they are never evaluated (which saves cycles) and hang around (using up memory).

Luckily Clojure comes with (doall) which forces the evaluation of a lazy sequence – however it’s not recursive and *only* works on sequences. This function is recursive, and also calls itself on all the values contained in hash-maps:

; force all sequences and maps to un-lazy
(defn doall-recur [s]
  (cond
   (map? s) (reduce
             (fn [r i]
               (merge {(first i)
                       (doall-recur (second i))} r))
             {} s)
   (seq? s) (doall
             (map doall-recur
                  s))
   :else s))

Game designin’ (GX)

Before I can make full use of the characters in Germination X, I need to think about the game itself, the social aspects – and how this interacts with the theme of companion planting.

This could be a very rich area to play around with, but it needs to start as simple as possible. I’m lucky in that I can make a lot of use of the research we covered as part of the Naked on Pluto project, and as ever, I have to start with plenty of drawings.

The design is focused on three main priorities:

  • Getting people working together (co-operative play).
  • Do this in a world organised by companion planting.
  • Integrate the world with the FAtiMA AI system, and make use of the notions of social awareness encoded within it

I’m also trying one well used casual game mechanic – a time based restriction, where some “energy” or “karma” is used up by actions (planting), and then slowly recharged. This is required in order to make cooperation necessary – people will be able to request help from other players who have more energy/karma and may choose to plant beneficial companion plants near to their ill plants. This could perhaps be rewarded by being given a larger reserve of planting energy if you do this.

I’m particularly interested in the interaction of these game mechanics, and finding some sort of minimum to achieve engagement. For example I’m quite against explicitly punishing “bad behavior” (in this case planting harmful plants near other player’s plants) and seeing how this might be explored by players in practice.

“Emotional colours” in Germination X

Most of the work on Germination X over the last two weeks has been upgrading FAtiMA to the new modular version developed for Lirec. This uses a little more memory than the previous version, so I’m only running one spirit in the game at the moment. I’ve also made a fix for Internet Explorer which wasn’t working properly with the game.

Over the last few days I’ve had some time to try using some of the non-facial emotional cues I talked about previously – specifically the use of colour. In the screenshot above the character is emitting coloured particles based on it’s predominant emotion (in this case Joy). One of the areas I want to focus on over the next couple of months is how to express emotions with these simple characters in ways that may be quite abstract.

Reading/writing clojure

Revisiting my clojure frustrations, I was having problems getting things saved out to be recreated properly when loaded back in. This is something you take for granted perhaps, as a scheme programmer – but by restricting the set of containers I use, I’ve managed to get the right behavior from clojure.

user=> (def a (hash-map :number 43 :list () :string "hello"))
#'user/a
user=> (spit "test.txt" a)
nil
user=> (slurp "test.txt")
"{:string \"hello\", :list (), :number 43}"
user=> (read-string (slurp "test.txt"))
{:string "hello", :list (), :number 43}
user=> (:number (read-string (slurp "test.txt")))
43

As originally suggested by Sam – if I save a hash-map, I get one back when I parse the text – same for lists or normal data. This isn’t the case for struct-maps or records which I tried before. I can also do versioning with hash-maps, where one of the fields is the version number, and structures can change without breaking file compatibility. When you load an old version, you can automatically detect this and convert it on the fly by adding default values for new data, or removing old stuff.

This is essential for production work, especially with an online game – as you need to keep file formats and data structures flexible while doing the upgrades in an quick automated way to match the code which is running.

Here is a section of the Naked on Pluto code (in scheme, but the process will be similar in clojure for Germination X) it gives you an idea of the kind of changes we made throughout the development process:

(let* ((f (open-input-file filename))
         (l (read f)) ; read the file
         (v (car l)) ; first item is the version
         (g (cadr l))) ; second item is the graph
    ; the version allows us to preprocess the graph to fix
    ; things which have changed. do this here.
    (let ((g (if (< v 1) (add-vocab-to-nodes g) g)))
      (let ((g (if (< v 2) (add-message-types g) g)))
        (let ((g (if (< v 3) (add-bot-timers g) g)))
          (let ((g (if (< v 4) (add-old-messages-to-nodes g) g)))
            (let ((g (if (< v 5) (remove-dir-from-edges g) g)))
              (let ((g (if (< v 6) (add-hatface g) g)))
                (let ((g (if (< v 7) (add-votes g) g)))
                    ; g is now up to date, whatever the version was we loaded
                  ))))))))