Friday, 21 November 2014

Story Time - Programmers Sleeping

Once upon a time I was a loud mouthed, big headed, my code could never be wrong, I'm invincible... 

Kind of programmer...

Over time you will, unless you never go out, you will meet programmers who know more things about you, either about everything, or about certain specific things, and you have to learn to evolve and understand they just know more than you.

They might have been through the problem you're wrestling with for the first time, they might have worked on the base system, or they might just recognise the pattern of the problem you've got.

So don't just dismiss these folks, they know what they're talking about, and even if they don't take it, analyse where they've gone wrong and you learn from it, do not do what happened to me...

We're about six years ago now, and we had a graphical system, this system had been running games from many different sources for several years (about four) so it was a tried system, the hardware was known, it had known bounds and I personally had handled maybe a dozen different people working on it before, their games all worked, and I turn around and can see 32+ games working still to this day.

One thing I don't see right now however is this game from this one guy, because... He's a douche, and I don't actually see him because he no longer works here, of all the folks in his department he was the first gone of his own accord, because... well because he was one of those programmers, one of those people who never really grew up, he considered himself above reproach, he was perfect, his code was perfect and any issues were yours.

So, let us just dive off to games, games at their heart have a loop, which reads/updates the data, plays sound and critically updates the graphics, that's the core of all games from Battle Chess to Call of Duty, this game loop is time critical, if you delay the update or the display the game will look like it's stuck, or juddering, people often call this lagging, but the problem is that loop for interrupted to things didn't look smooth or play smooth.

But computers are fast! So for most trivial problems the data can be updated and the display redrawn faster than the hardware is actually limited to, so the hardware is done and sat idle waiting for the next rendering of the game.

This is called the sleep or delay, and games use this time to do other things, like perhaps check for updates or sort data.

Now this delay has to be controlled, you have to make it a fixed length, or set it up so that the machine works out how long the work it did was since it last drew the screen, and wait for the difference in time to smooth out the drawing.  This makes the game play smoothly, makes animation behave smoothly...

So, if you have a loop and you just randomly sleep for X time, but then the data processing you're doing takes longer than X the game will look like it's stuttering.... How can this happen?...

Well, how about this code:

while ( true )

So, we update, then draw ,then sleep for 1 second.. okay, but what if the processing in "update" takes 800ms, how long will we take between draws now?... How about 1.8 seconds!  So that cycle the game will look like it took nearly twice as long to draw, and animations will stutter.

What has this got to do with programming?

Well, once upon a time this very code above strolled into view, and the programmer working with it kept saying "your machine is making my game stutter, it runs fine on my machine"... His machine being a more powerful machine with dual core and more RAM... So I pointed this out, he then set about trying to explain it all away.

When he then showed me this code, I just pointed at the sleep and went back to my desk, it was not my job nor part of my remit to work or debug his code, I saw this problem was simply he wasn't changing how long he slept for, but also he was very confrontational, because the contract with the "Sleep" function on Windows (the platform we were using) is not quite what most programmers expect.

You see sleep will go away and pause a process/thread for X amount of time, and it will come back to continue processing up to or after that time... Up to or after... Not immediately, so in a game you can't guarantee that the Windows Scheduler will pick up your thread and come back to your program immediately after 1000ms above!

I told this chap this, and he flat argued, he even went so far as to print out the MSDN documentation pointing out that I was wrong, and I was a wanker, and he went on a tirade around the office.

It was only later I went back and pointed out that he was referencing the sleep function for Windows Mobile, not Windows XP, and going to the right Operating System on the MSDN page, it said "upto or after the delay".

He didn't say sorry, he didn't say anything, he actually sat down and said "fat wanker".

Lucky for him my boss was stood right there and heard him say this, so I left them to it, but I never spoke to this cunt every again, he left the company soon after, he'd apparently agitated not just me but about six other people, arguing when they knew their stuff and then insulting them.

He was perhaps the third worst person I've worked with at this company.

For information about how sleep works, and how variable it can be, check this out.

Broken Feet

The house move went a head as planned, this was despite three major problems.  The first problem being we were both exhausted... The second being that we'd roped a friend into help, as none of our family even offered to help... And the third was that I broke both my feet....

Yes, I broke the pair... Luckily I didn't realise this, and kept on working, moving stuff, albeit very very slowly... But Sunday at 12:45 the key broke in the front door of the house we are vacating, so the mate helping piled a load of stuff up and said "You hop over that and open the back door"...

So, hop I did... I climbed up onto this 13 foot fence, perched my feet on the lip and jumped off... As the white sparkles cleared from my eyes, I knew I'd broke something... I figured I'd broke my ankles... But I staggered upright before letting this sink in, and I tried to open the door... No dice it was locked and bolted...

An hour later we were in the house, done and complete, the broken lock sorted and heading to the new house, I didn't feel right though, and got into the house by sheer necessity... But of course I chose to jump off the fence and so I was summarily picked on... I think I snarled at my father-in-law at one point, because he finally showed his face to help - but did manage to take the mate helping off for a detour to see his new boat - wasting precious daylight.

Anyway, finally got ice packs on the legs, had ibuprofen, went to bed... Come morning they were purple, and about four times their normal size, but being the conservative I am I only went to my GP... she had a good poke and prod, concluded I'd not broke my Achilles, probably just ligament damage, but she referred me to the fracture clinic.

I went home and carried on moving stuff, expecting a call... That call came Wednesday, to I had an appointment for Thursday morning... 6am I got up to get there on time, and I did... by about 11am I was in negotiations as to what kind of casts I was to have!

Yes, they're broke, and I walked and moved house with broken feet... For four days!... Even the consultant was impressed.

However, the junior doctor did balls up, without asking me he started to dictate my notes and said I smoked and drank!  Neither of which I do... which... which was a bit annoying being pigeon holed like that... I dunno, maybe it'd my beard makes me look like a pipe puffing beer swiller?...

Oh, and to rub insult into the hassle of the week, I finally got to sit down to play games.. and the PC is shagged, the main hard drive is banjaxed.

Tuesday, 11 November 2014

The Day of Your Death

I've been quietly contemplating life, or rather the lack of it, since the last episode of DrWho, which until they explain a few things is treading a fine line of insulting a fair few people with it's "Connected to the Burning body" line; regarding Cremation & the soul...

And a thought, probably a common thought, struck me...

Once you've passed your first Birthday, you've lived through the date on which you'll die... Technically we could say your Fourth Birthday, to ensure you've lived through a 29th February also (and yes I have a cousin born on that date!)

What a singularly depressing thought, we spend so much time thinking about our date of birth, but never really consider our date of death.  Perhaps some do, but of natural or unexpected causes, what a mystery we all lead...

It could be today...

I often post blogs a head of time, so there maybe items in my queue which will go out post-mortem, I may be a posthumous poster... 

Monday, 10 November 2014

Egypts Drugs Problems - Cultural Perhaps?

Reading of the problems of prescription pain killers being used as energy boosters in Egypt I believe there maybe a simpler problem at work, read the original here.

In 2001 when I visited Egypt I had the fortune of mingling with the people, unlike the US visitors who travelled in armoured convoys, us Brits just mingled in; even if in one bar we were accused of stealing the history by one chap and the bar man told him to "shut up, go read your history about the French".

Anyway, we met all sorts of people, backstreet hagglers, beggars, con-artists, sailors, tour guides, shop workers, children, the elderly... A good cross section.

But one chap I particularly remember was in a carpet shop, we didn't want a carpet, we didn't want to be in this shop, but we were bundled through this shop into a back room, literally the store room, and made to sit on a rug listening to a guy who had maybe four words in English, and we said "Thank you, but NO", several dozen times.

Anyway, this was our last day, kicked out of our hotel rooms, and in this hot room for so long I developed a headache.  I casually excused myself and took a paracetamol.

This old guy, and he was old, 70+ immediately asked for one, he pointed at the pill in my hand stopping me taking it and pointed to his head and held out his hand.

He knew what it was, I believe now he perhaps thought it was tramadol, but it was just paracetamol.  Anyway, he took his, I took mine and that was that, we'd been swapping tea in shops with people for the whole week.

It's only now I realise the cultural significance of this, how quickly wanting or taking a pill is, or anything it.. "You're smoking a dried weasel, gimme one of them too!"

It just seems to be part of the Egyptian attitude, now I've also been to Morocco, and whilst they share the same customs with sharing and offering tea they don't jump on wanting a pill off of you, they're in fact more weary if you ask "are you unwell?  would you like an asprin?"... they really ask what it is, read the packet and check the bubble is intact, you know in case it has been tampered with.

I noticed this working with Moroccans for a couple of weeks, it was common for them to be the same, but weary, Egyptians however... "Chuck it down my neck, it's good for you".

Stink Bugs in the UK

I just read this about stink bugs...

If that image at the bottom is of one, I'd like to say, they're already here, I've seen those and caught them in my bedroom both his winter and last winter!

And yes, I caught them and they stank, like a dry fuming smell, from an oily substance which stuck to my fingers and did not wash off easily with just water, it needed a detergent to help shift it from my fingers.

Sunday, 9 November 2014

Ghost Hunting - TAPS

Last night, lost for something to watch for 10 minutes, the wife and I put on one of those Ghost Hunting shaky camera bullshit programmes, some bunch of blokes called "TAPS" running around an old French fort somewhere or other.

Anyway, they kept saying they were seeing things, and kept saying they were hearing things, but they were never on camera, or the camera was shakier than a chronic masturbator in full swing.

But, one of the tests was just hilarious one fellow and a lass put a torch on a set of steps and they asked "any spirits present to flash the light if they are French"... and the light flashes... "Are you a soldier"... and the light flashes... "Did you serve here".. the light flashes...

They're saying they've just made contact with the dead, they've just proven life after death, or existence after death... They've just proven everything the owner of this site wanted to prove.  There's a shed load of other supposed detecting kit near the torch, but they say there's no jiggery pokery going on... Right... Okay... Lets say I believe you, you've dropped this into my viewing, and I believe you, you've just proven life after death!

And they completely ignore this test later on, when they come to review and hand over the evidence to the site owner, they have a shakey picture of a light supposedly dimming and brightening "as if someone is walking past the light" and they they have footage of "my t-shirt being touched from behind"... it looks just like he's moved his shoulder to me... All right, you've shown them that, now show them the proof of life after death!....

Nope, they don't show that footage again, they completely ignore it and it's been ignored by the summing up.... In fact the chap and lass who collected that footage, don't appear again in the whole show!

I find these kinds of shows so annoying, so.... pathetic and annoying.... Don't watch them folks, they're full of shit.

Saturday, 8 November 2014

War Thunder - BF110 Skin Grinding

I've been playing WarThunder and continuing my work through of skins for aircraft, my current target is both for the BF110.  Yes two skins, however, for the poor old 110 they're not farming ground targets these are for player air kills, AI don't count.

So it is a much different prospect to farming ground targets in the Stuka.

I figured however, in Arcade the 110 gets burned down too quickly, in Simulator it gets out matched, so I need to use Realistic battle, primarily for the good view compared to Simulator and that performance is still modified with the Instructor helping.

I'd not fully unlocked all the modifications when I started, I have now, and I've been having great fun with the plane, it is actually a very punchy aircraft when it gets into a tier 1/2 game.  However, I have found myself being matched with BF109F4's, so that's edging into Tier 3 and in those games where everyone climbs high I often find myself climbing up to the same altitude in a lazy oval or in tight zig-zags, because the single engined opponents simply get the jump on me.

The first of the two however, I think, looks great.

I've also started, with the aircraft fully upgraded, to take on the role in my team as the bomber killer, I can knock them down and take the punishment for doing so, when I'm forced to take on fighters I try to dive hit and run for my life.

It can work out to be fun, and profitable... if you vary your role as well, with bombs kept and used as the enemy team dwindle in number.