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

Solar Farm Update! Line moved, Power agreement signed. Energizing date near.

I visited the solar farm yesterday. Its a long trip, but worth it. I had not been there for a while, so it was good to see progress. The reason I went on that day, was it was the day that the DNO (Distribution Network Operator) finally came and removed (recovered!) the 11kv line that ran right over the middle of our site, and redirected it around the farm, with a spur coming off to join into their substation. This was critical (and HUGELY DELAYED by insane bureaucracy) because without that line being gone, we could not install the final mounting tables and panels, or the last few inverters. There is now about a months work to go.

Its so hard to know with these things what is REALLY involved, so I half expected there to be two guys and a ladder on site, but in fact that was probably about 12 people, and multiple vans and cars and 2 tractor things and some people on those extendy platform things they use to go do stuff up telegraph poles, and a LOT of big phat cable. Here is some cable, with me for scale.

The big phat cables are the ones that connect the inverters to our switchgear and also the ones that go from that switchgear to the substation with the transformer in, so they are all roughly 400V cables. They are insanely, insanely heavy. Even heavier than they look, and they do not look light.

One of the big things that had changed since my last visit was the installation of our switchgear in a big metal shipping container. This is a big green thing, that was mostly assembled offsite, but then things need wiring into it. This is basically a switchboard where all the inverter cables get joined together ready to connect (still at 410V which is considered low voltage) to the DNO owned substation and transformer to take it from 410v to 11,000v. Annoyingly, due to earthing concerns, these two structures have to be a certain distance apart, BUT there is also a maximum distance apart they can be, for some technical reason, so its a bit tight, and nuts. Surely it makes sense to be one building? anyway… I had a good look inside the green box. Its big, you can walk around in there:

Maybe the most interesting bit in here will be the actual meter, but that is not installed yet (soon!) but also of interest are the copper busbars that all the cables coming in get attached to, so they can flow together as a single power source. Although amusingly there are two separate places for this, so its not actually single :D. In any case, these super chunky copper bars are LIVE when everything is energized:

There are a lot of cool things in the box, but the most unusual, to me, and wacky are the big fire-suppression systems in the ceiling. I hope we never need them, but I guess you have to have them. All this stuff ends up being madly pricey. Anyway, here is a picture of an industrial automatic fire extinguisher :D

The other momentous thing is probably the sight (finally omg) of the DNO doing the work to move the old line and actually connect my site to the grid. It will now be connected, but not energised. We need the final panels, and then some paperwork and a ceremony called ‘witnessing’ to ‘commission’ the site. I am surprised we do not need to sacrifice a goat at this point, but it will probably just be throwing a switch and then some paperwork. Hopefully in a months time. Anyway, here are DNO people doing things:

And this picture gives you an idea of where the DNO substation (tan color) and our switchgear (green box) are:

Hilariously while I was driving to the site and back, we were also arranging to sell the power. I got quotes from 4 companies, and agreed a price and signed the documents on my mobile phone at a cafe near the site. I won’t say who I sell it too until its officially on their website (we might get an entry on their map of generators). As for the price? Its not bad. Certainly way higher than when I started this project, but my costs have shot up too, so hopefully its ok. I estimate break even in 13 years, which is kind of insane, but when you look at valuation of stocks, in a way thats a price/earnings ratio of 13, which is actually sort of reasonable? However, I suspect we will see short term rises in energy prices and long term falls, so it really depends on how things work out in terms of govt policy favoring renewables/heat pumps/ EVs and the ability to build out large scale energy supply. Anything could happen. In terms of how competitive the market is, there was a range of prices. The company I chose offered the most, but not by much, and it does look like there is real and genuine competition. I had to sign by 3PM that day to get the quoted offer, as it changes daily, but I chose to lock in that price for a year. In future I might choose longer term locks.

Amusingly, we get paid for the power monthly, which is more frequent than I get for console video games I own the IP to. Even the staid old dinosaur energy industry can pay monthly, within 10 days. Take note, video game publishers!

The next big step will be energizing the site, a day on which I am determined to get drunk afterwards, and then we will have the first few stats to obsess over, and eventually the first actual income for this company of mine. Oh My God. There is a lot of ancillary stuff to do on site, like plant some trees, tidy things up, and some plants have grown too high for the sheep to cope with, so it all needs actually proper mowing once, after which the sheep should take care of keeping the grass down.

Anyway, enjoy this final picture. It is me pointing at one of the two (now inactive) overhead 11,000 volt lines that delayed this project by a year, cost me probably more than my first house, and drove me to actual real tears. Its finally gone, and not a problem. Its about the same thickness as the power cable plugged into this laptop.

Solar Farm: Everything you always wanted to know about power purchase agreements (PPA)

I just had another meeting about the solar farm. We are now talking in very confident and believable terms about the date to actually switch on the farm, which is absolutely amazing after the last fifty billion years oft development. Amazingly, humans continue to exist on Earth and the solar system has not been swallowed up by an expanding star and yet my solar farm may get energized. (Obviously an expanding sun would be, in the short term, great news for PV generation…

This week is an exciting week because the overhead line that initially was supposed to save money and make life easy, but actually ended up causing chaos and delays… is actually being buried this week. This is a 5 day process, because what is involved includes the burying of some new line, recovery of the old line, and the actual proper live connection of the high voltage part of the site (this is the DNO’s territory and problem). This should all be completed by this Friday, which is also the day I am next visiting the site to see how things are. I don’t think THAT much visible will have changed since my last visit, but that was a while ago so its good to have a final walk-around before the next visit which should be switch-on.

Now in theory, as maybe 80% of the site is built out, and the site gets actually connected to high voltage national grid connections on Friday, you might think that we could switch on 80% of the site while we finish the rest, but thats a logistical headache. The removal of the line lets us drill the piles for the last few mounting tables and final inverters, and then connect the last few hundred panels, but all those new panels need connecting to the earthing, and the final inverters need connecting to our switchgear (all at relatively low voltage, about 400V), and doing all of that while the rest of the site is live sounds like hell…

On a huge site, like a 50MWP site, it would be absolutely worth the hassle, because of the opportunity cost of not being connected, but on our site, its just not worth introducing complexity just for literally one month of generation for 80% of a farm in a wet cloudy September…

Anyway, there is still a bunch of stuff to do that you don’t think about, like the tree planting (a condition of our planning application), and a lot of incredibly tedious paperwork to claim REGOs (Renewable generation certificates you get for producing green energy that er traded like a commodity). Honestly if someone like Elon Musk saw the bureaucracy and inefficiency behind the REGO system he would explode, but it has to be done as they are worth about £12/MWH.

The REALLY exciting part though is the arrangement of the power purchase agreement which I expect to sign tomorrow. I will go for either a 1, 2 or 3 year fixed price for each megawatt hour of energy the site produces. The actual calculation is a real paid, because there is the raw traded price per megawatt hour (about £70/MWH) and then the ’embedded benefits’ (about £20/MWH for my site) which are payments for being good enough to generate power where it is needed, and not put a strain on the main transmission network…and then the REGOs (about £12/MWH).

The embedded benefits stuff is interesting. If you think of electricity like traffic, then you have local roads, A roads and then Motorways (highways). As anybody who has built a road will tell you (We did!) the cost per mile goes up a LOT as your road gets bigger. So if generation requires an upgrade to a major transmission line (motorway) its stupidly expensive. If you can generate power that never leaves the local roads, and in fact therefore puts less pressure on even the A roads, then there is value in that, and you get compensated. To put it another way, building a small local solar farm helps supply a rural(ish) community, and puts less pressure on the connections to and from that community. In practice, my energy will certainly never leave Shropshire, and will probably never even leave the local town within Shropshire. I’ve made the job of managing the transmission network easier!

Anyway, for reasons that escape me, it seems that you lock in power purchase agreements for 1-3 years, but the price fluctuates on a DAILY basis, so you have to sign the deal the same day (before 4PM) that you get the quote. So at some point tomorrow I may well make a financial decision that affects my business for a few years. Still, I’m playing the long game here. I might lose money for 15 years then suddenly reap the rewards of madly high prices. Who knows. Doing this stuff is not for the meek. I’ll probably have pics to share on Friday!

Solar Farm update. Even a video!

Is it depressing that I am actually pleasantly surprised that wordpress handles direct uploading and embedding of video clips? It should be a pretty trivial endeavor in 2024, but I’m apparently shocked to find it working :D. Anyway, here is a video taken by some contractors on the site as they worked on the cabling and site substation.

In terms of progress… well not a lot, despite it being HUGELY SUNNY right now, my farm remains unconnected, earning nothing, due to the insane delays and bureaucracy. There is some good news, in that finally the insane list of delays and excuses got exhausted and I was given an actual firm date for when the overhead line (so small you will barely see it on the video) gets taken down and buried. This is the hugely expensive work that has to happen before we can fill in those pesky gaps in the rows of panels, and then actually do the final bits and pieces before the big ‘energisation’ of the farm when it goes live.

That date is <DRUMROLL>

SEPTEMBER 9th.

There is actually a few days of work associated with all this. The schedule looks like this:

  • 9th September – Deliver materials to site
  • 10th September – Install 2 x HV poles ready for shutdown
  • 11th September – make off 2 x 11kv pole terms
  • 12th September – make off any stay and make sure everything is in place ready for shut down
  • 13th September – Shutdown to loop in new substation

So from the 13th September onwards we will be in a hopefully minutely planned and seamless period of work to install the last frames and panels, and wire those up, plus connect the final bits and pieces, final fencing, and so on before we can switch on the site, just in time for mid-October’s total lack of sunshine. Oh the irony. However, that means a switch-on this year is almost guaranteed!

I will definitely be going to the site to see what is going on during that week, probably on the 13th, and obviously I’ll be returning to see it switched on. I might go back in-between those dates as well.

Some actual progress has taken place in the meantime, but its been slow because frankly there has not been any hurry given that the line-move was delayed so much and then there was insistence on a pointless 8 week delay on top of that. We are currently finishing our substation (mostly a switchboard) and the inverter to substation cabling (underground), and then there is something called ‘tails’ that needs doing, and we need to install the meter to read the generation, and also any power we import to run equipment overnight. The only interesting picture I have of all this is these big phat rolls of high capacity power cable:

    So its sort of good news, in that there is progress and then end is in sight. I have not yet signed a deal to sell the energy from the farm (a power-purchase agreement), as its a bit early to do that. Also prices tend to rise as we head towards winter so a late signing probably benefits me. I’ll be considering that around late August/September.

    Something interesting is that lithium-ion battery storage costs continue to fall. I had decided not to add a battery but may be able to revisit the economics of that once everything is running. I’ll definitely want a full years data from generation before I even consider it though.

    Re-thinking painters algorithm rendering optimisation

    Before I even start this post, I should point out that currently the project I am coding is for fun. I actually really ENJOY complex programming design challenges, unlike many people, so the comment ‘this is done for you in X’ or ‘there is middleware that solves this without you doing anything in Y’ is irrelevant to me, and actually depressing. Whatever happened to the joy of working on hard problems?

    Take an imaginary game that has a lot of entities in it. Say 500. Each entity is a sprite. That sprite has an effect drawn on top of it (say its a glowy light) and a different effect below it (say its another glowy light). The objects have to be rendered in a sensible way, so that if one object passes over another (for example) the glowy lights ‘stack’ properly, and you don’t see aberrations where the lights from something are seen through something else. Here is a visualisation:

    In this case red is the ‘underglow’ grey is the sprite, yellow is the overglow. The bottom right duo shows the issue where things have to be rendered correctly. In a 3D game with complex meshes and no antialiasing, you just use a zbuffer to draw all this stuff, and forget about it, but if you are using sprites with nice fuzzy edges (not horrible jaggy pixels, you really need to use the classic ‘painters algorithm’ of drawing from back to front for each object. There are clear performance problems:

    A naïve way to code this would be my current system which handles each object in 3 draw calls. So we set up the blend mode for the underglow, and draw that, then set a normal blend mode, draw the sprite, then a glowy blend mode to draw the top glow, then repeat for every other entity. The trouble is, with 500 entities, thats 1,500 draw calls simply to draw the most simple part of the game…

    Unfortunately this only scratches the surface because there may also be other layers of things that need drawing on top of each entity, and between drawing each sprite. However there is a major optimisation to be had…. <drumroll>. Actually my game really works like this:

    Where there is a grid, and <generally speaking> the entities stay in one grid box at a time. WITHIN that grid box, all sorts of stuff may happen, but items in the top left grid box will not suddenly appear in the bottom right grid box. In other words I can make some clever assumptions, if only I can find a way to generalize them into an algorithm.

    For example I could draw the underglow in one object in each grid box all together in a single draw call like this:

    So this is suddenly one draw call instead of 8. I then do the same for the sprites, then the overglow, and then do the other object in each grid square as a second pass (basically a second Z layer. Assuming 8 grid squares, 2 per square, 3 passes, thats 48 draw calls for naïve method and 6 for the new method. Pretty awesome! However, thats oversimplifying things. Firstly in some cases there are 16 entities in each grid, in others just 1. Secondly, in some cases items ‘spill’ over into the next grid square, so I need to ensure I do not get an anomaly where 2 objects would overlap just slightly and thus z-fight when drawn…

    Like everything in game coding, the simple code design always accelerates towards spaghetti, but I would like to do my best to avoid that if possible…

    In order to decide what is drawn at what time, I basically need 2 pieces of metadata about each object. Item 1 is what grid square it is in, and item 2 is the Z value of that object, where I can cope with say 16 different Z ‘bands’ for the whole world, meaning a group of 16 entities in a square will definitely be drawn with 16 different draw calls, and thus be painter-algorithm-ed ok.

    I also want to do this without having to do insane amounts of sorting and processing every frame, for obvious efficiency reasons…

    So my first thoughts on this are to handle everything via Z sorting, and make the list of entities the de-facto Z sort. In other words, when I build up the initial list of entities at the start of the game, I have pre-sorted them into z order. So instead of a single list of randomly jumbled Z orders. I get this situation, where the black -number is the Z position, and the blue references the grid square:

    So my now pre-sorted object list goes like this:

    A1 B1 C1 D1 E1 F1 G1 H1 A2 C2 F2 etc..

    I can then do batches of draw class so my actual code looks like this

    • DrawUnderGlowFor1()
    • DrawSpritesFor1()
    • DrawOverglowFor1()

    The nature of the game means that generally speaking, Z order can be fixed from the start and never change, which simplifies things hugely. The bit where it becomes a real pain is the overlap of objects to adjacent grid squares. I would also like a super-generic system that can handle not just these fixed entities, but anything else in the game. What I really need is a two layered graphics engine:

    Layer 1 just send out a ton of draw calls, probably with some sort of metadata. This is like a draw call, plus relevant texture, plus blend state for the object. This is done in a naïve way with no thought to anything else.

    Layer 2 processes layer 1, does some analysis and works out how to collapse draw calls. It can calculate bounding boxes for everything that is drawn, see what overlaps with what, and what can be batched, and then decides on a final ‘optimised’ series of calls to directx. This is done before any textures get set or draw calls are made. It then hands all this off to ideally a new thread, which just streams those draw calls to directx, while the other threads get on with composing the next frame.

    I have attempted such a system once before in the past, but I was a less experienced coder then, and full-time working, and on a (self-imposed) deadline to ship the game, rather than obsess over noodling with rendering engine design. So hopefully this time, I will crack it, and then have something super cool that can handle whatever I throw at it :D. Also the beauty of this design is it would be easy to bypass stage 2 and just render everything as it comes in, so I could even hook up a hotkey to watch the frame rate difference and check I’m not wasting all ny time :D.

    In praise of long-form content and deep work

    While idly trying to find something of interest to read one evening I found myself at medium, looking for tech news articles. I didn’t end up reading anything, because I was suddenly struck by how awful it was that every article has a tag line underneath it telling us how many minutes it takes to read it. The examples I saw were ‘3 minute read’ ‘5 minute read’ ‘6 minute read’.

    This is staggeringly depressing.

    Imagine the situation where you want to read something, which means taking new information into your brain, and you are only able to commit to a 3 minute session of reading, not 5 minutes. Unless you are the US president, or Elon Musk, you probably don’t actually have to save the vital 2 minutes difference. So this metric is not really being given to be in any way helpful, its being given as a kind of reassurance, or in the 6 minute case, presumably as some sort of urgent trigger warning. Its no great revelation that social media is warping out minds, but I really don’t think we appreciate just how bad its getting. When you cannot make a safe assumption that someone’s attention will be held for even 6 minutes, we are in real serious trouble.

    The world is scarily complex. Way more so than when I was a schoolkid. The sheer tonnage of stuff you should know about now, that wasn’t even a thing back then is scary. Primarily, its the way tech works, so you have to know how computers work (roughly), what apps are, what wireless internet is, how to charge a phone/laptop, how to use a trackpad or touchscreen, how to swap between apps, how to type (actually not considered important when I was 5 years old), some idea of what email and spam are, how to pick a password, what a username is, what a browser is. How to swipe between items on a phone, what an update is…

    …and its not like the real world is simpler either. My parents were very unusual because they had traveled to Europe! but never beyond. Their parents had only left the country to invade/liberate others. As a result, knowing a lot more about an incredibly connected world is now much more important. I only knew the concept of ‘forename/surname’ reversal from the bajorans in star trek:deep space nine. I had no idea that was a thing. I only really understood the complexity of honorifics last year. As a child, the most exotic food I encountered was spaghetti.

    In 2024, its just assumed that anyone in the UK is familiar with the culture and cuisine of pretty much the entire planet. Most stuff we buy comes from outside the UK (this was NOT true in the 1970s), most people travel outside their home country. This is awesome, and beneficial, and culturally enriching, but it makes like so much more COMPLEX.

    Plus science and technology marches on, and culture becomes more complex. Watch a TV drama from the 1970s or 1980s. Something you may notice is the plots are relatively simple, the narrative is linear. The same is true of most literature. The ‘fractured narrative’ is a relatively recent trend. When ‘Lost’ debuted on TV, it was radically different, complex, inter-twined stories which required serious attention. Modern TV drama relish their super-complex plotlines, flashbacks, deception and feints. This was not always the case. At the same time, every academic field has got more complex. I studied Economics before Behavioral economics was even invented. It didn’t ‘replace’ what I learned, it augmented and expanded it. This diagram is apparently series 1 of ‘dark?

    Life’s complex as fuck these days

    But meanwhile we seem to be systematically destroying our capability to do what it is sometimes referred to as Deep Work. What is Deep Work?

    Professional activity performed in a state of distraction-free concentration that push your cognitive capabilities to their limit. These efforts create new value, improve your skill, and are hard to replicate.”

    In other words, pretty much anything thats really worthwhile is Deep Work. And to do deep work, you need the exact opposite of the social-media fueled doom-scroll focus-destroying mindset that every big tech company seems to be pushing us towards. Perhaps the worst examples are TikTok and Instagram. They seem hyper-focused on super-short, non-interactive consumption of tiny tiny nuggets of dopamine. By comparison even X is better, as it now supports long-form posts and at least seems to be more focused on interaction, and thus conversation/interrogation.

    I find myself deeply worried about my own ability to concentrate on long form text, or to be engrossed in any long form activity. I can go play the guitar for 30 minutes, but after that I start to wonder if I have any email. As an 18yo kid, I would happily go 8 hours playing scales to a metronome. No distraction required or desired. I didn’t stop until desperately hungry.

    Quite a few years ago, on a whim, I started to read Winston Churchill’s war diaries. All of them. Its a lot. When you are the leader of a major military state in world war 2, you have a LOT to write. And Churchill wasn’t famous for brevity. The volumes now sit proudly in a bookcase, a rare example of an entire set of tiny-text serious books that I made it through. Reading them was a bit of a slog, but I’m glad I did, especially considering how much time I now seem to just wase entirely checking twitter or scrolling through slashdot stories I will never read.

    I do genuinely worry that we are already splitting into a society of basically 2 different groups. A tiny, tiny group of people who are working out how everything works, and doing serious research and work on making things better, and then a vastly larger group of us who just doom-scroll, or spend our days sending memes and emojis, and pretending to do work. Increasingly the idea of spending serious time to learn very complex new skills sounds ‘lame’ compared to trying to be witty on twitter in the desperate hope of ‘going viral’.

    At this point you are wondering if there is any way I can steer this blog post back to either video games or solar panels, and believe it or not, I can, and much faster the Winston Churchill would have done, let me assure you. I’m going to talk about a specific videogame : Dwarf Fortress.

    I’ve only tried to play Dwarf Fortress once. It was about 5 years ago. I didn’t get into it at all. Its not for me. I LOVE the idea of it, and love that it exists, but its really not for me. But thats not important. All you need to know about Dwarf Fortress is that it is ludicrously, hilariously, insanely detailed. Its a city builder for dwarfs, where the UI (originally) was just a bunch of text. It doesn’t matter, all you need to know is it was basically a hobby project, where the creators lived off donations from obsessive players. There are way more details here.

    This is where I give you a dopamine hit by skipping narratives to talk about the plight of the average indie game developer trying to get press attention. I know a lot of people who try this, and their strategies are very different, but in many cases there is a reliance on social media, and a desire to use the correct hashtags, and construct posts just right so you can strike it lucky and go mega viral. This Never Works. And BTW, even when it does work, it doesn’t work. I once made a stupidly viral tweet with about 80,000 likes. Do you think I was able to steer that into more sales of my games? (spoiler: no).

    Dwarf Fortress was the absolute opposite, its two creators basically just stuck their heads down, and kept working and improving and developing and updating the game for years and years and years. It was first released in 2006, so that’s 18 years so far, or much longer than World War II. To work on a single game for so long is impressive. It requires amazing attention to detail, incredible passion, and people who are perfectly happy to say to people literally decades later ‘yes I am still working on that thing’. And the very very best bit of the story? When they finally put their game up for sale for actual money on steam, they made bazillions of dollars overnight. It was a decades-long overnight success.

    The thing is, if you say to people now “you need to work really hard, all the time, probably for decades, and you will then probably have the same result”, absolutely nobody will even consider this as an option. These days the idea of coding your own game engine is considered some freakish, weird, obsessive things that only super-autistics gluttons for punishment like me or jon blow would consider. It used to be the norm. At one point, everyone had to do it, and nobody died as a result.

    I am currently coding a new game. The game may never be released. At the moment its still a secret, and mostly a hobby. Its VERY similar to another game I made, but because I dislike getting old code to recompile, and because frankly I LOVE to code, I’m basically recreating that old game, and its engine, entirely from scratch, instead of reusing the old code. This means thousands of small improvements, that I’d never make if I just ‘updated’ the old code. I enjoy doing it, and regret nothing. I am also quite glad I can still do it.

    We desperately need to retain the ability to focus long and hard on complex stuff. Its an essential skill, and I suspect almost everyone reading this is struggling with it, in the face of social media, and tech companies desire to kill our attention spans. I urge you to fight back. Pick a seriously long book and read the whole thing. Or pick a new technology or skill and commit to serious long stretches to master it. It is incredibly fulfilling. I have spent a mad number of hours learning to play the guitar. At this point in my life it serves no real ‘purpose’ career-wise, but I still get a lot of joy from knowing I have that skill and can still do it.

    Well done, you read the whole thing :D