Game Development

Idle Game

Release Date: December 2024

C# programmer

About the game: Developed a satirical idle game, focusing on improving efficiency and buying/expanding what companies the players own.
Mathematical models: Researched idle game mechanics and applied mathematical equations to determine dynamic costs and income for each company.
Int overflow into a readable scale: Implemented a logarithmic system to better format large numbers that would cause overflow errors (e.g., Billion, Tillion).

Intro:

The initial idea for the game came during a game jam when the designer/writer and I were planning out a game doing a weekend long game jam we were participating in. The initial idea had the player be able to buy a few companies and upgrades that would give them money every so often. We were able to make a MVP version of the game during the game jam, and many of the mechanics were implemented and are explained here. After the game jam I did decide to spend the next couple of months expanding the companies, doing more QA tests and balancing the general progression of the game.

Math for company profits:

One of the initial challenges with the game was how to calculate the dynamic cost or how much a company should be earning. For cost values I would get the base initial cost then multiply it by the the resulting value of the specific companies scale value to the power of the current level the upgrade or unlock level. This would give future designers 3 independently adjustable values that created a unique curve for cost of the item vs its benefit. Which forces the player to be strategic on what might be worth buying at any specific time or if its better to accumulate more money and acquire a more profitable company/upgrade. Even so the cost increases would be consistent in the changes that players could still predict and are given a smooth progression between different sections of the game.

Number representation on screen:

An interesting challenge that needed to be solved was working around integer overflows (Values that need to go past the maximum value a data type allows, around 2 billion for ints) and needing to display values beyond that point for costs and the amount of money the player has. For context on overflow variables, when creating a new variable in C# you need to set a data type At the same time, many players will want to count how many digits exist in values greater than 1 million as a way to determine how much money they have. So it was important to adjust the counter so that it would display any value greater than 1 million into two parts, a reduced value and its corresponding name (Million, Billion, Trillion, etc).
I solved this by finding the log(10) of my initial value and then calculating the floor. This gives me the size of the intended final value (Million, Billion, ETC) and at the same time allowed me to divide it by a factor of 3 to get the remainder which tells the algorithem how many digits need to be displayed. With this info I round any final values and place it as a string and displayed. The final value also becomes the current balance for the player and future calculations are done on the new reduced values.
As an example let's consider the player has 23,456,789 dollars to spend. When doing a log calculation and obtaining the floor (Integer value of the current float) I have a length of integer of 7. I can then find the remainder of the value when dividing by 3 (2.3333). This new remainder float (0.3333) means that only 2 values (2 and 3) appear in the millionth section in the initial value, so I place the values 23456 into a new float and have any value past the 2 numbers in the millionth numbers are used as values past the decimal point (23.456). Finally, the value that I got from dividing the length of the integer by 3 (Which is 2.3333) is floored and that final value (2) is used to determine that the 'million' string needs to be added to the end of the previously calculated value. Leading to a final string of 23.456 Million.
One mechanic I decided to include after the game jam as an extra challenge was an energy source which would help improve efficiency for all companies as well as give players targets and a better understanding of their progress while playing the game. Every 6 companies that a player would get would unlock a new set type of energy source at a price a magnitude greater then what player normally would have at that point. This meant that players would have the dilemma of needing to decide what's worth it, wait some time to get enough money to buy it or upgrade what you already have so that at an even later date they have the money to not just acquire the new energy source but upgrade the efficiency as soon as you get it.