Thursday, January 30, 2014

Investigating C1 climate (for a huge fail)



We all now C2 has an complex ecology model, where temperature,wind light, radiation and others such parameters dynamically shape the worlds face.

But did you know that basic ecology elements are also present in C1 to some extent?
Let's find out about those together.



So where did it all come from?
One of the very first times ever I opened the C1 genetics kit, I stumbled upon gene 139 called "Get sleepy in the dark"


This got me wondering.



Sure enough, the gene seems to inject sleepiness into the Norns when the "ambient" light level is low.

Well, I didn't know C1 had a light level system !
Browsing through the whole C1 Caos guide shows no sign of a "light level" parameter.
It shows that a wind and a temperature parameter exist though!

Norns also seem to be able to perceive external temperature via emitter genes

Feeling outside hotness should inject the Norn with the corresponding Hotness chemical.


That looks promising.
What about mapping the whole Albian room layout along with their attributes ( interior/exterior ) and wind and temperature levels ?

We can get the current games number of rooms by running :

dde: putv rms#

Which returns 29 in my world ( including a couple shelf cobs )

 The following CAOS command can then list all room parameters for us :
setv var1 rms#,loop,dde: putv room var1 0,dde: putv room var1 1,dde: putv room var1 2,dde: putv room var1 3,dde: putv room var1 4,subv var1 1,untl var1 lt 0

This outputs a long ugly chain in the form:

3368|840|3768|1285|3|2288|1565|2451|1860|0|2451|1747|2550|2030|0|7700|0|8352|150|3|7000|0|7700|150|3|6300|0|7000|150|3|5600|0|6300|150|3|4900|0|5600|150|0|6113|1664|0|7350|906|7670|1175|0|72
Where the values are in order of appearance: room left, room top, room right, room bottom, room type(0=indoors,1=surface,2=undersea).

I'll spare you details of implementation this time as it's not that interesting, but by using python and the "PIL" module, we can easily make sense of that data and map in on Albia:


Here blue rectangles are outdoor areas, while red ones are indoors.
You might have noticed that no "underwater" room shows up.Actually they do, but they have some strange boundaries expressed with negative numbers that the quick script can't handle.I decided it wasn't worth bothering as only two underwater rooms are defined anyway.
 
So ok, we now know which rooms are considered indoors and which ones are outdoors.Not that useful.
Yet it at least shows us that contrary to C2, in C1 the rooms are only sparsely covering the map, and are not interconnected with any common edges.Passing from one room to another is always done through a vehicle.
This explains why using the "edit" CAOS command in C1 to carry a Norn won't allow you to get it out of the current room ( as Norns have the "roombound" attribute set.In C2 most of the rooms share common edges through which stuff can pass.

But what about temperature and wind then?

If you read the C1 caos guide, you'll realise that although "temp" and "wind" commands do exist, they are not tied to rooms.
Actually, even in C2, those return "values around current Targ", meaning you can't get a temp value by room, but must pick a target inside the room and check the perceived temperature/wind levels there.(Which explains why in C2 the t° information in the status bar doesn't change when you move around, it represents temperature as perceived by your currently selected creature.)

What about C1 temperature/wind map ?
The quickest way to find out is to enumerate through all possible objects in the world and get temperature around them while they're current Targ:

enum 0 0 0,dde: putv temp,next


The result isn't really as expected :

0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|........

 What about wind ?


enum 0 0 0,dde: putv wind,next

1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1....

Hmmm...
Let's check that against C2 just to be sure our approach isn't flawed:

Temps:
36|69|69|119|66|66|69|68|119|95|36|61|69|47|40|81|36|44|121|69|66|116|78|57|93|93|62|66|36|69|6...

Wind:
6|-31|-31|-41|-7|-7|-31|13|-41|-18|6|-20|-31|26|6|-9|6|30|-52|-31|-7|-23|-25|-5|-26|-26...

So yeah, it seems that although present, both temperature and wind are unused in the original game.
That makes for a rather...anticlimactic conclusion for a climatology post.
(And I swear I didn't write the whole article for the sole purpose of this pun)

What more can we try to save from that failed experiment?
I still would like to understand whether those parameters are just present but unused or if they aren't even implemented.In the later case that would leave us an interesting opportunity to mod the simple C1 Albia to something more complete.

The way to check that is slightly more involved.
By digging inside the game executable code by itself with IDA, we can quickly locate the part where the CAOS interpreter operates:

This is how the actual C1 CAOS interpreter looks like mapped out in IDA. Each of the green/red branch is the interpreter handling individual CAOS commands, and the bunch of boxes aligned at the botom are the actual functions called by each CAOS keyword to produce the game actions.
I won't go in to much detail here, as raw and dirty reverse engineering might not be that interesting to most of my readers so far.( We will cover that in dedicated posts where this is more relevant)


Just as a quick example of what is found in there:


This is the place where the "temp" keyword is detected when parsing CAOS scripts
And this is the place where a value to be given "temp" is computed

If we have a peek at this function, we can see that there is some code actually running inside the "CAOSComputeTempVarValue" and supposed to give "temp" a value based on the passed target's coordinates.But in practice, it seems to handle "dead" unused data, and therefore always returns the same value.
This simply shows us that C1 already had some of the bases for the implementation of the C2 model, but that they weren't fully implemented in the released game (Nothing in there seems to feed the temperature/wind map).
This is a dead end for us, we won't be able to implement CAOS stuff that would "reactivate" the unused functions, as the mechanisms that should handle them backstage are inoperant (nothing in the game executable seems to set or manipulate the data those commands read out).

This....is a lie.

That having critically failed, what else can we check on the topic of understanding the environmental stuff?
Unfortunately in C1, the brain applet is pretty much useless and won't allow us to study the brain in an helpful way to determine if the "Creature->Sensimotor->Light level " "air is this hot/cold" environemental parameters actually trigger neurons at any given time inside the Norn.This isn't a big loss as we've shown that there's no variation in temperature or wind in the game anyway.

One last thing we could check though is the light system.
There's no light command defined in the C1 CAOS documentation.I also checked at the source inside the game executable, and although I've found a couple undocumented functions (nothing really groundbreakingly useful though) nothing light related.

So what does define the ambient light level supposed to make Norns sleepy (if the mechanism is used at all) ?
Maybe it's the indoors/outdoors qualification of each room that carries an inherent ambient light level acting upon our Norn's inputs?
We could check that.

The best we could do is to modify a test Norn's genome so light levels directly map to unused chemical level.By moving the Norn around we could then monitor the associated chemical for any changes.(drop me a note if you have any better/complimentary ideas!).

 Let's do this :

First we will add a new test chemical that will be easy to track.Don't forget to install the chemicals list.

...then add a new chemical emitter dedicated to this chemical.


Set a smplrate on the low side (often) so you have accurate readings.Set a high gain so you see any variations well.Set a low threshold.Don't forget to make the new chemical a quick decay one too otherwise it will permanently max out at the slightest stimulation.

I'm not showing you the corresponding graphs ingame as they appear slightly confusing and uninformative as illustrations, but once again, the short story is that the graph never changes the slightest bit even after moving the Norn around in every single room in Albia.
The conclusion is then that light levels also seem to be totally inactive in C1 despite being mentioned in the genetics kit.

My best guess is that all of this was unfinished work in progress that got released with the game, but was not yet in active use at the time.Since C1 and C2 seem to share a lot of common code, I'd say C2 is based directly on an improved version of the C1 engine, and those functionalities only came to full use after the second release( I'd be glad if anyone with "inside" information could confirm that btw.)

Sorry if you feel that I've wasted your time with a promising article title giving so few exploitable conclusions.But that is how exploration is.Sometimes you find cool stuff to share, sometimes not.Anyway, all of this contributes to its small extent to our overall comprehension of the game series.

I promise the next posts will contain much more interesting and readily exploitable information :)

2 comments:

  1. Despite not finding anything useful to exploit, I certainly found this post extremely interesting.

    As a point of interest, the original lore in C1 (and C2 I believe) said Albia was a disk shaped world, which was meant to account for why the sunlight never varied. It's rather amusing that, based on the code, that wasn't meant to be true. I guess they must have shoe-horned the lore in there to cover for the short deadline and coding they didn't manage to complete.

    ReplyDelete
  2. Thanks for the comment :)

    You make an interesting point.
    I had only considered that the "disc world" part was meant to describe the way the world wrapped around after scrolling for some time.

    The game was an ambitious project, and yes, looking at its internals shows that many things were accounted for early, but weren't ready for C1 release.
    Most of them show up in C2 though.

    ReplyDelete