Game Design, Programming and running a one-man games business…

An impossible bug. ARGGGH

Check out this code from production line for displaying pie charts of expenses.  I declare arrays of float totals for each of 3 pie charts.

 float totals[NUMPIES];
 totals[PIE1] = 0;
 totals[PIE24] = 0;
 totals[PIEALL] = 0;

 

Then I declare a 2-dimensional array of floats which I fill with some data. As I build up those amounts I also update the totals:

float amounts[NUM_FINANCE_CATEGORIES][NUMPIES];

for (int r = 0; r < NUM_FINANCE_CATEGORIES; r++)
 {
 if (r != FC_CAR_SALES)
 {
 amounts[r][PIE1] = SIM_GetFinanceRecords()->GetAmount(1, (FINANCE_CATEGORY)r);
 amounts[r][PIE24] = SIM_GetFinanceRecords()->GetAmount(24, (FINANCE_CATEGORY)r);
 amounts[r][PIEALL] = SIM_GetFinanceRecords()->GetAmount(-1, (FINANCE_CATEGORY)r);

totals[PIE1] += amounts[r][PIE1];
 totals[PIE24] += amounts[r][PIE24];
 totals[PIEALL] += amounts[r][PIEALL];
 }
 }

 

Then some simple resetting of data, which is irrelevant for this bug, and a check that I am not about to divide by zero:

Pies[PIE1]->Clear();
 Pies[PIE24]->Clear();
 Pies[PIEALL]->Clear();

if (totals[PIE1] <= 0 || totals[PIE24] <= 0 || totals[PIEALL] <= 0)
 {
 return;
 }

 

Then the final code:

 //now create
 for (int r = 0; r < NUM_FINANCE_CATEGORIES; r++)
 {
 if (r != FC_CAR_SALES)
 {
 for (int p = 0; p < NUMPIES; p++)
 {
 float perc = amounts[r][p] / totals[p];
 assert (perc >= 0 && perc <= 1.0f)

Hold ON STOP!. How can that assert ever trigger? EVER? (it does for some people). Its driving me mad :D. It can ONLY trigger if one of the amounts in the array is less than 0% or more than 100% of the total. I KNOW that the total is greater than zero, so the amount must be greater than zero. The total is only comprised of the sum of the amounts. There is no way these numbers can be out of synch, PLUS, they are all floating point vars so there is no rounding going on… or is it maybe a tiny tiny quantizing thing? (I’ve update the game with extra debug data for this error so I’ll find out soon). Surely thats the only explanation, and perc is something like 1.000000001%?

 

 

Coding your own ‘middleware’ is easier than you think

I have a system in the early access version of production Line that when an error happens that I assert() on, it logs that error out to a debug file, along with a timestamp, and the file name and line number of code where the assert failed. This is easy to do (google it). I recently changed this code so it also posts the error message, line number and filename data to my server (anonymously, I have no idea which player triggered it). That code basically just uses the WININET API to silently post some URL variables to a specific php page. That page then validates the data to make it safe, and runs an SQL query to stick the data into a database on my server.

IU can run SQL queries on the server to see what bugs have happened in the last 24 hours, which ones happened the most, what the version number of the game was, and how often they are triggering etc.

This has proven to be awesome.

The default solution these days to this kind of stuff is to buy into some middleware to do this, but thats not how I roll. I also have some balance-tracking stats analysis stuff that does the same thing. I can tell if the game is too hard, or too easy, or if players dont get to build electric cars until hour 300 in the game…and all kinds of cool stuff. This is the sort of thing that middleware companies with 20 staff, a sales team and a slick marketing campaign try to flog to you at GDC in the expo. Its really not that hard, it really is not rocket science. I get the impression that the majority of coders think that writing this sort of stuff is an order of magnitude harder than it actually is.

Oh also, production Line checks once per day on start-up to see if there is a newer version, then pops up a notice and a changelist if there is (for non steam versions). Thats home-grown code too, and its easy, EASY to do,m once you actually sit down and work out whats involved.

I know the standard arguments in favor middleware ‘it comes with tech support, its faster than coding it yourself, it allows you to leverage the experience and knowledge of others’, but I reject all of them. The only reason I know how to use WinInet, php and SQL and all that sort of stuff is because I taught myself. I taught myself ONCE in the last 36 years of programming, and I know how to do it now., I have my old code, and my own experience and skills. I dont care if XYZ Middleware INC is going to go bust, stop supporting my platform, double their prices, or stop answering emails, I have all this experience in house.

When you look at most middleware, its vastly bigger, more feature packed and complicated than you need it to be. Middleware has to be, because it has to be all things to all people. My stats tracking and error-reporting doesn’t have to work on IOS or on OSX or on mobile, or XBox or Playstation. it doesn’t have to be flexible enough to talk to four different database types, or support Amazons AWS. I don’t NEED any of that stuff, so guess what… the code to do what I *actually* need to do, is incredibly, incredibly simple. Don’t think about middleware contracts and APIs and excuses not to write the code, ask yourself ‘what exactly does the code need to do here anyway?’

I think when coders do that you will find, its actually way easier than you think. I did my error reporting code, both the client side and the server side, and tested and debugged in in about an hour. This stuff is not complex. Stop buying ‘fully-featured’ bloatware you don’t need.

GDPR, Cambridge analytica and hitting the wrong target (again)

This isn’t the first time the EU fucked up. Oh no. Remember that terrifying, scary time before we had the EU cookie law? that time you would surf the internet not knowing that many of the seemingly innocent sweet sites you visited did not use cookies, and how wonderfully safe and happy you felt after the EU introduced that wonderful thoughtful law that demanded that every single site on the entire web (as almost everyone uses cookies) pop up an irritating, patronizing window telling you that they used cookies? Isn the internet not much, much nicer to surf, and much safer since we had an extra mouse-click on the ‘WARNING COOKIES’ dialog for every website in the known universe?

No, of course it isn’t, that law was a complete and utter waste of everyone’s time, millions of peoples time, and continues to be, every day, as we all click on patronizing messages telling us what we already know. Its just one level above the dumbness of a warning saying “DANGER THIS SITE USES HTML”. It was a typical dumb techno-illiterate law passed by bureaucrats who didn’t even understand what they were trying to fix.

Thankfully they would never make the same mistake twice right?

Enter the GDPR, a new astonishingly useless piece of EU legislation that has resulted in the largest torrent of spam in my inbox since the invention of gmail. Suddenly everyone who I have ever had an account with has to spam me to ask me if they can continue emailing me, assuming that somehow I am incapable of hitting ‘send to spam’ and thus have NO WAY to control spam other than this clunky law of the EU. The GDPR has, as usual created a ton of work for everyone who runs a business with an online component (this is 2018 so that means everyone on the planet), whilst achieving absolutely fuck-all.

Essentially, the EU are looking at scandals like Cambridge Analytica and political social media manipulation and…. grasping at the nearest thing they have to ‘an internet privacy thing’ and passing that, without it having ANY impact whatsoever on the actual problem (which is mostly fake news), whilst taking a  wrecking ball to the idea of personalized advertising. I’m going to spell out in one sentence why this is dumb as hell:

Personalized advertising to reach genuinely interested customers is awesome. Personalized advertising aimed at undermining democracy is entirely different.

Why can’t lawmakers understand this? Trying to equate deeply targetted, niche advertising with political manipulation is completely dumb. Knowing that I’m a 48 year old white English male who drives a car, lives in a rural location, likes star wars, plays video games and works as a programmer enabled the ads I see to be relevant to me. Show me an advert for a new electric car thats in my price range… i’m genuinely interested. Show me an advert for a new virtual reality headset and I’m interested, show me an advert for baby clothes and I’m not fucking interested. Show me an advert for ladies bicycles and I’m not fucking interested.

We have learned many years ago that advertising is annoying because 95% of the time it was being shown to the wrong person. We are finally escaping that situation, with ads being shown much more in line with the genuine interests of the viewer. If you are over 65 I don#t WANT to bother you with my video game ads. If you only play FIFA, I don’t WANT to bother you with my strategy PC game ads. By ensuring advertisers have no access to personalized information, you make advertising WORSE.

The solution to true scandals like the whole trump/brexit/cambridge analytica scandal is simple. You ban political ads on social media. We already ban them on British TV, we can easily pass a law that bans them on facebook. Thats fine, easy, simple, and it does not require us to take the entire advertising industry, attempt to wreck it AND at the same time make the experience WORSE for both advertisers and consumers.

Simply put, the people who think they will solve political advertising with GDPR are idiots. Its the wrong method, aimed at the wrong target, by people who have no idea how the modern ad market works. Its also hilarious to think Russian state-sponsored bot networks are going to comply with the GDPR. I voted to remain in the EU, but every time they pull something like this, they make the whole system look like a bunch of idiots.

I have a cold, I may seem grumpier than usual :D

Uncompressed video blog!

Finally my first super-fast internet upload of a weekly video blog, in super HD!   with new intro!!!

STUUUUUUUUPIDLY Fast internet (Fiber to the premises)

Its been a long, long bitter struggle, the likes of which I would turn into an opera if I was A)Wagner or B)Klingon, but basically at the end of a long struggle, I now have stupidly fast internet (at least for the UK). Here is a brief summary.

Firstly WHY was my internet so bad? because I live here (see below), which looks nice, and it is, its so quiet (ish…crows tractors and even shotguns are a thing…), there is VERY little crime, there is zero traffic, the air is fresh, its a wonderful place to live… (picture taken by me with my drone :D)

…apart from the fact that the internet, phone and power lines are all delivered to our houses like this:

Which is sub optimal. Again, the UK’s technological innovation in its far history has come to hurt us. We had very very early railway lines, so they are still here…and awful. We had very very early telephones…and the same wiring is still here…and awful. When people started getting the early phone lines in the UK nobody thought they would ever become THAT important, so sticking a handful of cables up on poles and running them along roadsides seemed fine…but we now find out that doesn’t scale, especially when trees grow next to the lines, and its windy as hell, and rains a lot..and the copper degrades…and to cut a long story short, most people in a rural location like me get internet speeds worse than my old ADSL speed:

Which is actually…not TOO bad. We could use catch-up TV services like the BBC iplayer, we could surf, play games, even stream (most of the time) on netflix and amazon, but large files (like games and game updates) were torturous to download, and uploading anything larger than 500MB was practically impossible. When I did my weekly blog video updates for Production Line I had to render them at 60FPS 1080p, then compress them with handbrake to 30FPS compressed, and then go mow the lawn or whatever during the 2+ hours it took to upload those compressed files. Video calls on skype were impossible and twitch was not an option. Ideally…we needed faster ADSL or FTTC to fix it.

FTTC stands for ‘Fiber to the cabinet‘ and it means a fiber superfast cable goes to a cabinet in the street, and copper cable goes from the cabinet to the house. Its what 90% of UK customers who ‘have fiber’ are using, and you can get maybe 50Mbps down, 10Mbps up (if you are lucky. Our local telephone exchange was FTTC enabled. OH MY GOD. But… the geniuses who manage this stuff had placed the ‘nearest’ cabinet further from us than from the exchange…so actually upgrading from ADSL to FTTC would have reduced our speeds… Many people in the village gave up and ordered satellite links (horrid latency).

I wont bore you with my epic struggle to get fiber, but the short version is me actually plonking down a massive deposit (final cost would have been five figures) to get what BT called ‘fiber to the premises on demand‘ which is basically their way of saving “You cannot have fiber, butt throw us a huge pile of cash and we will do it anyway’. Lots of debate went on, and local councils claimed to be paying for it at the same time as me (the cheek!) and to cut as long angry story short, I got a full refund, and BT connected us all to fiber anyway… (yay!)

I assume it must be illegal for BT openreach to actually think long term, because rather than dig up our road once and lay decent fiber cable, they spent days trimming some trees (but not all of them…which makes zero sense) and then laid fiber cable in the air between poles…except for a bit about 300ft long down a bit of road between no houses and just open pasture, where they buried it underground for no adequately explored reason. They even threatened to add two NEW poles on my neighbours land until he told them where they could put their poles, which obviously it turns out they didn’t need anyway…

So at last, a BT guy came and connected the final piece of the puzzle, a fiber cable into my house. Interestingly it came bundled with a new copper cable, so he could remove the old cable and reuse the same hole. Awesome.! I now have a BT fiber modem (its big!) attached to the wall, most of which is apparently a battery backup to keep the internet up and running if we get a power-cut (we do…and this is awesome, as my PC is on a UPS anyway :D). We also needed a new fiber-capable router because the old one couldn’t cope with the speed.

We got our fiber at 220MBps down, 20MBps up, and we get close to that:

I went with IDNet who seemed very organised, and its costing me a total of £96/month, including them taking over our old copper phone line for elderly and technologically clueless people who actually want to PHONE me in 2018. *shakes fist*. We have no data cap whatsoever. Obviously its a business expense, so I save a little bit of money on that.

Anyway… FTTP (fiber to the premises) is amazing, and so fast its actually funny. I cant find ANYTHING that I can download actually at 200Mbps, its pretty nuts. Steam updates are lightning fast, uploading files stupidly quick, and even simple tasks like posting screenshots to twitter now happen instantly. Youtube defaults to max quality and loads way beyond my ability to watch anything. Its truly awesome. My only regret is that the 80Mbps/20Mbps upload would have been more than enough, and I didn’t go for it. Anyway…fast internet is awesome. I feel like I’m in the modern age at last. I may even start using twitch!