Game modding .... Who says studying algorithms is useless?
Replayability mod to randomize game layout gives a practical application for a PRNG and the "critical connections" problem
Replayability mod: This mod aims to increase replayability of Conquest Mode, largely by randomizing world maps
I recently picked up a game called Warpips on the Epic Store for free. Epic gives away weekly free games — usually quality games, just slightly older.
It's a single player tug-of-war style game with surprisingly intriguing strategy and gameplay.
After running through the campaign (or Conquest Mode, as it’s called here) a few times, I sadly came to the conclusion that it didn’t quite have the replay value I was hoping to get out of it.
Naturally, I decided to take this matter into my own hands and develop a mod for it!
Warpips is written with Unity in C# (as many games are these days, especially in the indy game dev scene), which is relatively simple to mod. I whipped out .NET Reflector to view the source code, grabbed BepInEx to hook my mod into the game’s runtime, and used Harmony to inject code.
I began with a very modest goal for 1.0.0 of the mod: a basic MVP that randomizes the campaign island layouts. Static world maps were the real replayability killer for me.
After only a couple hours, I had it working to where starting a new game would present with a unique randomly generated layout. Awesome!
But that’s when the problems started. I started finding and squashing bug after bug, mostly around reloading a saved game. I was messing with things that were statically loaded from the unity assets files rather than the game’s actual save file. The more bugs I squashed, or attempted to squash, the more cropped up and the more I discovered.
Also, sadly, I did have to scrap my cool idea of using a deterministic PRNG (seeded from underlying randomness of each play-through from the game itself) to avoid storing any state for my mod, as it got way too complicated and tricky to get right.
This ended up going on for nearly an entire weekend (sound familiar?). It turns out that trying to understand and modify large amounts of code well enough to avoid bugs with only decompiled source code to go off of isn’t the simplest of tasks.
Don’t get me wrong — there were certainly plenty of fun parts as well to keep me going! I, of course, used my own hand-written PRNG with its plethora of distribution methods to randomize a few other things as well and implemented a couple basic features beyond the original MVP.
I even got to bust out some graph algorithms that had previously been strictly academic for me, such as the “critical connections” problem I’d studied while prepping for big tech interviews over the summer.
Released!
At the end of the day I went ahead and released Version 1.0.0 on Nexus Mods. Given that I’ve dabbled in game modding on and off throughout the years but have never released a mod before, this is an exciting step for me!
Got some nice feedback on the mod (April 13, 2023):
“"Hey how about that. A big-time thank you. You just took a great game and made it infinitely better. I enjoy the campaign mode on the hardest difficulty but I never liked the 1 life only or inability to gain more lives throughout the run and after doing it enough times you see they maps are all the same and it's very formulaic. Your mod solves all that. So thank you very much. Made my day.”
I suppose this is another lesson on the importance of scoping projects properly and avoiding creep, something that transitioning my career from individual contributor to engineering manager has helped me improve at. When all is said and done, however, the fun I’ve had here does prove that I will always be a programmer at heart! :)
Do you enjoy programming on the weekends or in your spare time? What have you been working on?
Let me know in the comments below, and if you’ve enjoyed this post, please consider subscribing!