Grid controller simulator banner

Grid controller simulator

17 devlogs
36h 10m 15s

My most ambitious project. This has been a project of mine for years but I finally have the ambition and skills to complete this. What this promises to be is a realistic video game with intricate simulation mechanics and interesting challenges for…

My most ambitious project. This has been a project of mine for years but I finally have the ambition and skills to complete this. What this promises to be is a realistic video game with intricate simulation mechanics and interesting challenges for the player. It is going to have realistic simulation, sandbox mode, campaign mode, custom map support and even achievements and custom scenarios, could add a market if I am feeling spicy. I hope you find the premise and execution fun as I try to balance realism with complexity and enjoyment.

This project uses AI

Used claude to help with some advanced vector math for the icons and complicated ui math suggestions
Run the code through claude to catch any bugs I may have missed during development and testing
and some light formatting on the readme

Demo Repository

Loading README...

georgegk

Shipped this project!

Showcase video: https://youtu.be/BI512Jm9dFE
What is this project? If I had one word to describe it it would be: an experience. You really get a feel for the job a grid controller has, what happens in our daily lives to maintain this service with a nearly 100% uptime. It almost feels like magic. That’s what I was going for. The physics behind it are pretty complex, I am sure you don’t wanna hear about that right now and get bored (all the details are in the readme if you are interested). Generally this project helped me grow a lot as a developer and further develop the skillset required to create amazing videogames. But this story is far from over, we still have so many features left to implement (over half the buttons are still locked!). Hope you enjoy this game and I will be here for the next part of this journey.
Since the last ship I mainly added the settings menu, fixed bugs and added music

georgegk

Ok so I didn’t do too much, I just updated the readme with the new info, pushed all of the project files to github, built the game for macos using github actions (took a while to get it working) and built the game for linux using my dual boot ubuntu. I also recorded and published a showcase https://youtu.be/BI512Jm9dFE

Attachment
0
georgegk

Ok so I was just testing the game when realized that I didn’t have any way to view the status of a specific power line. So I went ahead and made a menu that displayed that with all of its stats like status, voltage, thermal limit, load ect. But as I was looking around the map with the new menu I saw that every line had a load of 0. Obviously that shouldn’t be possible so I dug around my simulation engine to try and find an explanation. I won’t bore you with the technical side of things it was basically numpy silently failing when it recieved arrays full of zeros but I fixed that and everything looked good to go. But then I tried to trip a line as a test and the network beyond it somehow still functioned like it was connected. It was more technical math that was causing the issue so I decided to fix it by calculating which nodes where connected by active lines to the main substation and only allowing them to operate if they were. I then had to go to the generators and make them immediately trip and go to 0 if they aren’t connected, go to storage and make it disconnect and stop providing power if it isn’t connected and go to loads and make them disconnect and not have any demand if it isn’t connected. After that was fixed I saw that many power plants did not have any lines connecting them to the grid so I went and manually edited the map json to create a few new lines. And last but not least many lines would just immediately trip cause I set the thermal limit on most of them way too low and had to calculate new values for every line.

Attachment
Attachment
Attachment
Attachment
Attachment
Attachment
0
georgegk

So I kinda forgot to devlog for a bit so here is a breakdown of what I did in those 4 hours. I first integrated the menu option fullscreen which I had literally no idea how to do but after googling it I just need to put a specific flag in the screen command so I messed around with different flags until I got a configuration that worked. Then I needed to integrate the different frequency options in the second option which required me to find every single use of frequency and change it to accommodate both 50 and 60hz. After that I had to find a few good royalty free songs for the soundtrack. I settled on 4 songs with 1 being a bit more fast paced. I then created a system that automatically plays songs and advances the current track index but has a fallback in case for some reason if fails to initialize the audio to prevent crashes. I also integrated the last option that simply prevented the fast paced from playing when enabled. Lastly I decided to add your battery usage as a factor to determining your score and made it so when you hover your mouse above the menu it displays a breakdown of what’s contributing.

P.S. I completely forgot about this but I improved the tutorial like a lot. I made your screen pan by itself to not cover the node you needed to click and highlight the menu of said node when necessary. Overall it should make it much clearer and more understandable!

Attachment
0
georgegk

Ok so I continued to work on the menu, trying to think of more ideas for the settings. I eventually decided on those 4 and built 2 other reusable input classes: slider and toggle button. The implementation wasn’t too complicated since I just copied the toggle class and made adjustments to fit each time. It took a bit to get each slider working but overall I am incredibly happy with this result

Attachment
0
georgegk

I read all of your feedback and I am very thankful for your incredibly high votes ❤️! I wrote down in my todo list all the suggestions so I will have to integrate those before I move on to the other features. Now I decided to ditch claude on the ui help and do everything myself so naturally I am way slower but it does feel better. I just hope I maintain the high quality. Right now I am working on the settings menu and I made a reusable toggle button class to choose the frequency.

Attachment
0
georgegk

Shipped this project!

Hours: 24.75
Cookies: 🍪 665
Multiplier: 26.86 cookies/hr

What is this project? If I had one word to describe it it would be: an experience. You really get a feel for the job a grid controller has, what happens in our daily lives to maintain this service with a nearly 100% uptime. It almost feels like magic. That’s what I was going for. The physics behind it are pretty complex, I am sure you don’t wanna hear about that right now and get bored (all the details are in the readme if you are interested). Generally this project helped me grow a lot as a developer and further develop the skillset required to create amazing videogames. But this story is far from over, we still have so many features left to implement (over half the buttons are still locked!). Hope you enjoy this game and I will be here for the next part of this journey.

georgegk

Nothing much to say I just wrote up the readme.md and pushed everything to github. It was pretty easy, mostly a lot of copy and pasting from different documentation I have written up to help me with development and giving claude a final pash to have it polish it

Attachment
0
georgegk

This alpha is ready to be published. Now I don’t have all the features ready just the tutorial and simulation, but I want to get some feedback on the game and physics before I continue, that’s why I am going to ship shortly after I write the readme.md. In the meantime I added this tutorial with gates to guide the player through the mechanics and allow them to interactively learn the game. Lastly I also added a small disclaimer to the main menu when you boot the game that includes some important info about the current state of development.

Attachment
Attachment
Attachment
Attachment
Attachment
0
georgegk

After the last devlog I decided the simulation itself was good so I went on to build the game over screen and main menu. I started with the game over making it show your score and reason for failure and allowing you to either restart (click or press R) or return to the main menu. Now for the main menu I decided to show all the game modes I am planning and have described above and have them locked. All except for the Realistic Simulation which is the one I have developed currently. Now as you see I have high ambitions for this project and I hope I will be able to complete it. For now I am going to build the tutorial, see you later!

Attachment
Attachment
0
georgegk

ok yeah it was in fact not functional. It was a lot of bug fixes before I got them to work without crashing but they eventually did. Now I realized that I had been applying the droop to the freq wrong so I fixed that, but then realized that I should have been applying it to _tick_dispatch so I moved it over to there, but then again realized that I had the inertia calculations and then finally decided that it made the game too easy so I removed and just kept some basic inertia. Now I also fixed other less note worthy bugs making this game more playable. I think we are approaching a point where I think I can somewhat ship this as a way to get feedback on the concept/gameplay/ everything else. Wait I also forgot to say that I added time multipliers that make the simulation run faster and retrofitted the time indicator to also show minutes

Attachment
0
georgegk

Ok so I finally got back into developing this game after finishing a couple of other projects and I am off to a great start. I started by trying to improve the load shedding simulation cause it was causing this weird oscillation going in a loop low freq -> load shed -> high freq -> load restore - > low freq but I eventually realized that this load/restore would probably make the game way too easy so I am thinking of maybe removing it and having the user manually shed and restore per load (right now I just have the trigger frequency at 50 meaning it just never gets triggered). Other than that I started work on the controls which I have scripted in but am like 95% sure don’t actually work without crashing the game (I guess we will find out soon enough). I had to do some weird spaghetti code to get everything properly wired up for the event loop so I got no idea what consequences that had for the rest of the triggers. That’s all for now let’s get back to it.

Attachment
Attachment
Attachment
0
georgegk

I did not in fact add controls. I was about to but I got side tracked cause my simulation script has a lot of bugs. First of all I had to readjust the demand tick function to gradually move from hour to hour instead of instantly changing and making the grid collapse. I also had to add a clear alarms button since alarms just kept pilling on without being removed and I realized that load never got shed, since I have made a typo when reading the node data and the script thought that no nodes could shed. It took me a long time to find all those and there are probably way more I just haven’t noticed yet. This is more complex than I thought but I am still having a lot of fun.

Attachment
0
georgegk

log time, no log (or whatever the saying is). I finally made the Simulation Engine™ for the game and let me tell you it was a lot of math/physics. The only thing that saved me was pen and paper where I manually organized the formulas I was gonna use for this. I won’t get into it here but it’s a lot of math, swing equations and so on and so on (some I didn’t even know myself, google saved me). I kind of haven’t connected it to the interactive menus (or created any controls), expect for the HUD, so I don’t exactly know if it’s functioning or not, I guess we will find out soon enough once I connect everything together. I fear that I haven’t written _tick_dispach() correctly to account for wind and solar so I will have to correct that like right now.

Attachment
0
georgegk

I completed the rest of the HUD. It has a gen VS load bar in the bottom middle that shows out difference in production/ demand, a panel in the top left to show the time, season, day, and some production statistics and lastly an alarm panel that shows how much we are exporting/ importing and a few important alarms whenever they happen. This project is going really well however the complicated math is starting to get to me.

Attachment
Attachment
Attachment
0
georgegk

So I designed this analog meter to display the current grid frequency to the player, but then I realized that it is a bit hard to read so I also added a digital display and a label to describe the current state. I will also have those warning displayed elsewhere in the HUD but it’s nice to have them right below there too. I like this design a lot I feel like the colours just pop

Attachment
0
georgegk

So I made this nice info screen. It might not look like much but it took quite some time to have it all functional and displaying text (I just noticed that the label text can overflow, I only fixed the overflow in the content area), after all I had to make the program that read the saved map file and rendered the data. I haven’t talked about the map at all. So I want it to be totally customizable and be able to include custom scenarios that’s why I have decided to save the maps as .json files that the player can choose from.

Attachment
0
georgegk

So update time! over this 1.5h I decided that I didn’t want to load the icons as files but instead have them generated using python, so with some help from claude I designed this system that creates an icon for each type of node. Now it did take quite some time to figure everything out but overall I like the new look, it feels very pygamey which is what I am going for with this project. I have zoomed in a bit so the labels are visible (I will probably need to fix that overlap won’t I)

Attachment
0
georgegk

So I mostly worked on getting everything basic setup, I have brain stormed this project quite a lot and I have decided to base the main map around oakridge alaska (shoutout: Oakridge Nuclear Power Station you have been a great inspiration in this project that’s why I am giving you the main map). It is a “small” exporter city with nuclear, hydro, solar, wind and gas peakers a perfect combo to implement a variety of features. Plus the subarctic location allows for weather features and interesting ice/temp related challenges. This is nothing too complicated yet just some transmission lines, a pannable map and some random nodes.

Attachment
0