Wednesday, 10 September 2014

Two Types of Unity

Unity. Unity. Unity...

Seems ironic that I've been thinking about Unity so much recently without actually giving much thought to the unity of the country, currently threatened by the incompetence of naive wasters in Westminster who gave the Scottish independence movement enough advantages to turn what should have been a straightforward referendum producing a resolute 'NO' into a full blown political crisis lest they decide 'YES'.

Not that I'm unsympathetic to the nationalist cause. It's hard to argue in favour of the status quo when the status quo is as unfashionable as the real Status Quo. I understand why some people's wish to break the Union. Living here in the north of England is (arguably) worse than living in Scotland. It sometimes feels like we're sitting in the middle ground, as political debate flies over our heads. Westminster does actually listen to Scotland whilst ignoring the rest of the country.

Yet clearly something does need to be done to change a situation in which, for example, arts funding for London is £21.90 per head, whilst here in the North West, our arts are funded to the value of £5.06 per head (2012/13 figures). I've joked in the past about Sky News and their paper reviews but, when so many in the media talk about representation, nobody seems to notice how the news agenda is often directed (and commented upon) by small coteries of people who all sound the same. Simply too much of our national identity is tied into a London identity. Being British is too often seen as being a Londoner, in the same way, I suppose, those of us who live close to the Mersey are assumed to be Scouse, instead of being part of the surrounding areas, such as Lancashire, Cheshire, Manchester, or even Wales.

I should imagine that many of us have some Scottish blood. My own grandmother was Scottish. Yet even if there isn't a blood tie, Scotland has given us so much of what we should collectively feel proud. It's hard to pick apart our country without cutting deep into ancestral flesh. Many of my favourite writers are Scottish, so I suppose my thought processes are deeply influenced by that culture. Are we suddenly meant to feel less proud of Andy Murray or Sean Connery because they're suddenly from foreign soil? None of this makes sense. We're being led into an unnecessary quagmire by people making decisions that might last centuries based on fads, cults of personality, and acts of sheer bloody-mindedness.

I genuinely think it will be disastrous for Scotland to vote yes but it's especially sad to see people voting for their own ruin simply because Alex Salmond has managed to turn this debate into a chance to give Tories a bloody nose. It seems as dumb (or perhaps even as profound) as the reason one guy gave for voting 'no' on Newsnight  last night, which was he didn't want to lose 'Match of the Day'.

Simply put, so much of our identity is tied up with the Union that I hate to think of this country divided after centuries of productive harmony. There'll be no more chances to wave the 'red, white, and blue' once we've stripped the blue from our flags.




Meanwhile, Unity in PC land still means that I'm teaching myself more C#.

About a week ago, I thought it would be a cheerful thing to quickly create a simple game I could play with a friend. It started out as a joke, a minor distraction from my procedural city project which had been exhausting me. Last week was also dominated by long days travelling with my sister so she could see consultants, so I wasn't going to get much concentrated time at my PC.

Now that simple game is almost finished, I've run up against a huge problem.

I wrote the game because I wanted to do something involving multiplayer, which means I had to learn how to get machines talking to each other over the network. That's relatively easy to do in Unity and it took only an hour before my PC was moving objects around on my Android tablet via Wi-Fi.

Without going into too much detail, the game is a very simple game not entirely unlike snooker, moving objects using Unity's physics engine. It looked pretty good until I noticed that the game's progress being played out on one machine gradually began to look quite different to the game's state as seen on the other machine.

It was then that I began to understand the non-deterministic nature of modern computers.

It's probably dumb of me not to realise this earlier but I've never done network coding before. I would assume (not so much naively but idealistically) that one set of input fed into code running on one machine would produce exactly the same result as the same input fed into the very same come running on a different machine. Common sense dictates that it would be true. 1 plus 1 always equals 2...

Except, that isn't always entirely true.

One of the bigger bugs I struggled with a few months ago (unrelated to networks but simple maths) involved a problem I saw with floating point numbers. Some numbers were getting calculated wrong for no obvious reason.

The reason had to do with floating point errors. Some numbers are impossible to accurately store insider a computer's memory. Numbers which have extremely long (or sometimes infinitely long) mantissa (the fractional part after the decimal point) cannot be stored given the finite number of bits available. Irrational numbers, for example, can't even be stored as a ratio. The value of Pi is often written as 22/7 but that's an approximation, and it's certainly impossible to write the entire value since it (probably) goes on forever. One of my favourite parts of science fiction occurs in Carl Sagan's novel, Contact, where Pi is calculated to such a length that they reach a point where our original creators had hidden a message.

But I digress.

Because floating maths require some degree of approximation, different processors (and, by extension, difference compilers that create the machine code ready by processors) have different ways of approximating those numbers.

Usually, we don't notice this but when a physics engine starts to do thousands of calculations, those small fluctuations begin to produce big differences. So, for example, the way my PC calculates the friction of an object moving across a surface might produce a different velocity than that calculated by my Android tablet's processor running the very same code. The values differ by very small amounts but it's enough to make large changes. I suppose it's the old simile of the butterfly flapping its wings in New York and producing a storm in Tokyo. My PC might show a ball rolling into a pocket whereas on the Android it just clips the edge and fails to roll in. Since the game is multiplayer and both players are meant to be playing the same game in the same virtual space, this causes big problems.

So, this is where I am today, with a nearly functioning game that I'll have to re-engineer to ensure that only one machine does the calculations whilst the other produces movements in all the game objects based on a hell of a load of numbers I'll have to send over the network.

I suppose, if I had time, I might explain how this is all an apt metaphor for the problems of devolution, nationalism, and our Westminster elite. However, I hope that my floating point errors will be much easier to fix.

No comments:

Post a Comment